cancel
Showing results for 
Search instead for 
Did you mean: 

In the MCSDK middleware is are the Observer bemf samples accessible ?

BTrem.1
Senior II

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.

0693W000007BAWqQAO.jpg0693W000007BAWWQA4.jpg 

  1. Is STO_PLL_GetEstimatedBemfLevel the correct method to access the BEMF Oberver value?
  2. Is TSK_HighFrequencyTask() the correct place to access the Observer value?
  3. Is the DAC set up incorrectly?

I don't know if the value I'm retrieving is wrong or if my use of the DAC for output is wrong.

3 REPLIES 3
Laurent Ca...
Lead II

Dear @BTrem.1​ 

Many thanks for your question.

I forward internally your question.

Best regards

==

Laurent Ca...

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.

Laurent Ca...
Lead II

The question has been set only to the "STM32 Motor Control" topic (the question is only about the STM32 SDK). 

Best regards

Laurent Ca...