Chopper H-bridge dead on arrival

Hey guys, first let me give you a short introduction, as I don't want to be the rude guy who just go straight and ask his problem on the forum. I'm a hobby machinist CNC enthusiast. I started with a small milling machine, with the size of a 3D printer, but now I have a bigger one. I did studied a subjet on electronics on the university, but you know, a lot of theory and problems, but very little real world practice. Since then I have done some small Arduino projects and the one I will show next, and I can say I have started learning electronics.

Since more than a year ago I have been trying to design a servo driver for my mill, inspired on the Mechaduino project, that once working I can share with the comunity. The problem is that the stepper motors I use are way bigger and powerfull than the ones the Mechaduino can handle. Specially I want to increase the supply voltage. This way I can fight the inductance of my motors, getting faster speed and more torque at high speed.

If anyone want to hear the whole history I will write it. After several circuits and a lot of forum reads, aplication notes and datasheets I got an H-Bridge circuit that kinda works. It uses 4 N-channel MOSFETs and 2 IR2103 gate drivers (with internal dead time). As I didn't wanted to deal with bootstraping on software I used a couple of DC-DC isolated converters to supply 12V to the high side MOSFETs. It drives high impedance loads well on both directions, the problem starts when I want to implement the 20kHz chopper to control the current.

I use a voltage divider to set the reference, a 0.1 Ohm power resisotor between the low side MOSFETs and ground as shunt, and a LM358 Op Amp to compare it. When the amperage through the shunt reaches the point where it's voltage is higher than the set reference, the output of the Op Amp triggers an interrupt on the MCU that drives the high side MOSFET OFF, and the low side one ON (after the dead time set on the gate driver to avoid shoot through condition). But whenever try this, my MOSFETs get killed, sometimes the gate driver too, and my power supply shuts off.

I saw somewhere that the inductance of the DC-DC converters could cause some triggering problems, so I give up and bought a ZS-H1A H-Bridge to see If I could get it working.

https://es.aliexpress.com/item/16A-DC-Motor-Drive-m-dulo-Dual-Way-H-puente-de-Control-de-unidades-IC/32869551194.html?spm=a2g0s.9042311.0.0.190563c06UmenT

It has a couple of H-Bridges in bootstrap configuration (with IR2104), some logic gates to conver the PWM and DIR inputs, and a buck converter to feed the gate drivers and logic gates. I got it wired and feed it with a 90% 20kHz PWM, the high impedance load (a bulb) worked fine.

Unfortunately it has no overcurrent sensing. So I cut the source of the low side MOSFETs of one bridge, and conected them to GND with my shunt and current sensing circuit. Went to connect my low impedance load (the motor) and... puffff, same result as before.

So, at this point, I got no clue about what is exactly killing my circuit and what I can do to avoid it. Any help will be greatly apreciated!

I think all of the Original Post boils down to "What stepper motor driver should I use with my big stepper motor".

If I am correct then you need to post a link to the datasheet for your stepper motor.

A H-bridge is not a suitable driver for a powerful stepper motor.

In the meantime these links may provide some background.
Stepper Motor Basics
Simple Stepper Code

...R

Post a link to your stepper motor, and we can probably recommend a suitable driver.

Unless, of course, you want to repeat the hundreds to thousands of engineer-years required to arrive at the current advanced state of stepper motor driver designs.

Hi Robin2 and jremington, I think you didn't understand the point or maybe I expressed myself wrong (English is not my mother language). I do know how stepper motors works, how to controll them, how the stepper drivers works and the correct stepper driver to use on mines. I have been using them for some years now.

What I'm trying to achieve is convert my steppers in 2 phase BLDC servo motor, with my own design driver to achieve greaters speeds increasing the supply voltaje, and closed loop controll. To get that, I first need to get a working H-bridge with current controll (of course the driver will use 2 bridges).

