adjustable 500mA bipolar current control for PCB trace electromagnet - Page 1
Forum section: electronics / projects

author: lynaghk
author_rank: Contributor
timestamp: November 28, 2021, 04:05:47 am
content: I'm experimenting with magnetic actuators and have had success generating a magnetic field using a motor driver to push 500mA through a copper wire in series with 5 Ohm power resistors to limit the current.I'd like to modulate this current, so I came up with the following design (schematic attached delow): High-side current into an h-bridge IC is read by a current sense amplifier and 0.1 Ohm shunt resistor, fed into a microcontroller ADC, which modulates the PWM duty cycle into that h-bridge.(I believe this is how the fancier current-limiting motor drivers work internally.)I'm running at 5V and max 500mA current, using cheap parts that can be assembled quickly by JLCPCB (Hence the Chinese h-bridge datasheet.)Given the relevant component specs:amp bandwidth is 210kHzmicrocontroller ADC sample time is 16us (60 kHz)h-bridge max PWM freq is 250 kHzI think I should be able to have a few kHz control loop no problem.However, I've never designed this kind of thing, so figured I should ask for advice / warnings / suggestions for new players like myself =DThanks!Datasheets:amp:https://datasheet.lcsc.com/lcsc/1811021124_Texas-Instruments-INA180A2IDBVR_C192764.pdfh-bridge:https://datasheet.lcsc.com/lcsc/2008171535_Bardeen-Micro.-BDR6122T_C724035.pdfmicrocontroller:https://www.st.com/resource/en/datasheet/stm32f401cc.pdf

author: T3sl4co1l
author_rank: Super Contributor
timestamp: November 28, 2021, 06:40:19 am
content: With a nearly whole dynamic range (i.e., 500mA nominal, but short-circuit is only a bit more at 1A), there should be little if any price to pay for getting the output stuck on, or for missing out on momentary peaks or whatever, so it's a good learning environment for the controls -- who cares if it's badly compensated, or oscillating, at first; you have all the time in the world to adjust it to perfection.This contrasts with SMPS, where the price for failure of a digital control might be 10 times or more fault current into an ill-conditioned (e.g. low resistance or shorted) load, or peak voltages causing breakdown of switching devices. More care is needed in that case; and one can develop experience in a simpler environment like this.60kHz sample rate means a maximum bandwidth of 30kHz (and something to do with aliasing beyond that), and the load should be 1st order (R + L) so the loop can run basically as fast as it can given the sample rate (a controller time constant of a couple samples) to give a 2nd order overall response. Set up for doing input step response testing, and adjust parameters until it looks right.It's not apparent what inductance you're working with; a "PCB trace magnet" doesn't sound very high, maybe a few hundred uH if that? This has an L/R time constant of say 200uH/5Ω = 40us, a mere ten cycles at the switching frequency -- or far fewer at lower frequency or if the inductance is much less. If the ratio is too low, you're basically just switching it on and off all the time, not controlling it as such, and the slower feedback loop certainly won't be able to do anything about that.BTW if you haven't already planned it, sync the ADC and PWM, say every 4th cycle start an acquisition -- or sooner preferably but I'm guessing you can't run the ADC that fast (ATMEGA?), so run it as fast as spec allows.Tim

author: Zero999
author_rank: Super Contributor
timestamp: November 28, 2021, 04:20:09 pm
content: Needless to say, this won't give a smooth current, but pulses.It should be fairly easy to change it to give a fairly smooth DC, without having to dissipate lots of power in a resistor.Replace the 5R series resistor, with an inductor and put the sense resistor in series with the PCB trace. Now the PWM will be smoothed by the inductor and the current sense amplifier will see the current, through the coil, rather than the power supply and it will use a fraction of the power.

