[FEATURE] High-side current sensoring for stepper motor
Hi,
TI offers excellent chips like the DRV8262/8962 for stepper motors. However, both of these chips feature an integrated high-side current sensor. From reading your documents, I understand that for stepper motors, the shunt resistor measures the current for the entire H-bridge. Based on this, it seems to me that it shouldn’t matter whether I use the high side code or the low side code. If there is current in the high-side shunt, there must also be current in the low-side shunt.
That said, I am using the low-side configuration, but I am unable to get correct current measurements.
Additionally, I’m not entirely sure if my understanding is correct. For BLDC, can high-side current measurement be achieved by simply making small modifications to the low-side sensing code, such as adjusting the measurement phase at specific times?
I am looking to do the same thing, also curious why it shouldn't work as-is. For BLDC you might need to switch up the association between what current sense goes to what "phase", but other than that it should work I think
It's a matter of adjusting the timing so the current sensing is synchronised with the high-side FET on-time. For low side sensing it is synchronised with the on-time of the low-side FET, which is when the high-side is switched off, so high-side sensing will not directly work with the low-side sensing code.
Thank you for the reply! After writing this comment I read up on it a bit more and understand better the implications and reasons behind this. However what I am still unsure about is why this would be harder than low side sensing, shouldn't it be similar in the solution, but with a flipped polarity somewhere? Or is the issue that some hardware only happen to support a pwm/timer set up that just happens to coincide with/result in low side sensing? Do you happen to know of any documentation that can give insight into this?
Hey guys, just to add an additional comment here. @Tubbles-er you're right, in terms of MCU code, it's gonna boil down to some flag being on or off basically (but it's gonna be very very hardware specific :) ). I've done it a couple of times before, with stm32 and esp32. Which hardware do you have?
There aren't many applications where high-side shunts would be favorable over low-sode shunts. The low side shunts see much lover voltage over their terminals (mostly around 0) and therefore are easier and cheaper to produce in hardware. The high-side ones are seeing higher voltages almost VCC the whole time, so they require some matching with your application. But they are quite common in DC motor setups (not much in BLDC or Stepper). That's why we did not support it yet, we just did not have the hardware for it and not many people asked for it :)
Thank you for the response! Yeah that makes sense to me. We are looking to combine the stm32g431 with the drv8962, to make a hardware that is capable of both bldc and stepper motors. However that drive chip has built-in current sense over the high-side FETs, measuring the voltage drop over a somewhat well-defined 50 mOhm R_DSon. This seems to me to require high-side sensing capabilities and different synchronization with the PWM than low-side sensing. If you have tried this before with stm32 platform I'd love to take a look at your code!
So the quickest fix would be to use the low-side current sensing and chanege the sync moment.
For stm32, if I remeber correctly you just need to change this line:
https://github.com/simplefoc/Arduino-FOC/blob/395b6cd4c621fe460c1d61a99bc0fc38913d5481/src/current_sense/hardware_specific/stm32/stm32_adc_utils.cpp#L348
add a line after it, basically inverting the result
next_event_high_side != next_event_high_side;
This should work I think. If it doesn't direclty work look into this function _initTimerInterruptDownsampling. It is responsible for determining if the sync is high or low-side.