I conected my H-bridge circuit to one of the coils not to make the motor moving, but to achive a working current control on that coil by chopping. Once I have that working, I can control the motor without (hopefully) any problem. But that's what I can't get to work.

Thank you both for your interest in my problem. Hope that I clarified more it now.

EmperorDevilhunter:
What I'm trying to achieve is convert my steppers in 2 phase BLDC servo motor, with my own design driver to achieve greaters speeds increasing the supply voltaje, and closed loop controll. To get that, I first need to get a working H-bridge with current controll (of course the driver will use 2 bridges).

Just to avoid any further confusion I think that means that you want to replace your stepper motors with BLDC motors and you are looking for help with the design of the H-bridge to control the motors? is that correct?

If so I certainly did not get that impression from your Original Post or from your Title and it is a subject that is far beyond my pay grade.

If my understanding is correct you are more likely to attract help with a more meaningful Title - perhaps "Help with H-bridge design for BLDC motor". If you edit your Original Post you can change the Title.

...R

This is what you wrote first. Nothing about BLDC motors anywhere.

The problem is that the stepper motors I use are way bigger and powerfull than the ones the Mechaduino can handle. Specially I want to increase the supply voltage. This way I can fight the inductance of my motors, getting faster speed and more torque at high speed.

A modern current limiting stepper driver does exactly that. Buy one to suit.

This is what you wrote second:

What I'm trying to achieve is convert my steppers in 2 phase BLDC servo motor

That is basically what a modern current limiting, microstepping motor driver does, except to make a servo you will also need a shaft encoder.

You can buy both from many sources, and again save yourself hundreds to thousands of engineer-years of effort.

More or less, I will keep my stock motors, adding an absolute encoder to them, and upgrading the control algorithm to use them as brushless servo-steppers. To get that, I firts need to make the H-bridge working with constant current, doesn't really matter if it's for a stepper, a brushed or anithing else.

My problem is not in the H-bridge itself (I think), but in the chopping to controll the current.

I have been doing some reverse engineering on my drivers. The M542 that I currently use on my big steppers have a couple of H-bridges with IRF540 N-Channel MOSFETs and IR2101 gate drivers. Those don't have dead time so it must be done on software. This driver has 100 ohm gate resistor with antiparallel diodes to slow down turn on times, while maintaining fast turn off. On the other hand, the driver that uses the IR2104 has only 10 ohm gate resistors.

Each bridge on the M542 has a couple of 0.22 shunt resistor in pararllel between the source of the low side MOSFETs and the GND. The voltage generated on the shunt is compared with a couple of OP Amps. One is compared with a signal from the driver MCU (to set the current). The other one is compared with a voltage divider, I think to set some kind of 10 amp overcurrent protection.

I can't find any other component in the M542 that protects the H-bridge when performing the chopping, while mine with the same concept keep getting fried. Could be something with the control algorithm of the dead time, but the 500ns dead time of the IR2104 should be more than enough. Can be the inrush current too much? Can be my Op Amp too slow? Could be any other component that I don't know protecting the circuit? Does I need to add some blank time before triggering the chopper interrupt? I'm lost.

jremington:
You can buy both from many sources, and again save yourself hundreds to thousands of engineer-years of effort.

Unfortunately is not that easy. Common stepper dirvers usually lack of high enough voltage, underrating your motor. Even though I have a prefectly suited driver, I could buy a one capable of handling higher voltage, but still not so much.

There are new stepper drivers with close loop system. But they have an incremental encoder with lower resolution than the one I want. And still too short on voltage.

I could buy just an industrial servo, but they are waaaaay more expensive. Too much for the average hobbyist.

I want to develope an open source servo driver for those powerfull steppers and share it with the comunity, as all open source drivers I could find are for small ones. It's part of my hobby, I enjoy doing it and learn a lot, even if I have to use hunders of hours engineering it.

