Hello,
We are implementing a FOC algorithm in a BLDC motor. We are at the point where we have already the algorithm running and the inteerupts and ADC sampling are already working. However we foun out a problem that may affect a lot the ADC sampling and we do not know which should be the direction to follow. The following image represents a simulated PWM update where the control decides to increase or decrease a lot the duty cycle of the PWM.
The procedure in the control is as follows: ADC SOC trigger sampling of current in A, B and C. Then the FOC is executed and the Counter compare A is updated as soon as control finishes. The counter compare is shadowloaded so the true update will happen when the time base counter reaches 0 or the period value. The resulting waveforms are presented in the image. As you can see, because the counter compare is updated when timebase reaches the period, the PWM gets update in the falling edge of the high side, produceing a asymetric waveform.
The main problem is that the sampling is produced when the timebase reaches the period because it is suposed to be the average current value (i.e. the time that falls rigth in the middle of the PWM when is high). Because of the change of the compare value, the PWM middle value is not synchronized anymore with the timebase count period value. We are intereseted on having all pwm still synchornized to sample all of them at th same time and obting its average value.
One solution could be to update the compare values when timer reaches 0 before the timer starts increasing again. However, as you can se the control interrupt lasts 29us so it is not posible to update the pwm before. We would like to know which is the best path to follow in order to solve this situation.
Tahnks in advance,
David