0

I have been working on a custom electronic speed controller I designed and built partly based on a reference design from ST Microelectonics; the STEVAL-ESC001V1.

My board uses the same MCU, a STM32F303CBT7.

I am having difficulty understanding how to configure overcurrent protection.

The reference design uses a voltage divider to provide a 0.5Vdc reference voltage to PA4 via a 0 ohm resistor (not mounted); or you can use the DAC output on PA4 to supply a reference voltage. Alternatively, you can also select to use internally pre-set voltages to supply the comparator reference which was done in the STEVAL-ESC001V1 firmware example. In their example they selected 0.6V which corresponds to a peak current of 33amps. enter image description here enter image description here

Either source goes to the negative input of each comparator used for overcurrent protection; the positive inputs of each comparator being the three phase motor current which is proportional to the voltage across the shunt resistor used to measure motor current.

In my design I am using a 2milliohm shunt resistor and want the overcurrent trip to be 100A peak. This would correspond to a peak voltage of 0.2 volts on my shunt resistor (0.4Vp-p for clarity if you were considering the negative half cycle. Since the comparator doesn’t care about the negative half cycle I assume it is safe to ignore it.).

So I created a voltage reference of 0.2Vdc and have connected it to pin PA4 of my custom board. When I go to the configuration settings for OCP in Motor Control Workbench (MCWB) I select Embedded HW OCP, External for the Inverting Input which corresponds correctly to pin PA4; however, when I enter 0.2V as the Voltage Threshold I get 0.000Apk. Further, when I try to generate the code for CubeMX I get the errors “motor nominal current value is higher than over current protection” and “Voltage threshold (0.2V) is lesser than offset (0.294 V)”.

enter image description here

What is the offset of 0.294V referring to and how is it generated? Did I configure something incorrectly? I cannot find any documentation from ST that answers this.

If I use the DAC as the reference for the inverting input, the generated voltage reference is 0.48V for a selection of 100A. How is this value calculated in MCWB? It is vastly different that my value of 0.2V.

If I stick to using my reference voltage of 0.2V, can I input a higher value in MCWB and overwrite the value in my IDE without risk of breaking the FOC FW? i.e. game MCWB.

I did read some ST application notes (after the fact) that suggest that the MCU comparator inputs come from the same node as the + input of the current sensing opamp (as this adds a dc offset to the current waveform), but I don’t see how this is necessary given we don’t care about the negative half cycle of the current waveform (the comparator output is already clamped at DC common).

enter image description here

Any tips, tricks, advice is welcome.

mike
  • 107
  • 9
  • Looks to me as though the combination of R14 & R17 create s voltage divider which gives U5's output a DC offset of about 0.294V - so your OC trigger threshold should probably be 0.494V (0.2V + 0.294). – brhans Jul 29 '23 at 02:42
  • Just to clarify, the circuit diagrams I shared in my question are from the STEVAL-ESC001V1 reference documentation. In this case the offset is indeed 0.294Vdc. This makes sense. However, while my design uses the same opamp architecture, my resistor values are 787 and 14.7k which is an offset of 0.168V. Regardless, MCWB isn't picking this up correctly, and why am I forced to use an offset? – mike Jul 29 '23 at 15:34
  • IMO I should be able to specify a reference voltage without hardware dependancies. So this leads to the question - can I game MCWB to generate the project in CubeMX and modify the values in my IDE? I ask because somewhere I read in documentation that it is a no-no to do this (or I could be wrong). – mike Jul 29 '23 at 15:37
  • The Control Stage selection box shown in this post is from my custom application with the correct resistor values for R14 & R17. – mike Jul 29 '23 at 16:04
  • You can almost certainly modify the offset value in your IDE after CubeMX does its thing - but you'll have to remember to re-modify them if you ever regenerate the project from CubeMX. – brhans Jul 29 '23 at 16:26

1 Answers1

0

To answer my own questions.

Q: What is the offset of 0.294V referring to and how is it generated? Did I configure something incorrectly?

A: The offset of 0.294V comes from the STEVAL-ESC001V1 reference design and is the offset to the opamp + terminal (3.3V x 787Ohm/(787 + 8060Ohm) = 0.294V). Despite using the values of resistors in my custom application, MCWB does not pick this up. I assume this is a bug in the MCWB application and is not something I configured incorrectly.

Q: If I use the DAC as the reference for the inverting input, the generated voltage reference is 0.48V for a selection of 100A. How is this value calculated in MCWB? It is vastly different that my value of 0.2V.

A: The reference value (voltage threshold) is calculated in the background of MCWB and is assumed incorrect given the observations made above. In my application the use of the offset isn't applicable, and the 0.48V reference from the DAC won't work for me.

I am able to set the voltage threshold in my IDE directly and without breaking the firmware. The file mc_parameters.c defines hardware parameters, one being the DAC_OCP_Threshold. The generated 16bit value can be overwritten to the value needed by my application, within the limits specified by the MCU datasheet. The 16 bit value is converted to a left aligned 12 bit value in the firmware using the LL library.

To test, I measure the DAC output to verify that it was aligned with what I expected. To verify that OCP works I connected the board to the MCWB Monitor. I then connected a variable DC voltage to the board (while simultaneously monitoring it on my scope) at each on the MCU inputs for COMP2/4/6. I then raised and lowered the voltage around the set threshold and observed the OCP was triggered in Monitor.

I also verified using an external voltage reference on PA4 works as expected.

In future I will use the DC offset as without it the threshold voltage can be very small and possibly too small for the DAC to accurately produce. Using the DC offset will help mitigate this being an issue.

mike
  • 107
  • 9