Hi,
I am using TMS320F28335 processor to control brushless motor, among other things.
I control brushless motor with hall sensors. TI has some sample code how to do this in general. One deviation from standard code is that I do four quadrant control, i.e. we pwm both high and low switch. Problem I am having is that when I clock in new ePWM modules with new period settings, changes don’t happen simultaneously. It looks like first PWM module goes into effect right away, but second doesn’t until beginning of next pwm period. This leaves me with a whole pwm period where sometimes I push the current in incorrect direction and unnecessarily heat up the motor. I toggle the sync bit so the two pwm modules are synced, but once again not until second pwm period.
I tried playing with shadow registers, and sync bits, but with no success. I realize that it might be impossible to clock in two new pwm settings instantaneously and at the same time. So I am OK if there is a period delay, but only if both modules are equally delayed and they are in known state while waiting(i.e. they both low or both high).
I am using ePWM modules to control speed and commutation. Every time I need to commutate I choose new pair of switches and set them to desired pwm profile. In general my code works fine. The only problem I am seeing is in synchronization of newly selected swithes. Specifically, lets say I am commutating from switch pair (pwm1,pwm2) to (pwm2, pwm3). I disable pwm1, and set pwm2 and pwm3 to new duty cycle setting. Disabling of pwm1 appears right away. Pwm2 and pwm3 appear either stuck, from previews state, or in some random state for about half of pwm period. Then they appear synchronized and in correct states.
This delay in syncronization is causing hicups in my motor drive. Is there a prefered way to impose new synchronized state without much delay?
here is code snipet from one of six commutation states...
case COMMU_STATE_0:
{
// Power In
EPwm1Regs.AQCSFRC.bit.CSFA = 0; // PWM 1a (Ah)
EPwm1Regs.AQCTLA.bit.CAU = 2; // high when CTR = CMPA on UP
EPwm1Regs.AQCTLA.bit.PRD = 1; // low when CTR = PRD
EPwm1Regs.CMPA.half.CMPA = pwm_duty_ticks; // PWM duty cycle
EPwm1Regs.AQCSFRC.bit.CSFB = 0; // Comp PWM with Deadband on 1B
EPwm1Regs.DBCTL.bit.OUT_MODE =BP_ENABLE;//deadband(overides CSFB)
// Power Out
EPwm2Regs.AQCSFRC.bit.CSFA = 0; // Shifted Complement PWM
EPwm2Regs.AQCTLA.bit.CAU = 1; // Set Low CMPA on UP-count
EPwm2Regs.AQCTLA.bit.CBU = 2; // Set high CPMB on UP-count
EPwm2Regs.CMPA.half.CMPA = pwm_shifted_cmp_a; // PWM duty cycle
EPwm2Regs.CMPB = pwm_shifted_zero; // PWM duty cycle
EPwm2Regs.AQCSFRC.bit.CSFB = 1; // OverRidden by DeadBand
EPwm2Regs.DBCTL.bit.OUT_MODE =BP_ENABLE;//deadband(overides CSFB)
// Unused
EPwm3Regs.AQCSFRC.bit.CSFA = 1; // Low
EPwm3Regs.AQCSFRC.bit.CSFB = 1; // Low
EPwm3Regs.DBCTL.bit.OUT_MODE = BP_DISABLE;
break;
}
Once I execute one of six states I issue this command for synchronization...
// force pwm sync
EPwm1Regs.TBCTL.bit.SWFSYNC = 1;
Attached is a scope plot of the observed behavior and additional detail on the code.