2022-01-20 02:59 PM
I asked a question before on the routine SPD_GetAvrgMecSpeedUnit but the answers did not address what I was looking for. https://community.st.com/s/question/0D53W00000xsTlzSAE/information-on-the-c-code-procedure-spdgetavrgmecspeedunit-
This routine returns the average mechanical rotor speed and is called every Medium Frequency Task (1ms). The routine itself returns a pointer to SpeednPosFdbk_Handle_t..
I can't seem to find where the average speed is actually computed.? It is a moving average computed over STO_FIFO_DEPTH_UNIT samples (currently set to 64).
The Medium Frequency Task occurs every 1ms but the motor FOC calculations are updated every PWM period. Is the speed of the new sample put in the buffer calculated over 1ms or is it a "instantaneous" value measured between PWM periods?
My concern with the moving average filter is the linear phase incurs a large phase delay even at low frequencies (see bode)
Thanks for any help you can give,
Regards,
Solved! Go to Solution.
2022-02-07 08:57 AM
Hello,
May be the best solution is to download the latest SDK version 5.Y.4 (that provides the full code). You will be able to let the sliding window averaging for internal computation and insert your application computation in parallel...
Best regards.
2022-01-23 12:46 PM
Update:
I think the rotor speed calculation is done in STO_PLL_CalcElAngle with the moving average done in STO_PLL_CalcAvrgElSpeedDpp but these procedures are NOT available a source code. A consultant who works with ST provided 'private' functions STO_Independent_PLL_CalcElAngle and STO_Independent_PLL_CalcElAngle. If these are copies of the original functions then it appears for a 22kHz PWM rate the speed is calculated every PWM period (11kHz Nyquist rate). It is then averaged in the moving average filter updated every 1ms (1khz) providing a 500Hz Nyquist rate. The filter has 64 taps so the filter has a stop passband of 15.6Hz and is linear phase. This means the phase shift at 15.6Hz would be 180deg just for the velocity filter. This is to large for my application.
I tried reducing the moving average length to 32 from 64 by changing STO_FIFO_DEPTH_UNIT but the motor would fail to spin up. My application has two loops; The inner loop is the standard ST velocity loop but once nominal speed is reached I apply an outer loop that measures phase error of the rotor relative to a reference phase (clock) and adjusts the inner loop speed to maintain zero phase error. I'm thinking of changing the configuration so that when switching over to phase lock mode I will not use the SPD_GetAvrgMecSpeedUnit() to obtain the rotor speed but will write my own routine that does not use the moving average filter.
Are my observations correct that the two above functions are not provided in the ST source code?
The procedures STO_PLL_CalcElAngle and STO_PLL_CalcAvrgElSpeedDpp are declared in sto_pll_speed_pos_fdbk.h but are not __weak.
Evidently the speed moving average filter needed for the open loop spin-up mode is not compatible with what I need in the closed loop phase lock mode.
2022-02-07 08:57 AM
Hello,
May be the best solution is to download the latest SDK version 5.Y.4 (that provides the full code). You will be able to let the sliding window averaging for internal computation and insert your application computation in parallel...
Best regards.
2022-02-24 03:59 PM
Just saw this answer today, will definitley check this out and report back,
Thanks,
Brian