author: lynaghk
author_rank: Contributor
timestamp: November 28, 2021, 10:18:12 pm
content: Thanks for the responses y'all!Tim, 100% agree that this is a friendlier project to learn on compared to a switched mode power supply =DI hadn't considered inductance at all, and it's actually even worse --- similar PCB trace "coils" have inductances as low as 1--10uH.Call it 5 uH, so with the fixed 5 Ohm resistance our time constant is 1us, which means the STM32 microcontroller's ADC sampling time won't be fast enough to provide meaningful feedback.I could slow the coil rise times by adding more inductance (I can't remove the 5 Ohm resistance, btw, that'll be from the long, thin PCB trace "coil" --- sorry if I was confusing earlier, the power resistors were just stand-ins for trace resistance while breadboarding with copper wires).However, based on my shopping around SMD power inductors, it'd take a few to sufficiently slow things down, which would add both to the BOM cost and coil resistance ($0.10, 100 uH, 0.5 Ohm per inductor).What if instead of trying to do closed-loop current control through the microcontroller, I handled it with analog circuitry controlled via DAC (PWM + low-pass filter)?E.g., LM393 comparator (1us response time) chopping a high-side P-MOSFET based on DAC output and voltage across low-side shunt (1 Ohm) underneath the h-bridge?The h-bridge would then be controlled by plain GPIO rather than PWM, since current control would be handled by this comparator chopper.Though a 1us response time comparator may be too slow also.Perhaps I can use the microcontroller ADC and DAC to drive a MOSFET in its linear region?

author: NiHaoMike
author_rank: Super Contributor
timestamp: November 29, 2021, 03:07:51 am
content: The average current isn't going to change much for a given duty cycle, mostly it will vary as a result of the resistance changing due to thermal effects, a relatively slow process. You can use a high PWM frequency and check/correct the average current at a much slower rate.

author: ajb
author_rank: Super Contributor
timestamp: November 29, 2021, 03:56:42 am
content: According to google translate, that bridge has a rise/fall time of 0.5us, so with a load time constant of 1us, that's not going to work out very well regardless of what's controlling the bridge. You might be able to drive it faster, but then the bridge is going to dissipate more power as it won't have time to fully turn on in any given cycle, and it might even blow up if it doesn't have built-in cross-conduction protection. 500mA at 5V is only 2.5W, so linear control wouldn't be that bad, as long as you're not concerned about battery life or something. The simplest way to do linear control is with an op-amp closing the loop between the sense resistor and the drive transistor, you'll need to compensate it for the load inductance but that shouldn't be too hard since both the power level and the inductance are pretty low. If you've got a DAC channel available on the MCU you can use that to drive the set point.Your idea of using a comparator to switch the coil current when it hits a setpoint could work, but it needs to be a fast comparator and a fast power stage to deal with your inductor's rise/fall time. You can find pretty fast comparators and power stages with conveniently built-in control loops in switching converter ICs, which is basically what you're talking about building, but even those tend to top out at a couple of MHz which is on the edge of what you'd need here.Instead of adding inductance directly in series with the inductor, you could use that extra inductance plus some capacitance to add what amounts to a buck converter *in front* of the load inductor. You could use an actual buck converter IC for this, and drive its feedback pin from the MCU to trim its output voltage to provide the desired current, or you could use the MCU's PWM to directly drive a half bridge that in turn drives the inductor, and rely on the current feedback to close the loop directly (you could also measure and control the intermediate voltage if you wanted to, could be a fun exercise). The frequency here doesn't particularly matter, provided that the ripple at the point where you connect the load inductor is low enough for your needs and accounted for in your control loop filtering. This would still be relatively efficient, if that matters to you.One other gotcha here, that applies to a lot of these methods, is that it sounds like you want to be able to reverse the coil polarity, right? If you're using a bridge IC to do that polarity control, and if whatever is controlling the coil current is outside of the bridge IC, then you have to make sure that your current setpoint always result in a voltage across the inductor and sense resistor that's above the minimum operating voltage of the bridge IC. If the DCR of the inductor is 5R, and that IC has a Vmin of 1.7V, your minimum current ends up being something like 340mA. The solution to this is probably to use discrete transistors instead of an IC. This allows you to get rid of the UVLO that many of those ICs include because your gate drive signals can still be at a reasonable voltage to get good switching performance even if the voltage supply to the bridge is only a volt or whatever. It may be more complicated/take more IOs to drive the discrete bridge, but if you're only using it to change polarity and not to regulate current via switching, then you can use jelly-bean logic level parts and just make sure to include a little bit of dead time when changing polarity.

