cancel
Showing results for 
Search instead for 
Did you mean: 

How to read additional ADC channel in Motor Control MC SDK 5.4.4 (STSPIN32F0601)?

GenuineDeveloper
Associate III

I am using MC SDK 5.4.4 to drive a PMSM motor using STSPIN32F0601. Now, I want to add a potentiometer to my system to sense different user selectable levels. Generally, in other appplications we can intialize the ADC and read the ADC converted values as and when required. But after referring the documentation I found regular_conversion_manager (RCM) to use the ADC channels. I am using an ADC channel other the ones assigned for phase current sensing, voltage bus sensing, temperature sensing. How do I go about to read an ADC channel in this case?

12 REPLIES 12
cedric H
ST Employee

Hello G,

I did the test with an STSPIN3202 without issue.

I tested both, with the proposed fixed (that should not change anything in your config) and without the fix.

In both cases I did not observe any wrong values read at the ADC. (without touching the potentiometer, the value read does not not vary more than 2.6% ).

You mentioned that applying the patch reduce the occurrence of the reading. That's make me wonder in which context did you execute the additional code ?

It should be in the main while loop. Not under interrupt.

Regards

Cedric

GMaud
Associate II

Hi ST Support,

I moved to the latest MWB version 5.4.4. Tested the ADC in standalone mode (no motor running) and then also with motor drive features active.

The MWB 5.4.4 framework resulted in better ADC BUT still not a stable ADC result.

With a fixed volatge on the input and correct sampling times I get 0x0080 noise values.

I verified the schematics and measured the voltages and seems like I found the cause.

The VDDA receives its voltage from the SW output. The SW output has a coil and capacitor, but the output has a 3V3 level with sawtooth

on top of it. This is fed into the VDDA so the analog voltage reference is very noisy! The sawtooth noise is 120mV.

This is the STSPIN3202 evalboard based design and also follows the STSPIN datasheet.

But if I look at the STM32F31 datasheet, I would rather use a ferrite followed by a 1uF and 100nF capacitor at the VDDA input (DocID025743 Rev 6 37/106).

The main question now is:

Does it make sense to put a ferrite followed by 1uF + 10nF to feed the VDDA?

On a normal CPU this would fix the noise issue on the ADC.

BUT I am not sure if this will work on STSPIN32. In the datasheet it looks as if the internal DCDC looks at the VDDA level to regulate the switching. So

filtering the VDDA might result in DCDC issues.

Can you confirm that filtering the VDDA will work on STSPIN32?

Hello @GMaud​,

as you can see in the STSPIN32F0A datasheet, the VDDA pin is the feedback of the DCDC regulator, so it is not possible to filter it.

I can suggest two options:

  1. to use the MCU internal reference to compensate ripple on VDDA voltage
  2. do not use the internal DCDC regulator and provide externally the 3.3 V supply voltage directly on the VDDA pin (refer to section 6.2.1 in the datasheet).

Please, next time open a new topic to ask new questions to help the Community members who might have similar concern.

If you want to refer to an old post you can add the link in the text ;)

If you feel a post has answered your question, please click "Accept as Solution"