I need to execute FOC control calculations once per two PWM reloads. In demo project there are these definitions:
#define M1_PWM_FREQ (10000) /* PWM frequency - 10kHz */
#define M1_FOC_FREQ_VS_PWM_FREQ (1) /* FOC calculation is called every n-th PWM reload */
#define M1_SLOW_LOOP_FREQ (1000) /* Slow loop frequency */
To change M1_FOC_FREQ_VS_PWM_FREQ value to 2 is definitely not enough.
What are necessary steps to be done in order FOC calculations to be executed rare than PWM reloads?
I see that you want to do FOC(clark/park transformation, PID,PWM modulation) in TWO PWM clock cycle, I think it is enough to set #define M1_FOC_FREQ_VS_PWM_FREQ (2) /* FOC calculation is called every n-th PWM reload */
But can you post the source code and part number you are using so that we can have a review?
Hi XiangJun Rong,
Thank you for the answer.
The source code belongs to the company for which I works and I have no right to distribute it.
I think that M1_FOC_FREQ_VS_PWM_FREQ is not enough, at least because in FreeMaster's parameter list there is "Fast Loop Period" according to which bunch of other parameters are recalculated.
There are "Fast Loop Period" and "slow loop period", the "Fast Loop Period" is the main loop, in the loop, the work of reconstructing 3 phase currents, calculating or estimating rotor position, clark/park transformation, Id and Iq PID, PWM modulation has to do. For the "slow loop period", in the loop, the actual speed is calculated, and the speed PID is calculated, the speed PID output is the reference Iq parameter for the current Iq PID. Generally, the "slow loop period" is about 1KHz, the "Fast Loop Period" is about 8K~10KHz.
Hope it can help you