cancel
Showing results for 
Search instead for 
Did you mean: 

ADC is reporting different voltage when motor not running versus running.

BTrem.1
Senior II

My motor control application uses the STM32G431. The code has a serial command that reports the Vbus voltage. To get the Vbus voltage I run the following in a low priority timer callback at triggers once per second.

float V_d = (float)PQD_MotorPowMeasM1.pVBS->AvBusVoltage_d;

volts = V_d * ((ADC_REFERENCE_VOLTAGE / BUS_PARTITIONING_FACTOR))/65535.0;

The motor supply is 5Vdc and with the motor On or Off a scope trace and DVM show the 5Vdc is not changing more than 2-3mV. The divider is 30k to +5Vdc and 10k to Gnd and the tap has a 4700pf cap to ground. The tap goes to PA3 (ADC1_in5)

When the motor is not running I typically report 4.8vdc but running I may see 4.5vdc on some boards and 5.3vdc on others. The supply rail is not changing but the reported ADC reading is changing.

I am using the following ADC for motor current, Vbus and Temperature:

U adc1_in3

V adc1_in2, adc2_in2

W adc2_in1

Temp adc1_in4

Vbus adc1_in5

My pwm frequency is 23kHz and the Vbus and Temp ADC's are set per the attached code file . Any ideas what would cause this reporting error?

5 REPLIES 5
Laurent Ca...
Lead II

Dear @BTrem.1​ 

Welcome to the STM32 Community

Could you give more details to the STM32 Community about your setup -the material you use- ?

(HW and also SW: CPU(s), tools and versions, board(s), motor(s) and so on)

And more especially did you use STM32 MC tools (such as MC_suite, STM32 MC Motor Profile, STM32 MC SDK, STM32 MC Workbench, the used example, the origin of the base of your application source code, and so on)?

Best regards

BTrem.1
Senior II

The motor was initially tested on a Nucleo-G431 board with a IHM17 driver (SPIN233). The motor was characterized using the MCSDK 5.45. It is a 6-pole pair PMSM with a start current of 500mA and a run current of 30mA. It is driven from a 5V bus. The base code was developed using STM32CubeMX 6.1. My board is a custom board using the STM32G431 48pin device. The code uses a combination of HAL and LL drivers.

In moving from the Nucleo-G431 64-pin device to the custom board G431 48-pin device I of course had to modify the pin assignments to get all functionality. Maybe my ADC's are not set up properly? I attached the .stmcx and .ico files. For code development I use STM32CubeIDE V1.5.

cedric H
ST Employee

Hello,

Could you confirm that you put your oscillo probe at the MCU pin level (be careful to be in high impedance mode), to be sure that what is seen by the scope is exactly what is seen by the ADC.

Another important point is to be sure that the ADC Vref (3.3) does not change at all. Most of the time ADC errors comes from a variation on Vref.

Finally, regarding your ADC setting, your sampling time could be a bit too small. It is set to 47.5 which is Ok for a Resistor input up to 2.2K. In your case, Input resistor is (30K)//(10K) = 7.5K. So from the data sheet, the value should be 247.5. (But it depends on the ADC frequency).

Cedric

Thank-you for responding. Yes, I did use a 10x probe and I probed right at the MCU pin. I have another board which reports adc sample 4.84v with motor off but 5.21v with motor on. I changed the sample time from 47.5 to 247.5 and it had no effect on the readings. The peripheral bus clock is 170Mhz and the ADC clock is 42.5MHz. Note also my motor run current is only 35mA so it is very small compared to my nominal Vbus supply current.

Brian

cedric H
ST Employee

Hello Brian,

The Vbus can increase once the motor is spinning due to the BEMF if the algorithm is not well tuned. This is what we you observe normally when you slow down your motor. But in your case if I understand it correctly, you do not see this variation on the scope correct ?

You are using SDK 5.4.5. Would it be possible to try the SDK 5.Y.2, and dump a waveform of your currents (which is possible with the new motor Pilot tool, and the new motor control protocol develop with the 5.Y series).

Regards

Cedric