EmperorDevilhunter:
Hey guys, first let me give you a short introduction, as I don't want to be the rude guy who just go straight and ask his problem on the forum. I'm a hobby machinist CNC enthusiast. I started with a small milling machine, with the size of a 3D printer, but now I have a bigger one. I did studied a subjet on electronics on the university, but you know, a lot of theory and problems, but very little real world practice. Since then I have done some small Arduino projects and the one I will show next, and I can say I have started learning electronics.

Since more than a year ago I have been trying to design a servo driver for my mill, inspired on the Mechaduino project, that once working I can share with the comunity. The problem is that the stepper motors I use are way bigger and powerfull than the ones the Mechaduino can handle. Specially I want to increase the supply voltage. This way I can fight the inductance of my motors, getting faster speed and more torque at high speed.

If anyone want to hear the whole history I will write it. After several circuits and a lot of forum reads, aplication notes and datasheets I got an H-Bridge circuit that kinda works. It uses 4 N-channel MOSFETs and 2 IR2103 gate drivers (with internal dead time). As I didn't wanted to deal with bootstraping on software I used a couple of DC-DC isolated converters to supply 12V to the high side MOSFETs. It drives high impedance loads well on both directions, the problem starts when I want to implement the 20kHz chopper to control the current.

I use a voltage divider to set the reference, a 0.1 Ohm power resisotor between the low side MOSFETs and ground as shunt, and a LM358 Op Amp to compare it.

The LM358 is utterly wrong for this application, you need a high speed comparator, not the slowest opamp
in the world... The comparator needs to drive the MOSFET driver chip immediately, you can't afford interrupt latency. The LM358 can't slew at anything like the rate needed for a logic signal.