author: lynaghk
author_rank: Contributor
timestamp: November 29, 2021, 05:57:41 am
content: Great point about the 0.5us rise time in the h-bridge, no way to chop the current from the outside.You're right that I need to be able to reverse the coil polarity, which is why I've been thinking I need an h-bridge.The datasheet for this one suggests that the undervoltage lockout only applies to VCC:so high-side current limiting on the "VM" input should work, yeah?That's what I was getting at with the comparator --- it wouldn't be driving one of the h-bridge inputs, but rather a high-side transistor controlling the flow of current into VM.That said, I'm not sure about the particulars of a comparator vs. opamp and (MOS)FET vs. BJT in this application, and whether the shunt resistor should be on the high or low side of the entire h-bridge.I'm assuming that the amp will get driven into saturation during h-bridge dead-time / shutdown, but as long as it doesn't lock up there I'm hoping that won't be a problem.

author: Zero999
author_rank: Super Contributor
timestamp: November 29, 2021, 09:17:56 am
content: Quote from: lynaghk on November 28, 2021, 10:18:12 pmI don't see how you can do this, without more inductance. I haven't done any calculations, but if 100µH is sufficient and the resistance is1⁄10of the PCB coil, that's pretty insignificant and 0.10$ isn't expensive, unless the budge is extremely tight and you're making a large volume.The only alternative is to use a linear Howland current pump and use smoothed PWM from the MCU, or an DAC output as the signal source.

author: ajb
author_rank: Super Contributor
timestamp: November 29, 2021, 04:34:21 pm
content: Quote from: lynaghk on November 29, 2021, 05:57:41 amAh, I missed that it has a separate Vm input, if that is truly able to operate all the way down to 0V then it should be fine, although I'd be skeptical of that without reading the rest of the datasheet.QuoteA comparator is going to be better suited to chopping the power to the inductor, an op amp is better suited to linear regulation. It looks like directly chopping the power supply to the load inductor isn't a viable option because of the low inductance, so if you wanted to do this with minimal parts and the easiest circuitry at the expense of efficiency, a linear solution with op-amp and transistor would probably be the way to go.Conceptually, there's not really a difference between low- and high-side current regulation, it's exactly the same topology just flipped upside down. In practice, low side is usually easier because it allows your control signal (and optional readback signals) to be ground referenced, it's very easy to combine arbitrary load supply and control signal voltage levels, and you get more options in N-channel (low-side) FETs than in P-channel (high-side). The downside to low-side is that your load is NOT ground referenced. You can compromise a bit by doing low-side sensing and high-side drive, if the sense resistor is small enough then the load might be close enough to ground referenced for some applications. FET vs BJT probably doesn't make a functional difference here, since the power is pretty low.Since you want to have this H-bridge between the constant current driver and the load, you'll need to go high side on the drive at least, because the bridge still needs to receive ground-referenced logic signals. If your sense resistor can be a low enough value it may still be fine to keep that on the low side of the bridge.QuoteA comparator will be fine with this, some op-amps take a bit of extra time to come out of saturation and you might need to be concerned about that depending on what your application can tolerate. There are also some op amps with very limited differential input voltage ratings, so you'd need to make sure you don't accidentally pick one of those.With a linear constant current driver you generally do NOT want to EVER connect the load while the driver is active. If the driver is set to deliver any amount of current while the load is disconnected, it will drive the transistor wide open attempting to get any current to flow at all, and connecting the load in that condition could give it a pretty big wallop before the loop recovers. This can be avoided with additional circuitry to detect the voltage at the load terminal and disable the driver, although this might not really matter in your application. At any rate, if you have the current setpoint and the bridge under MCU control, you can just make sure that you set the current to zero before switching the bridge around and avoid the whole problem.Assuming MCU control, I think I would be inclined to do something like the attached. The two half-bridges shown here could be two halves of the existing bridge IC you have, the one on the right is used strictly to set the polarity, the one on the left is driven by PWM and forms a buck converter along with LBuckand CBuck. The frequency of the buck stage doesn't really matter as long as the L and C values are chosen to suit, but higher frequency + lower L&C means faster loop response, but that only matters to the extent that your ADC can measure the load current fast enough. Depending on the resolution and response time you need and the MCU you're using, you might want to run the PWM at a relatively low resolution and dither it so that you can run at a higher frequency. Load current is measured as (VS1-VS2)/RSenseand fed back into the loop driving the PWM in software. Lots of MCUs these days have differential ADCs that could do that subtraction for you, but VS2can probably be assumed to change slowly enough that could measure it less frequently and subtract it in the software loop. Or you could skip measuring VS2entirely if you decide that the resistance of the bridge and any fluctuations in Vcc are negligible for your purposes.

