2021-01-11 12:36 PM
Hi All,
I'm working on a motor control system where I need access to the firmware bemf observer values for alpha and beta. Is this available in the middleware or MCSDK library? Can someone point me to documentation if it is available?
Edit:
Adding to this question, in mc_tasks.c in procedure __weak uint8_t TSK_HighFrequencyTask(void) I added the following: (value is declared static uint32_t (near line #736):
/* USER CODE BEGIN HighFrequencyTask SINGLEDRIVE_3 */
value = STO_PLL_GetEstimatedBemfLevel( (&STO_PLL_M1) );
HAL_DAC_SetValue( &hdac1, (uint32_t) DAC_CHANNEL_2, (uint32_t) DAC_ALIGN_12B_R, (uint32_t) value);
/* USER CODE END HighFrequencyTask SINGLEDRIVE_3 */
My setup of DAC1_CH2 in MX_Dac1_Init is the following:
/** DAC channel OUT2 config
*/
sConfig.DAC_Trigger = DAC_TRIGGER_NONE;
sConfig.DAC_ConnectOnChipPeripheral = DAC_CHIPCONNECT_EXTERNAL;
sConfig.DAC_SampleAndHold = DAC_SAMPLEANDHOLD_ENABLE;
if (HAL_DAC_ConfigChannel(&hdac1, &sConfig, DAC_CHANNEL_2) != HAL_OK)
{
Error_Handler();
}
The actual DAC output 'resembles' what I expect (a 0.5V sinewave at 200Hz) but it has spikes every period of the motor PWM frequency.
I don't know if the value I'm retrieving is wrong or if my use of the DAC for output is wrong.
2021-02-28 08:45 PM
Dear @BTrem.1
Many thanks for your question.
I forward internally your question.
Best regards
==
Laurent Ca...
2021-03-01 08:19 PM
On question [3] I did find that the MxCube generated code already was calling UI_DACUpdate(TSK_HighFrequencyTask()); in stm32f03x_mc_it.c, so at least one DAC was being called twice in one interrupt period. I've been able to fix that. No spikes, it's a nice clean sinewave 6x per revolution on a 6 pole-pair motor.
2021-06-01 01:52 AM
The question has been set only to the "STM32 Motor Control" topic (the question is only about the STM32 SDK).
Best regards
Laurent Ca...