cancel
Showing results for 
Search instead for 
Did you mean: 

Check PWM Duty Cycle on Motor Control

Agga
Associate II

Hi.., Currently, I'm using STSPIN32F0601 and driving the BLDC motor using ST-MCSDK-5.4.5 and I'm very new to it. After spending a couple of weeks studying, I know how to call the API to check parameters like VBUS, Motor Speed, Motor Power, Phase current, and so on. The problem that I'm facing is I would like to check the Duty Cycle of the PWM signal when the motor is running. So.., may I know how I can see the real-time duty cycle of the PWM.

Thanks for your reply and help.

5 REPLIES 5
SRedd.5
Senior III

I use MCSDK 6.2.0 the duty cycles are available in the function

 

__weak uint16_t PWMC_SetPhaseVoltage(PWMC_Handle_t *pHandle, alphabeta_t Valfa_beta)

 pHandle->lowDuty = (uint16_t)wTimePhA;
 pHandle->midDuty = (uint16_t)wTimePhB;
 pHandle->highDuty = (uint16_t)wTimePhC;
 pHandle->CntPhA = (uint16_t)(MAX(wTimePhA, 0));
 pHandle->CntPhB = (uint16_t)(MAX(wTimePhB, 0));
 pHandle->CntPhC = (uint16_t)(MAX(wTimePhC, 0));

 uint16_t  CntPhA;                                    /**< PWM Duty cycle for phase A. */
  uint16_t  CntPhB;                                    /**< PWM Duty cycle for phase B. */
  uint16_t  CntPhC;                                    /**< PWM Duty cycle for phase C. */

The function is called in FOC routine.

Thanks for your help.

I will try to test it.

@SRedd.5  Hi Sir, really thank you for your suggestion and I also found it in my mcsdk 5.4.5. Unfortunately, I'm able to call the variable to my main.c file. I want to see that CntPhA value as a live watch parameter in the IDE. May I know how can I call it? sorry for my poor programming skills.

To watch a variable live while the code is running two options are available 

1. Enable a DAC channel and observe it on the scope.

2. Use Cube monitor tool using the ST link.

The option 2 is easy try it, you are not required to call the variable in the main.c file.

https://www.st.com/en/development-tools/stm32cubemonitor.html 

 

 

 

Hi mate, i want max duty is 60%, because after rectifier AC220v i will get 310v dc but my motor only 200v, so if i used max pwm 60% iwill get avarage 186v right, how to se?? On that funtion stetphasa voltage?? Or change pulse value???