author: lynaghk
author_rank: Contributor
timestamp: November 29, 2021, 08:04:36 pm
content: Quote from: Zero999 on November 29, 2021, 09:17:56 amYeah, I don't think chopping (modulating the h-bridge on/off) is going to work given the low inductance of the load and the ~1us comparator response and h-bridge switching time. (Much less the 15us microcontroller ADC sampling time.)The $0.10 SMD inductor I mentioned was just for ballpark, and they have max current ratings on the same order as my desired currents, so I'd need to make a little network of 'em.It's maybe doable, but I suspect linear current control may be both cheaper and give less ripple.ajb, thanks for your detailed thoughts! Responses inline:Quote from: ajb on November 29, 2021, 04:34:21 pmWhat's the mechanism behind your skepticism?That at low VM voltages the internal gate driver won't be able to open up the transistors?Quote from: ajb on November 29, 2021, 04:34:21 pmYep, that's what I'm thinking as well.I'll be duplicating this circuit a dozen times per board, so I'm hoping a cheap quad op-amp (LM324) driving BJTs will provide an inexpensive solution.Quote from: ajb on November 29, 2021, 04:34:21 pmYeah, a 1R sense between the h-bridge and ground would only raise it 500mV at my max current, which is well under the maximum allowed logic-low signal (0.3 * Vcc = 1.5V).Quote from: ajb on November 29, 2021, 04:34:21 pmThanks for the heads-up.The LM324 common mode max is Vcc - 1.5, so 3.5V in my application, which is fine since the sense would be low and the ADC output maxes at 3.3V anyway.More interesting is that 3.5V is the max high swing, which means that this amp wouldn't be able to "turn off" a high-side PNP by bringing its base up to 4.3V (Vcc - 0.7).If we use an NPN as a high side switch, then max current would be limited by the output voltage of the amp.I.e., with a 5R load and the sense resistor and h-bridge Rdson contributing another Ohm we have a max current of (3.5V max output - 0.7V NPN base-emitter drop) / 6 Ohm = 460 mA.Would I be asking for trouble using a high-side NPN BJT like this?Quote from: ajb on November 29, 2021, 04:34:21 pmNoted, this is great advice, thanks!Quote from: ajb on November 29, 2021, 04:34:21 pmThanks!I want to make sure I calculate and understand the op amp + transistor current topology first, and then would love to compare your design.(Which looks much better as it uses fewer components.)I appreciate all this discussion, this is the first time I've had to design circuits like this and it's very helpful to hear from more experienced folks!

author: asdf336
author_rank: Contributor
timestamp: November 30, 2021, 12:46:58 am
content: As pointed out your sample rate doesn’t need to correlate to inductance but your switching frequency should. Standard buck rule of thumb is about 40% ripple as determined by voltage, inductance and switching frequency. ADC sample rate can be slower (but yes sync it to the pwm).Added L could help but isn’t it a clue that your pcb traces have too little L to begin with?linear would be easier and better just less efficient. Still 0.5A at 5V is only 2.5W. I assume you could find power opamps in this range and use 2 to form a bridge driver (same concept as H bridge).

