EEVblog Electronics Community Forum

Electronics => Projects, Designs, and Technical Stuff => Topic started by: andrejr on August 20, 2024, 08:01:44 pm

Title: Generating current limited bipolar pulses with MCU and H-bridge?
Post by: andrejr on August 20, 2024, 08:01:44 pm
Hi everyone!

I'm trying to design a neuro-stimulator-like circuit around an ESP32-S3. The output needs to be bipolar / biphasic (it's floating so an H-bridge will do), current limited, and the current needs to be controllable from the ESP32, likely with a digipot or DAC.
The ESP32 is likely too slow to be in the control loop, but is fast enough to generate the 4 signals for the H-bridge.

Let me preface this by saying that the parameters I want to achieve are:


I have several ideas on how to achieve this, but they all seem to be a bit overkill, so I'm turning to you for solutions on how to simplify this circuit.
It's for an open-source project that needs to be as cheap and as small as possible (fewer components = better).

I also have a working prototype (https://imgur.com/a/6E7Qrbl) that creates the required waveform with a bootstrapped improved Howland current pump, which is extremely overkill - it has a lot of components and requires a bipolar power supply (so 2 flyback transformers or a 2-secondary one).
Moreover,  I don't neet to generate arbitrary current waveforms, I just need short bursts of current-limited pulses. Also, it uses many components, some of which are relatively expensive. I also don't benefit from having ± rails, because the output is floating anyway (a double-insulated, battery powered device).

So for the new design, what comes to mind is having a single HV power supply, an H-bridge for making bipolar (biphasic) pulses from that voltage, and some sort of a current-limiting circuit with an adjustable current.

For the PSU, what I currently have is a little SMD flyback transformer (Coilcraft LPR6235-253PMRC (https://www.coilcraft.com/getmedia/1aa7eee3-2e1c-41c5-a485-234fb57f5458/lpr6235.pdf)) run with a MOSFET, and the PWM @ 100KHz is generated by the ESP32-S3; This generates some 120V from the battery's 3.2 - 4.2V and charges an electrolytic cap. I don't think this part can be improved much, save for a better snubber circuit.

I have a 3.3V rail, an unregulated 3.2-4.2 battery voltage, and a 120V from the flyback. If it's possible, I'd rather not add another SMPS converter for an intermediary rail.

For the actual current switching and limiting part, I want to use something like this:

https://oshwlab.com/pscdietrich/high-voltage-h-bridge (https://oshwlab.com/pscdietrich/high-voltage-h-bridge)

I'd likely use some NPNs that can handle the 120V, same goes for the MOSFETs.

ESP32-S3's GPIO module allows changing the states of many pins in 1 clock cycle, so I can use it to generate the signals to drive the H-bridge (I'll add dead time between switches just in case).

An alternative would be using a chip like DRV8833 to drive the MOSFET H-bridge.

As for the current limiting part, this comes to mind:

https://www.ti.com/lit/ab/sboa174d/sboa174d.pdf?ts=1723924270977 (https://www.ti.com/lit/ab/sboa174d/sboa174d.pdf?ts=1723924270977)

I could use something like an INA240 with a small current sensing resistor on the low side, and its output could either drive a schmitt-trigger-input quad AND-gate that ANDs the h-bridge driving signals with the output of the H-Bridge signal. The reference voltage would be provided by a DAC5571.

Another solution would be to take the output of the INA240 and feed it into a MOSFET or BJT that supplies the power for the top side of the H-bridge.

This would likely work even if the MOSFET ends up in the ohmic region most of the time while actually switching on, or I use a BJT, because I only need 3 x 150uS pulses (up-down) every 5 seconds at most, which means the average current and power is miniscule and the device is unlikely to overheat.

The third solution would be using this circuit, or a low-side equivalent, with a digipot for R2. I don't think that'd work right off the bat, the voltage across the digipot might not be too high, but it's likely that it's offset too high compared to the MCU voltage.
Title: Re: Generating current limited bipolar pulses with MCU and H-bridge?
Post by: moffy on August 21, 2024, 03:45:17 am
There is another way to approach it, using a bipolar current source that is switched by a half H bridge. The bipolar current source is only unipolar but uses a diode bridge and the switching waveform to be bipolar. For the zero points you could either switch the current source off or put a bypass switch across the load. The capacitor across the load is for glitch suppression due to the inevitable capacitances exposed to the switching edges. The blue trace is the input +/-120V switching waveform and the green is the +/-10V(+/-10ma) current limited output across the 1k load.

[attachimg=1]

P.S. Modified simulation, changed direction of current source.
Title: Re: Generating current limited bipolar pulses with MCU and H-bridge?
Post by: PCB.Wiz on August 21, 2024, 05:28:39 am
Hi everyone!

I'm trying to design a neuro-stimulator-like circuit around an ESP32-S3. The output needs to be bipolar / biphasic (it's floating so an H-bridge will do), current limited, and the current needs to be controllable from the ESP32, likely with a digipot or DAC.
The ESP32 is likely too slow to be in the control loop, but is fast enough to generate the 4 signals for the H-bridge.
How many of these do you need ?

If it is a single channel, a low side current sink, can be steered with 4 switch elements.
You will need care to avoid cross conduction, but low on duty cycles do allow a simpler bootstrap gate driver.

Below is the classic MOSFET precision current sink, easily controlled.
The feedback RC allows large C MOSFETS to be driven and control the overshoot.

Title: Re: Generating current limited bipolar pulses with MCU and H-bridge?
Post by: andrejr on August 22, 2024, 02:04:33 pm
Hi everyone!

I'm trying to design a neuro-stimulator-like circuit around an ESP32-S3. The output needs to be bipolar / biphasic (it's floating so an H-bridge will do), current limited, and the current needs to be controllable from the ESP32, likely with a digipot or DAC.
The ESP32 is likely too slow to be in the control loop, but is fast enough to generate the 4 signals for the H-bridge.
How many of these do you need ?

