cancel
Showing results for 
Search instead for 
Did you mean: 

Shunt resistor current sensing with inverting opamp circuit

Zeno
Associate III

Trying to model and use an inverting opamp circuit for current sensing

[PN]: STM32H755ZITx 
[VERSION]: MCSDK 6.3.2
[TOOL]:MC WB, Board Designer, Firmware, MC PROFILER, etc..)
[DETAILS]: Using an inverting opamp for the current sensing circuitry. Goal is to run FOC closed loop position control but can't seem to get the current sensing working properly.
[EXPECTED BEHAVIOR]: Able to configure an inverting opamp instead of a non-inverting opamp when using a (three) shunt resistor setup. 
Then once the project is created I want to use this to profile the motor parameters and run the motor in closed loop by using the current sensing circuitry. 
[HOW TO REPRODUCE]:Try to use the board designer and configure a current sensing feature, the only option available when working with external opamps is the setup with a non-inverting opamp. 

Zeno_0-1749023629749.png

 

 

 

We noticed that our opamp circuitry is different from what the (MCSDK) workbench expects and see that the behaviour when trying to run the motor in closed loop or using the motor profiler is bad. Our supply source gets drained from the moment we try to start the profiler. Our problem seems to be related to how the current sensing is perfomed in the MCSDK. 
This is our opamp circuit: 

Zeno_1-1749023971396.png


I wanted to have the model of it put into the Board Designer in order to use the workbench for our initial project generation but I'm unsure how to apply the fix for the inverting opamp circuit that we have?

I saw this post and tried it out but it doesn't seem to have the right effect https://community.st.com/t5/stm32-mcus-motor-control/how-to-invert-current-reading/m-p/669709#M9911 

 

If someone would be able to point me in the right direction on how to resolve this issue that would be great because this is the only thing now blocking us from running the motor in closed loop.
The different parameters needed in the workbench are also very confusing (polarization offset, offset network attenuation, ...)

 

1 ACCEPTED SOLUTION

Accepted Solutions
cedric H
ST Employee

Hello @Zeno,

I looked at your schematic. In your case the parameters are the following:

Polarization offset = 1.65V

cedricH_3-1749463919428.png

In your case Offset attenuation = 1 

Opamp gain = -10

The negative gain is fixed in the MCSDK 6.3.2 or MCSDK 6.4.0 

Regards

Cedric

 

 

 

 

View solution in original post

7 REPLIES 7
Zeno
Associate III

Currently tried runningn open loop to see how the MCSDK is handling the current sensing so I plotted phase a and phase b. 
At 100 rpm Vref of 20% gave me these results: 

Zeno_0-1749026510611.png

At 1000rpm Vref of 20% gave me these results: 

Zeno_1-1749026649390.png

 

Zeno
Associate III

FYI: closed loop control seems to be working by using the bypass in the other post: https://community.st.com/t5/stm32-mcus-motor-control/how-to-invert-current-reading/m-p/669709#M9911 

 

Both speed and position control seem to be working now for a motor on 48V. 

 

That makes me shift my focus into thinking that the culprit here might be the Motor Profiler running, I assume he'll reset the gains for the PI controllers and causes an extreme compensation which completely draws my voltage source. 

cedric H
ST Employee

Hello @Zeno,

I looked at your schematic. In your case the parameters are the following:

Polarization offset = 1.65V

cedricH_3-1749463919428.png

In your case Offset attenuation = 1 

Opamp gain = -10

The negative gain is fixed in the MCSDK 6.3.2 or MCSDK 6.4.0 

Regards

Cedric

 

 

 

 

Hi @cedric H

 

Thanks for the reply, looks like I'm using that parameterisation for the opamp circuit but I did also set the 
Amplifying network reference (Vm) * to 1.65V.
Is that correct? 

 

With kind regards, 

Zeno

Hi @Zeno ,

No, it is not correct. It should be 3.3V 

Regards

Cedric

Hi @cedric H , 

 

Thanks for the response, what is the use and influence of that parameter? 
Is it for example reflected in the drive_parameters.h or in pmsm_motor_parameters.h?

 

Regards 

Zeno

cedric H
ST Employee

Hi,

It should be used in parameters_conversion.h to set 

#define ADC_REFERENCE_VOLTAGE 3.3

Which is used everywhere you need to scale your ADC result like here :

#define M1_MAX_READABLE_CURRENT (ADC_REFERENCE_VOLTAGE / ( RSHUNT * AMPLIFICATION_GAIN))

To be 100% honest, I am not sure that this value is actually used or in preparation for future usage.

Regards

Cedric