author: ajb
author_rank: Super Contributor
timestamp: November 30, 2021, 06:44:48 am
content: Quote from: lynaghk on November 29, 2021, 08:04:36 pmJust that it's unusual for something like that to be specified down to 0V, because what application requires operation of an H-bridge at such low voltages? If it's truly specified that way, then that's kinda neat, I just didn't go through the trouble of translating enough of the datasheet to check.If you're doing a bunch of these channels per unit, there's another option that may become worthwhile. If you can provide a bipolar power supply, then you can tie one end of each inductor to the midpoint (typically ground, but you could also use a split positive supply, in which case your midpoint would be Vcc/2), and drive the other end positive or negative without needing a full bridge to swap the polarity. You can use the same basic op-amp constant current driver idea, with a couple of changes. You'll need to add a second transistor to the output of the op-amp to form a half bridge, or optionally use a power op-amp that can provide enough current to drive the load directly. The current sense resistor will need to be on the fixed side of the load, and your current setpoint signal will now be positive for current in one direction and negative for current in the other direction, and you can transition from one polarity to the other as smoothly as you like.If you only had one of these channels then it likely wouldn't be worth the trouble of providing the required power supply to do this (if you don't already have it), but with a dozen or so channels it starts to make more sense. You can also apply the same basic idea to the circuit I showed above, just eliminating the half bridge on the right side.

author: Zero999
author_rank: Super Contributor
timestamp: November 30, 2021, 12:22:56 pm
content: Quote from: lynaghk on November 29, 2021, 08:04:36 pmDoes this have a bipolar, or single power supply?One way to do this is with a Howland current pump, which can be made to work with either a single, or dual power supply. See links below:https://www.ti.com/lit/an/snoa474a/snoa474a.pdfhttps://www.eevblog.com/forum/projects/high-voltage-safety-and-design-considerations/https://www.eevblog.com/forum/projects/need-help-with-bi-directional-constant-current-source-(100ma)/https://www.eevblog.com/forum/projects/30a-precision-current-source/The pain old op-amp + pass transistor can also be used, but it needs a dual supply, to get positive, as well as negative currents. If you only have a single supply, a rail splitter could be used, or an H-bridge connected to the output, to change the polarity of the current.https://e2e.ti.com/blogs_/b/powerhouse/posts/how-to-generate-current-sources-and-sinks-of-arbitrary-magnitudehttps://electronics.stackexchange.com/questions/129609/how-does-this-constant-current-sink-actually-work

author: lynaghk
author_rank: Contributor
timestamp: December 01, 2021, 01:31:23 am
content: Here's what I've got for the linear current + h-bridge topology:+ P-MOSFET selected because it can dissipate 1.5W+ LM324 output only goes up to 3.5V, so I'm pulling up with a resistor so P-MOSFET can be closed; will this bother the amp?+ RC low-pass filter to smooth 3.3V PWM control signal from MCU.+ 3 Ohm sense resistor network so amp can better detect low current signalsTotal cost is about $0.40 per channel, 1 PWM pin (current), 1 GPIO (direction).amp datasheet:https://datasheet.lcsc.com/lcsc/1809051220_STMicroelectronics-LM324DT_C71035.pdfMOSFET datasheet:https://datasheet.lcsc.com/lcsc/1810171817_Alpha-&-Omega-Semicon-AO3401A_C15127.pdfThis would all be running from a 5V single-sided supply.The Howland pump is interesting, but seem like it might get complex / expensive for 100mA--500mA currents.I'd also need to up my analog noise / SPICE modeling skills significantly =DThe bipolar supply idea is also quite interesting.Say it's +/- 5V and have an op amp powered by these rails.How would I generate the control signal if the microcontroller PWM is always between 0--3.3V?

author: Zero999
author_rank: Super Contributor
timestamp: December 01, 2021, 09:07:01 am
content: Quote from: lynaghk on December 01, 2021, 01:31:23 amThat will most likely oscillate and be very difficult to stablise, because the feedback is taken from the drain. If you use the LM324, which won't work with its inputs close to the positive rail, it must be an N-channel MOSFET/BJT with the feedback taken from the source/emitter.Ignore my bipolar comment. The circuit I posted, will only either work as a sink, or source. It can't do both, even with a bipolar supply.How many channels do you need?

author: Terry Bites
author_rank: Super Contributor
timestamp: December 01, 2021, 12:36:35 pm
content: Here's high current high speed bipolar CCS 2A/V dont forget the heatsinks!

author: Zero999
author_rank: Super Contributor
timestamp: December 01, 2021, 01:26:21 pm
content: Quote from: Terry Bites on December 01, 2021, 12:36:35 pmThat's a good idea: make a Howland current pump from an instrumentation amplifier.I strongly recommend adding some emitter resistors, otherwise during power-on, C1 will rapidly charge, causing a large current to flow through X2 & X3, which might damage them.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: December 01, 2021, 06:27:28 pm
content: Uhhh... that cap probably makes the thing unstable anyway, or something. If you must have stable voltage at the op-amp pins, do a bootstrap supply with cascodes, zeners to the bases, and bypass it there (or better yet don't, because emitters don't appreciate bypass caps either -- and they should have low enough impedance to satisfy the amp already). Otherwise -- particularly if it has adequate CMRR from the supply pins -- it should be fine strung between nodes, for the same reason.Other than that, yeah, the general form is a traditional flying/floating/bootstrapped op-amp with power stage driven through its power pins. Also mind thermal stability, such circuits (complementary open-collector mirrors or whatever) tend to run away easily.Tim

author: lynaghk
author_rank: Contributor
timestamp: December 01, 2021, 07:22:05 pm
content: Quote from: Zero999 on December 01, 2021, 09:07:01 amHmm, I was following ajb's suggestion from earlier to do a high-side switch.I don't think an N-channel won't work because when larger currents are flowing the load will have a 5+ Ohms and the LM324 won't be able to keep the N-channel's gate voltage high enough to stay open.Situation would be worse for a BJT.Re: oscillation, it's not obvious to me where the phase offsets are being introduced in my circuit, much less how to calculate them.Conceptually, is the issue the capacitance of the mosfet gate?(I found this long explanation which I'll study later; open to any suggestions for reading material on this:https://electronics.stackexchange.com/questions/358605/gain-of-opamp-circuit-with-current-output)I have a few hesitations about the Howland solution:1. I don't have a split supply, so would need to (learn how to) design one2. I'm not sure how to shift a 0-3.3V PWM control signal to one centered at 0V3. an instrumentation amplifier plus BJTs sufficient to source/sink 500mA of current per channel seems like it'll get expensiveIf the op amp + mosfet linear regulation solution isn't workable, my inclination would be to try ajb's buck topology idea.For that I just need to find a surface mount inductor capable of handling 500mA.And learn how to do all of the calculations, of course =D

author: Zero999
author_rank: Super Contributor
timestamp: December 01, 2021, 10:54:49 pm
content: Quote from: lynaghk on December 01, 2021, 07:22:05 pmIt depends on the gate threshold of the MOSFET.QuoteWhy do you think that it would be worse for a BJT? On the contrary, a BJT would be better, as it turns on at only 0.7V, rather than a few volts for a MOSFET. The only issue is the base current might be too much for an LM324 to drive, but a Darlington pair would fix that.QuoteIf the feedback is taken from the emitter of a BJT, in the circuit I posted, there's no extra voltage gain. The inverting input of the op-amp sits a base-emitter voltage drop below the op-amp's output. If the feedback is taken from the collector, or drain, the feedback voltage will change a lot, for a tiny change in the op-amp's output. The op-amp is not designed to be stable, with an extra gain stage in the loop. The op-amp will be designed so its gain is below 1, when the phase shift exceeds 180o, to prevent oscillation and adding an extra gain stage within the loop, boosts the gain, causing it to oscillate.Quote1) It can be bridged.2) No problem. Filter it to an analogue signal of 0V to 3.3V and connect the negative input of the Howland pump to half 3.3V.3) It depends on your budget. I doubt an instrumentation amplifier IC would cost that much more than the current sense amplifier IC you're using.

author: lynaghk
author_rank: Contributor
timestamp: December 02, 2021, 01:48:22 am
content: Thanks a ton Zero999!You're right about the BJT, I was thinking about the voltage drop but forgot that the same applies to the MOSFET and its threshold is larger.What you said about op-amp feedback makes a ton of sense as well --- try and keep extra gain out of the feedback loop when possible.Presumably the less gain overall, the less gain above unity at 180 degree phase, so no oscillation.Thanks for walking through that example with the circuit you posted earlier.Driving a darlington pair, hmm.With two darlington diode drops we'd have a max voltage at the emitter of 3.5 V - 1.2 V = 2.3 V, which with a 6 Ohm load resistance means current would limited to about 400 mA.Hard to beat on price, though, 7 channel darlington array for $0.20, much cheaper than a MOSFET.Re: Howland, an instrumentation amp per channel would be much more expensive than the 1/4 of a $0.13 quad LM324.Of course, all this is probably more expensive than ajb's inductor + PWM solution, still thinking about that one...

author: Zero999
author_rank: Super Contributor
timestamp: December 02, 2021, 10:40:30 am
content: Quote from: lynaghk on December 02, 2021, 01:48:22 amLooking back at the circuit, there's another error: the op-amp inputs are the wrong way round. The MOSFET is in common source configuration, meaning that it's an inverting amplifier, so as the op-amp's output voltage drops, the voltage on U1 increases, causing the functions of the op-amp's inverting and non-inverting inputs to reverse.https://www.eevblog.com/forum/projects/adjustable-500ma-bipolar-current-control-for-pcb-trace-electromagnet/msg3846563/#msg3846563QuoteYou didn't say how many channels you needed. A Darlington array can't be used for more than one channel, because the emitters are commoned. You could use one Darlington array for the two transistors on lower side of the H-bridge, with the bases connected to diodes on the op-amp's output, to implement current limiting. You also need to check the power dissipation. If you opt for an array, it would be advisable to connect several channels together, to spread the power dissipation.QuoteUsing a switched mode configuration is definitely a good idea. I will save power and won't generate so much heat.

author: Terry Bites
author_rank: Super Contributor
timestamp: December 02, 2021, 10:51:36 am
content: I have used it with out stability issues being apparent.

author: lynaghk
author_rank: Contributor
timestamp: December 02, 2021, 06:12:10 pm
content: Good catch on the Darlington array, I was looking only at the individual unit schematic and didn't realize the array connected both the COM *and* the emitter E terminals of all the units in the array.I read up more on LC and buck circuits yesterday so will have a go at PWM modulation for that approach, will post a schematic here later with a SPICE simulation, assuming I can figure out one of the free packages (LTSpice or Micro Cap).

author: lynaghk
author_rank: Contributor
timestamp: December 03, 2021, 04:59:20 am
content: Turns out Micro-Cap is pretty cool. I managed to cook up a simulation of ajb's buck bridge idea.I modeled the h-bridge IC using an IRF9540 and IRF540 (picked arbitrarily from the extensive catalog in Micro-Cap) and am driving with a 250kHz PWM signal as per the IC's recommended max.PWM will be driven by a 16-bit counter on an STM32 running at 84 MHz.Maybe timers are limited to 42 MHz?Can't recall, but either way I'll have sufficient resolution for the PWM duty cycle for a 250kHz signal.The chart shows multiple PWM duty cycles with the current (red) and corresponding 12-bit ADC reading to be expected.With the 3 Ohm sense resistor I'm only using about half of the ADC's dynamic range, but I'd rather lose small-current resolution in favor of making sure I can get up to the 500mA max current in the event that the PCB traces get manufactured with a few extra Ohm of resistance.I chose the 4.7uF and 100uH values arbitrarily.Aside from making sure the SMD inductor can handle 500mA of current, anything else I should take a look at here when selecting components?

author: Zero999
author_rank: Super Contributor
timestamp: December 03, 2021, 10:54:31 am
content: Quote from: lynaghk on December 03, 2021, 04:59:20 amThe inductor should be before the capacitors, not after. As drawn, the capacitors will discharge high current spikes into the MOSFETs, resulting in high power dissipation.Driving MOSFETs like that is a bad idea, due to cross-conduction, although you'll probably get away with it, as the supply voltage is below the sum of the threshold voltages. Yes, I know it's just for the purposes of the simulation, but I thought I'd point it out anyway.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: December 03, 2021, 07:05:04 pm
content: I'm rather more concerned with how it was supposed to work at all... at first I thought they were wired as complementary source follower, which sucks because of the high drive voltage required (and V2 isn't labeled so who the heck knows what's going into it here), but come to think of it the P and N are on top and bottom so depending on which way the P is oriented (the symbol is conveniently missing the substrate connection so it's impossible to tell D/S apart), it's either a PMOS working into a diode, or two whole-ass diodes in series shorting out the supply.To be clear: the simulator doesn't make any assumptions, or efforts towards realism (besides certain gimmicks in rare cases), the model is entirely up to you. An ideal voltage source will not click off when you short it, nor will components emit magic smoke when you overpower them. You must check yourself, whether currents are realistic, power dissipation is within limits, etc.What you should have, is a CMOS inverter: N source to GND, P source to +V, gates tied, drains tied. With the transistors and supply voltage shown, this won't be too bad, but will need somewhat higher drive voltage (say +8/-3V) to perform properly.The caution about shoot-through occurs when the gate voltages are intermediate. For these transistors, it won't be much, because they are barely on at 2-3V, but, doing this with representative types that you'd use in new design, you'll most likely have logic-level types that are barely on at merely 1V, and strongly conducting by 2-3V. So over the 1-4V range of gate voltage, you have a problem. As the gate voltage swings through that range, in the whatever 10s of nanoseconds it takes, huge supply currents will be drawn (maybe 10A+, depends on type and etc.).And yeah the capacitors are just wrong. You probably get a simulation result because the transistors are never fully switching as such, just slightly charging/discharging the capacitors -- at great expense to power dissipation.The preferred way is to use the inductor as its own filter, or if that's not possible (again, because of the short L/R time constant), then it can be pre-filtered with an LC stage, and then the LR load connected.(There is, by the way, a way to use transistors to directly drive capacitors, at high efficiency; but it requires inductors in the supply side instead, and is generally harder to build and operate. I wouldn't recommend.)Tim