[ I just looked up the datasheets - the LM358 response speed for a small signal of a few 100mV is about 500 microseconds - that's even worse than I thought. A standard LM339 comparator has a small signal response time of 1.3us, 400 times faster, and faster comparators are available. ]

Have fun and keep us posted.

EmperorDevilhunter:
More or less, I will keep my stock motors, adding an absolute encoder to them, and upgrading the control algorithm to use them as brushless servo-steppers. To get that, I firts need to make the H-bridge working with constant current, doesn't really matter if it's for a stepper, a brushed or anithing else.

OK, it seems like my attempt at a summary in Reply #4 was all wrong. I don't reckon I am bad a summarising things so you may like to reflect on the material you had given me to work with :slight_smile:

Now it sounds like you believe you can make a stepper driver that is better than the available stepper drivers from firms such as Gecko.

If so I think that is just a teeny bit beyond the scope of this hobby forum. It is certainly beyond my ability.

...R

PS ... Your Title still conveys nothing about the problem you want help with.

That's an insteresting point, MarkT. I did not acknowledge there where so much difference between Op Amps, and clearly did not pay enough attention to it's datasheet. I just ordered a LM393 to test, as is compatible with the boards I have (and it has 1.3us response time too). I want to use a smaller shunt resistor (0.01ohm) in the future board, so the signal is goint to be small.

Speaking about the Op Amp, one point I was debating myself is what is better: using one Op Amp to multiply the sensing voltage to something around 0-3.3v, and then comparing it with the setpoint of the MCU, or using a voltage divider with the setpoint and compare it with the raw sensing voltage. I thing the last one is more efficient, as should be faster and with fewer components. Maybe can be less precise, but I don't think that is goint go affect too much. What do you think?

Robin2:
Now it sounds like you believe you can make a stepper driver that is better than the available stepper drivers from firms such as Gecko.

Yeah, I think it can be done. I don't have the whole knowledge right now, but I hope I will. I want to get a working design first (with similar performance as the standar drivers) and then, being open source, start improving the design with all the comunity. A lot of people already have machines working with steppers that can be greatly improved with this driver. Some of my goals are:

-Up to 100V and 6A (per coil) in the first board, but that could be increased in other versions just by changing some components (200V should be nice).
-Migrate the software to a faster MCU: Mechaduino software use a SAMD21, I got it working on a ESP32.
-Faster chopper frecuency: most drivers use 20kHz nowadays, to improve that I need better gate drives and higher quality MOSFETs.
-Faster PID frecuency: Mechaduino use 10kHz frecuency.
-Capable of driving one stepper motor or two brushed DC motors, both in open loop and closed loop configuration.
-Read the actual current with the MCU.
-Read both motor and driver temperature.
-Read absolute (AS5047 or AS 5048 14bit) and incremental encoders (with index). And send the quadrature and index signal to the CNC controller to perform hardcore operations like rigid tapping.
-Read the signal from glass scales in the machine, as they are more precise. Use this signals for position controll, while encoder signals are used for motor control.
-Faster DAC to set the max current. The Mechaduino uses just PWM with filtering and I don't like it at all. The ESP32 has 2 DACs, but I don't know how fast they are or if they are able to get 0V right. If using other MCU with more outputs, I was thinking on a R-2R ladder IC and just write the whole byte register at the same time.

Hope this project is interesting for the comunity and people want to participate on it, sharing their knowlege, ideas, improving the software, ect.

Regards!

EmperorDevilhunter:
That's an insteresting point, MarkT. I did not acknowledge there where so much difference between Op Amps, and clearly did not pay enough attention to it's datasheet. I just ordered a LM393 to test, as is compatible with the boards I have (and it has 1.3us response time too). I want to use a smaller shunt resistor (0.01ohm) in the future board, so the signal is goint to be small.

Speaking about the Op Amp, one point I was debating myself is what is better: using one Op Amp to multiply the sensing voltage to something around 0-3.3v, and then comparing it with the setpoint of the MCU, or using a voltage divider with the setpoint and compare it with the raw sensing voltage. I thing the last one is more efficient, as should be faster and with fewer components. Maybe can be less precise, but I don't think that is goint go affect too much. What do you think?

With a low value shunt amplifying can be worthwhile (for higher currents the sense voltages tend to be
less in order to keep the shunt resistor size within sensible bounds). You'll need a fast precision
opamp, something with more like 1MHz full-swing bandwidth.

Yeah, I think it can be done. I don't have the whole knowledge right now, but I hope I will. I want to get a working design first (with similar performance as the standar drivers) and then, being open source, start improving the design with all the comunity. A lot of people already have machines working with steppers that can be greatly improved with this driver. Some of my goals are:

-Up to 100V and 6A (per coil) in the first board, but that could be increased in other versions just by changing some components (200V should be nice).
-Migrate the software to a faster MCU: Mechaduino software use a SAMD21, I got it working on a ESP32.
-Faster chopper frecuency: most drivers use 20kHz nowadays, to improve that I need better gate drives and higher quality MOSFETs.

The basic chopping should be done in hardware, you need the speed and the failsafe behaviour. Then
DACs to set the current limits, and the speed of the microcontroller will then depend on the maximum
micro-stepping rate you want to support - the DAC has to be driven for every microstep (although you
can pull tricks at faster speeds, dropping the effective microstepping ratio).

-Faster PID frecuency: Mechaduino use 10kHz frecuency.
-Capable of driving one stepper motor or two brushed DC motors, both in open loop and closed loop configuration.
-Read the actual current with the MCU.
-Read both motor and driver temperature.
-Read absolute (AS5047 or AS 5048 14bit) and incremental encoders (with index). And send the quadrature and index signal to the CNC controller to perform hardcore operations like rigid tapping.
-Read the signal from glass scales in the machine, as they are more precise. Use this signals for position controll, while encoder signals are used for motor control.
-Faster DAC to set the max current. The Mechaduino uses just PWM with filtering and I don't like it at all. The ESP32 has 2 DACs, but I don't know how fast they are or if they are able to get 0V right. If using other MCU with more outputs, I was thinking on a R-2R ladder IC and just write the whole byte register at the same time.

Don't worry about the DACs, the limiting factor is precision of amplifying the shunt voltage (BTW you'll need
4-terminal sensing of the shunt resistor, so the opamp can usefully act as a differential amp and remove
common-mode errors.

Once you have hardware comparators controlling the current, you might need to worry about protection
circuit for gross shorts - the current feedback system is only fast enough to limit current when the load
is inductive, but if the motor leads short out this is no longer the case and the MOSFETs will immediately
pop unless you have a second fast comparator and latch to put the circuit into a shutdown/error state
with all MOSFETs off. The limit for this can be set by trimmer resistor and will be above the normal
operating threshold by a reasonable big margin to prevent false triggering.

Hope this project is interesting for the comunity and people want to participate on it, sharing their knowlege, ideas, improving the software, ect.

Regards!

The basic chopping should be done in hardware, you need the speed and the failsafe behaviour.

Do you mean hardware interrupts or hardware components? At first I was designing to do the chopper with hardware components, mixing the signal from the MCU and the Op Amp with some logic gates, but I was afraid to get too high natural frecuency and my gate drivers and MOSFETs could overheat with the switching losses. Seen that most chopper works at fixed frecuency from the MCU I selected the hardware interrupts.

the DAC has to be driven for every microstep (although you
can pull tricks at faster speeds, dropping the effective microstepping ratio)

Not exactly this way on a servo drive, as I understand. Input and output microstepping will not be the same, and the DAC will be set at PID frecuency. Let me explain it with the example of what I'm looking for my machine:

My mill have 5mm pitch ballscrews, I want 1um resolution so with 200 steps motors I need 25 microsteps. Also up to 12000mm/min travels means that the input step frecuency is 200kHz. But the DAC will be 8bits, around 10 times more output microsteps. Why? If I want to move the motor for a fix position, but the mechanical load aplied and the magnetic springiness does not let the motor get to the setpoint, the controller will command the motor to move the amount of magnetic degrees foward to compensate this position. But that can be in between input steps.

In the case of a 20kHz chopper, each 50us the MCU reads the encoder position, calculate PID with the corresponding setpoint, set the DAC and finally switch on the MOSFETs. Before the next cycle, the chopper interrupt switch off the MOSFETs if the current is reached. If not, they must be switched off at the end of those 50us to perform the bootstraping. PID ecuations calculate DAC output from current position, setpoint, past desviations and expected desviations, so is not set for each microstep like on a stepper driver, it will jump several steps each time is set.

you'll need
4-terminal sensing of the shunt resistor, so the opamp can usefully act as a differential amp and remove
common-mode errors

Can you tell us more about this topic? I know there are several ways to read the current, but I only know how to perform the simplest one, with the sunt between GND and the low side MOSFETs. I know that's not the real current through the coils, but that's how my comercial drivers works.

Once you have hardware comparators controlling the current, you might need to worry about protection
circuit for gross shorts - the current feedback system is only fast enough to limit current when the load
is inductive, but if the motor leads short out this is no longer the case and the MOSFETs will immediately
pop unless you have a second fast comparator and latch to put the circuit into a shutdown/error state
with all MOSFETs off. The limit for this can be set by trimmer resistor and will be above the normal
operating threshold by a reasonable big margin to prevent false triggering.

I think that is what the Op Amp that comparates with a fixed voltage on the M542 drivers do. Anyways this will be a future improvement.

EmperorDevilhunter:
Do you mean hardware interrupts or hardware components? At first I was designing to do the chopper with hardware components, mixing the signal from the MCU and the Op Amp with some logic gates, but I was afraid to get too high natural frecuency and my gate drivers and MOSFETs could overheat with the switching losses. Seen that most chopper works at fixed frecuency from the MCU I selected the hardware interrupts.

in hardware

Not exactly this way on a servo drive, as I understand. Input and output microstepping will not be the same, and the DAC will be set at PID frecuency. Let me explain it with the example of what I'm looking for my machine:

My mill have 5mm pitch ballscrews, I want 1um resolution so with 200 steps motors I need 25 microsteps. Also up to 12000mm/min travels means that the input step frecuency is 200kHz. But the DAC will be 8bits, around 10 times more output microsteps. Why? If I want to move the motor for a fix position, but the mechanical load aplied and the magnetic springiness does not let the motor get to the setpoint, the controller will command the motor to move the amount of magnetic degrees foward to compensate this position. But that can be in between input steps.

In the case of a 20kHz chopper, each 50us the MCU reads the encoder position, calculate PID with the corresponding setpoint, set the DAC and finally switch on the MOSFETs. Before the next cycle, the chopper interrupt switch off the MOSFETs if the current is reached. If not, they must be switched off at the end of those 50us to perform the bootstraping. PID ecuations calculate DAC output from current position, setpoint, past desviations and expected desviations, so is not set for each microstep like on a stepper driver, it will jump several steps each time is set.

Can you tell us more about this topic?

I think you are complicating things a lot - simple bang-bang or hysteresis current control is easy and
reliable, one comparator, one H-bridge in synchronous rectification mode (per winding). I done this before
and its only down-side is somewhat lower efficiency and audible hissing/rushing noise from the motors.
I'll try and dig out the circuit I designed.

If you want to get into all the business of slow, fast and mixed decay modes you can of course, but
that's a side issue from my perspective.

I know there are several ways to read the current, but I only know how to perform the simplest one, with the sunt between GND and the low side MOSFETs. I know that's not the real current through the coils, but that's how my comercial drivers works.

Its done that way to remove the large voltage excursions if you do it elsewhere, and the current is
the real current through the coils (but always in the same direction due to the switching).

There is a clever way to use two shunts and a differential opamp to directly measure the current so that the direction isn't lost, which makes the comparator circuitry easy as it doesn't have to know what state the MOSFETs are in to select output polarity.

I think that is what the Op Amp that comparates with a fixed voltage on the M542 drivers do. Anyways this will be a future improvement.

That's what I was trying to do on my first try, implement the chopper in hardware. One draw could be excesive switching speed, incrementing switching losses. Anyways, the drivers I have seen all do the chopping in software, but I still have both options. The idea is to mix the signal from the comparator and the MCU with a couple of AND gates.

Since my last post I have been looking for more info on operational amplifiers, what I found that did not knew is that there are specific Op Amps designed to work as comparator, in the saturation región, that are way faster than estándar Op Amps. I though they were just a configuration of the Op Amp. I have ordered some LM393 to test.

The decay setting is something I don't want to tackle yet, maybe for the future. I won't get that door closed until check the performance.

MarkT, can you explain more about the two shunts configuration? I have an idea of how can it be, but not sure if it will overshoot the voltage limit of the comparator.

Regards!

Not two shunts, two comparators, one is just ultra-fast shutdown on short circuits, it needs a latch to
hold the shutdown state (until manual reset?). The idea is that gross over current cuts out completely
until reset or power cycle, as this means either the rest of the circuit is faulty, or there's a short circuit.

With a working winding the rate of change of current is pretty modest and you can thus you can afford a little
noise-filtering (and amplification) on the signal to the chopper-comparator, but an over-current comparator
should see the raw signal direct from the shunt - as few components in the way as possible (fewer
things that might fail).

I've found what I think is the circuit I mentioned:

Can't remember what the dual DAC is, probably some micro chip MCPxxxx SPI job. This circuit doesn't have
second comparators, the current sensors are either ACS711 or ACS712 I think (too slow for short-circuit
protection purposes I reckon)

ISENSEA and ISENSEB are the current feedback signals, back to the comparators and gates driving the FAN7388 drivers (they are 3-phase drivers but I think I used them as they are simple and seem robust from past uses).