Because of the holidays, TI E2E™ design support forum responses will be delayed from Dec. 25 through Jan. 2. Thank you for your patience.

This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28065: How to drive PMSM motor using foc algorithm

Part Number: TMS320F28065
Other Parts Discussed in Thread: CONTROLSUITE, DRV8312, LM5109

Hello TI experts, 

I am going to drive a PMSM motor using foc algorithm. I have designed a board which contains a f28065 microcontroller. In order to do that I started with ti application notes. Then I customised it according to my board.

In my board I have connected hall-effect sensors to ecap1, ecap2 and ecap3 pins of the controller. 

I've got some questions.

1- in this application note, pwms are modified in interrupt servic routine of pwm1. When tbctr resets the interrupt is generated. My question is if do other pwms need to be synced with pwm1? I mean the value of tbctr register of other pwms shouldn't be the same as pwm1? 

2- as my motor is not equipped with encoder and I only have 30 edges of hall sensors,  is it possible to do position control precisely?

3- when I set buildlevel to level3, the motor rotates in open loop mode. But it generates lots of noise. 

I apologise if my questions are very basic. 

Thanks Pray

  • Hi  Hamid,

    Our PMSM expert is currently out of office, expect a response back by Monday. Apologies for the inconvenience.

    Thank you,

    Luke

  • 1- in this application note, pwms are modified in interrupt servic routine of pwm1. When tbctr resets the interrupt is generated. My question is if do other pwms need to be synced with pwm1? I mean the value of tbctr register of other pwms shouldn't be the same as pwm1? 

    Yes, the three ePWMs are needed to be synchronised for a motor drive.

    You may take a look at the training workshops as the links below about C2000 and motor control.

    https://training.ti.com/c2000-motorcontrol-training-series

    https://training.ti.com/c2000-mcu-device-workshops

    2- as my motor is not equipped with encoder and I only have 30 edges of hall sensors,  is it possible to do position control precisely?

    That depends on the requirements your system. In most of cases, the hall sensor is not good enough to do  position control precisely.

    3- when I set buildlevel to level3, the motor rotates in open loop mode. But it generates lots of noise. 

    Which example project are you using? That could be normal to run a motor with open-loop, you may try to tune the reference voltage and speed for open-loop control.

  • Thank you for your invaluable comments.

    I have started with this example project:

    • C:\ti\controlSUITE\development_kits\DRV8312-C2-KIT_v128\PM_Sensorless
      And then I modified it based on my board. I modified it somehow to generate pwm pairs ( PWMxA and PWMxB) and also I modified deadband parameters of each pwm.
      In this example project EPwmxRegs.TBCTL.bit.SYNCOSEL of each pwms is set to zero and and also EPwmxRegs.TBPHS.half.TBPHS of each pwm is set to zero but I can't find any piece of code to do the synchronization.
    • I checked the output signal of half-bridges, there are three sine wave with almost the same phase.
  • Do you still want to run the motor with hall sensor? and need position control? Or the sensorless is enough for your application?

    C:\ti\controlSUITE\development_kits\DRV8312-C2-KIT_v128\PM_Sensorless
    And then I modified it based on my board. I modified it somehow to generate pwm pairs ( PWMxA and PWMxB) and also I modified deadband parameters of each pwm.

    Are you changing the code for DRV8312-C2-KIT? or your own board? DRV8312-C2-KIT doesn't need to enable the deaband for PWM output.

    In this example project EPwmxRegs.TBCTL.bit.SYNCOSEL of each pwms is set to zero and and also EPwmxRegs.TBPHS.half.TBPHS of each pwm is set to zero but I can't find any piece of code to do the synchronization.

    All of the EPWM are synchronized by default.

    I checked the output signal of half-bridges, there are three sine wave with almost the same phase.

    Which build leve are you working on? The outputs should be PWM signals with variable duty in build level 2~7.

  • In my application I need to do position controlling. If I can't do it with hall effect sensor, I will go for the motors equipped with the encoder. As much as I know, to drive pmsm motor there is no need to hall sensors. I mean it makes no difference to use sensored or sensorless method for this purpose. I wonder to know your opinion.

    And I've got a question. You said that pwms are synchronized by default. But when I check the counter value of each pwm in debug mode, I see that they are not the same. And when I set the cmpa value of each pwms in the interupt service routine of epwm1, the value of cmpa value of epwm2 and epwm3 are updated in different time. To make the story short, I am sure if I am updating pwms correctly.

    I'm not using DRV8312 driver, I've used three lm5109 to drive the high side and low side n-mosfets. I chose this example project because it provides more functions for f28065 microcontroller.
    Finally I apologize the misinformation, the output of half-bridges is not sine wave. There was a problem with my oscilloscope. Here is the waveforms of svgen.ta and svgen.ta -svgen.tc. (build level is set to level2)

  • Seems like you enabled the filter on the probe to monitor the current and voltage. The waveforms are right when use SVPWM for FOC.

    The registers and variables are not updated at the same time in the watch window, so you can't check the real immediate value in the debug mode. 

  • Thank you for your invaluable comments. 

    I've got a question. How BASE_FREQ (base electrical frequency) should be set? In open-loop mode when I set it to 20, it works fine however in closed loop mode (LEVEL4) when it is 20, the motor generates lots of noise. In this mode if I set it to 200, it generates much less noise. Could you please tell how I must adjust the frequency?

  • You just need to set the value equals to or greater than the rated frequency of the motor according to the motor you used. So it could be 200~400 for most of the motors.

  • Thank you. I really appreciate your help.