If it is a single channel, a low side current sink, can be steered with 4 switch elements.
You will need care to avoid cross conduction, but low on duty cycles do allow a simpler bootstrap gate driver.

Below is the classic MOSFET precision current sink, easily controlled.
The feedback RC allows large C MOSFETS to be driven and control the overshoot.

What you're suggesting is something like this, right?

https://electronics.stackexchange.com/questions/657221/high-side-h-bridge-where-low-side-is-connected-to-a-constant-current-source

The whole device has 1 channel only.

Title: Re: Generating current limited bipolar pulses with MCU and H-bridge?
Post by: PCB.Wiz on August 23, 2024, 11:00:21 am

What you're suggesting is something like this, right?
Somewhat.
If you want 20 kHz, the drive impedance needs to be lower, and lower fets can be n channel.
Choose lower C fets, ie lower current ones to lower your drive energies.
Give yourself plenty of voltage margin - maybe 250V or more parts on 120V nominal.
Note This current limit works on the load, but does not protect against test bench slips.

You want to avoid cross conduction, so a proper gate driver is easier than simple transistors.
Title: Re: Generating current limited bipolar pulses with MCU and H-bridge?
Post by: andrejr on August 25, 2024, 05:13:52 pm

What you're suggesting is something like this, right?
Somewhat.
If you want 20 kHz, the drive impedance needs to be lower, and lower fets can be n channel.
Choose lower C fets, ie lower current ones to lower your drive energies.
Give yourself plenty of voltage margin - maybe 250V or more parts on 120V nominal.
Note This current limit works on the load, but does not protect against test bench slips.

You want to avoid cross conduction, so a proper gate driver is easier than simple transistors.

Are you maybe aware of any gate drivers that would work with only the 100V and 3v3? Or maybe I can use a voltage divider for the 12V or 5V supply (they're mostly like that), because not much current is used, maybe buffered w/ a BJT?

For the voltage, I can increase that to 200V easily w/ a PWM adjustment, I just didn't because there was no need. The electrodes I use conduct quite well, even 60V is plenty to get the desired current through skin.
Title: Re: Generating current limited bipolar pulses with MCU and H-bridge?
Post by: PCB.Wiz on August 25, 2024, 07:46:17 pm
Gate drivers have a max rating, so you are fine using 200,250,300 or 600V rated drivers.
Just pick one easy to source, with a suitable deadtime.
You have light current needs, at sub 10mA and moderate speed at 20kHz so choose low C fets, also with plenty of voltage margin.
If pwm can go to over 200V, then pick parts comfortably above that.
With mosfet gate C, and a single current sink, you may need 4 STKY steering diodes so the negative gate drive of one side, does not disturb the positive drive of the other side.

Title: Re: Generating current limited bipolar pulses with MCU and H-bridge?
Post by: PCB.Wiz on August 26, 2024, 09:52:44 pm
Are you maybe aware of any gate drivers that would work with only the 100V and 3v3?
That's a rare combination. There are gate drivers with charge pumps, but they are not designed for fast switching.

Your currents here are low,  so you could experiment with Bipolar current mirrors with small gain.
In the idle state with no drive, there is no power loss.

High voltage, low Cre parts are available in NPN and PNP designed for Video/Chroma output stages  BF6xx,BF7xx,BF8xx series
Or, very common are xA44/xA94 parts, higher Cre and some vendors have higher gains, which might be 'good enough' ?


Title: Re: Generating current limited bipolar pulses with MCU and H-bridge?
Post by: Marco on August 26, 2024, 10:24:46 pm
I'd use an inverting buck boost and boost circuit to generate the high voltage (if needed with some diode multiplier stages, like Theremino) since it's lower power any way. Driven with a constant square wave (ie. constant power, provides a bit of safety). Use a couple TVS to limit it to say 140V and then linear regulators for your desired voltage. Efficiency is not required. Put some BJT current limiters on both rails and then use the H-bridge