author: lynaghk
author_rank: Contributor
timestamp: December 03, 2021, 08:04:17 pm
content: Everything y'all said about the MOSFETs makes sense: adjacent caps will source current during switching (=> power losses), shoot-through possible, and Micro-Cap's symbol is frustratingly ambiguous about source/drain distinction.Unfortunately Micro-Cap doesn't ship with a tuned SPICE model of my cheapo H-bridge driver IC, so what's the alternative?Maybe I should just use an ideal voltage source of my PWM input signal (see attached); after all, the goal of the simulation is to help me choose values of C and L for my application to work.The IC promises 1us switching times, so perhaps as long as my current flow settles in ~500us in the simulation, I can ignore the 1us-level timing details?From this perspective, using 1uF caps with a 100u inductor looks like the right ballpark.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: December 03, 2021, 10:13:48 pm
content: 1. The switching waveform isn't particularly important to the simulation. If you're just plotting Vout(time), then the bridge is just a modulator with some gain, and the HF ripple it also generates is mostly irrelevant, or easily modeled based on a squarish wave.So, use a PULSE source with some modest edge rate -- apparently around 0.5us.Or don't bother at all and just look at the step response of the filter.The key insight is that, if you're largely looking at the transient response of the filter, then ripple and its response are simply a matter of superposition: the system is linear and we can simply look at the step response plus the ripple response (if we care at all, say because the output ripple voltage is small enough to ignore).2. Model it as some reasonable approximation. Like a pair of transistors. But now you need a drive circuit too, likely with some staggered timing to avoid shoot-through. There may be slew rate control as well, hence why the output rise/fall time is so long. Or maybe they lie about the rise time and it's actually a lot faster or slower. And, it will generally depend on load current as well, so who knows what effect that has.This is reasonable if you need to know the dynamics of the switching event (commutation) itself. This concerns the inductance of the supply (the loop from +V to half bridge to GND), device capacitance, and any little things you have hanging off the output (usually something like R+C or diode snubbers, if any -- which is not unlike what you had before, just MUCH smaller values!). And for this, just a few hundred nanoseconds of simulated time might suffice, modeling the output filter inductor as a constant current sink, because its current will change little during such a short time frame, meanwhile the load current at the moment of switching may be all over the place, it depends on PWM over long time scales -- it's just an initial condition at these up-close scales.The time constants are diagnostic. For the switching loop, you have the 100s pF of device capacitance, 10s nH of loop inductance (and ~uF of supply bypass closing the loop, which just acts like a short circuit for such time scales -- can use the AC equivalent circuit), and whatever things of similar value are attached (i.e., snubbers on the order of 100s pF, and R ~ sqrt(10nH/100pF), would be expected). In contrast, the filter has much longer, 10s or 100s of us time constants (10s uH + ~uF), again, essentially stationary to the switching event, and conversely the switching events are essentially irrelevant to the filter response.Tim

author: artag
author_rank: Super Contributor
timestamp: December 03, 2021, 11:55:42 pm
content: You might be interested in this guy's work :

author: lynaghk
author_rank: Contributor
timestamp: December 25, 2021, 12:58:53 am
content: Just to follow up, I had a PCB made and was able to successfully use it as a linear motor to drive around 1mm disk magnets (see attached photo).Background research / theory and initial measurement notes:https://kevinlynagh.com/pcb-stepper/One interesting finding is that trying to switch the H-bridges anywhere close to 250 kHz greatly limits the current output.Presumably the switching losses that I neglected to model in Micro-Cap are not, in reality, negligible. =D