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.
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)”.
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).
Any tips, tricks, advice is welcome.