Controlling 20 electromagnets with Arduino, best practices? - Page 1
Forum section: electronics / beginners

author: Cranberry
author_rank: Contributor
timestamp: December 24, 2015, 06:35:58 pm
content: Hey everyone,I am making this project that uses a bunch of electromagnets, pretty much close tothis project herewith the Arduino. I notice they use a TA7281P IC for this project. I've been using an L293d, which requires more input pins to the Arduino in order to control 2 motors (per chip). I wanted to know if I wanted to control 20 electromagnets, would using the same chip they've used be a better bet? Are there any better alternatives (ICs or circuit designs)?Also, one thing I wasn't sure about is how the current draw works for these ICs when hooking up 2 ICs (total of 4 electromagnets) or more. Based on the electromagnets I currently have, I need 0.5A each to visibly repel/attract a magnet. If someone could explain how I could maintain 0.5A to each electromagnet, I would appreciate it.I had hooked up two electromagnets to the L293d, another two to the sn754410 (because those were the only chips available to me) to a +12V power supply (Vs pin) and +5V to the Enable Pins and Vcc. I notice the L293d IC started making the electromagnets 'jitter' and almost no repel/attract. Should I be concerned about hooking up multiple of these ICs in parallel and the voltage supplied to them? I know the max for the L293d is 36V.

author: Aodhan145
author_rank: Frequent Contributor
timestamp: December 24, 2015, 08:28:15 pm
content: Whats wrong with a couple of shift registers and transistors? It would be simple enough including the code. It is a lot of connections though.

author: Cranberry
author_rank: Contributor
timestamp: December 25, 2015, 12:37:37 am
content: Quote from: Aodhan145 on December 24, 2015, 08:28:15 pmCould you explain (or direct me to a place that shows) what you mean exactly?I originally tried to make an h-bridge with transistors for this based onthis schematic I foundbut it caused my transistor to overheat.

author: Ian.M
author_rank: Super Contributor
timestamp: December 25, 2015, 01:01:52 am
content: What's the DC resistance of your electromagnets?

author: Cranberry
author_rank: Contributor
timestamp: December 25, 2015, 01:13:25 am
content: Quote from: Ian.M on December 25, 2015, 01:01:52 amReally low, about ~56 Ohms.

author: Ian.M
author_rank: Super Contributor
timestamp: December 25, 2015, 01:26:53 am
content: That's about 215mA when powered from 12V. If you don't need to reverse polarity consider using someTPIC6A595chips. They are 8 output shift registers with 350mA 50V MOSFET output stages. Daisy chain enough for all your electromagnets and interface to them by SPI.N.B. each output will need a diode to the 12V rail or to a snubbing rail above the 12V rail for back-EMF protection.

author: Richard Crowley
author_rank: Super Contributor
timestamp: December 25, 2015, 01:55:12 am
content: We don't know what you are trying to DO with your electromagnets?So it is almost impossible to recommend anything specific, or to evaluate your examples.You mentioned attract and repel, so are we to assume you need to apply opposite polarities?Is the thing you are trying to control "polarized" (like a permanent magnet)?Or is it "non-polar" (like a piece of iron, etc.)?Do you need simple on/off switching?Or do you need linear amplification (as through an audio amplifier)?We also don't know what the power supply voltage is for your coils?These are important design parameters.Without them, we are just shooting in the dark.And we probably can't offer very good suggestions.Also, none of your URL links work, so we don't know what you are referring to?Please learn how to quote URLs properly.

author: Ian.M
author_rank: Super Contributor
timestamp: December 25, 2015, 02:11:59 am
content: He has mentioned a 12V PSU. I agree we need far more info, and a general overview of the whole project and its aims would be helpful.Cranberry's links (fixed)http://www.instructables.com/id/How-to-Control-an-Electromagnet-with-an-Arduino/http://forum.allaboutcircuits.com/proxy.php?image=http%3A%2F%2Fplaywithrobots.com%2Fimages%2Fold%2Fh%2520bridge%2520transistor.jpg&hash=cc39c3c781df30bc9714ce9e3999620a

author: Cranberry
author_rank: Contributor
timestamp: December 28, 2015, 07:12:15 am
content: My mistake, I didn't realize the links were all mangled like that. They're fixed.I want to do something like what the author in the "How to Control an Electromagnet with an Arduino" did in his application projecthttp://www.e-alexander.net/magic_slippers.phpwhere he took a bunch of electromagnets (hand wound, air coil) + neodymium magnets to have the magnets attract/repel based on email data. So far I've been powering 4 electromagnets with a 12V DC supply, and the L293d and SN754410 paired with the Arduino like here:https://learn.adafruit.com/adafruit-arduino-lesson-15-dc-motor-reversing/lm293d(V_motor to +12V). I do need to have the option of attraction/repelling and no magnetism. I don't think I need linear amplification(?) but I do know that a single electromagnet coil can repel adequately at 0.5A, so the max current for each electromagnet should be that value. The resistance of each electromagnet is around 5.6-10 Ohms (correction). It is likely it will have the option of a toggle switch. Ideally, the electromagnets won't all be on at the same time, but if they are on, they would pulse in a pattern rather than steadily remain on. I hope that makes things clearer.

author: Ian.M
author_rank: Super Contributor
timestamp: December 28, 2015, 07:54:03 am
content: You are FUBARed.The article you linked to was using steel cored electromagnets wound with fine magnet wire. Yours are air core so the flux is far less concentrated and the attraction/repulsion is much weaker unless the magnet is a close sliding fit inside the coil.Now you tell us the electromagnets measure between 0.56 and 0.7 Ohms, which is two orders of magnitude less than you said earlier. A 0.56R load will pass 0.5A with only 0.28V across it, so you need a much lower supply voltage, load current sensing and PWM current control for the H-bridge to be able to do this without your H-bridge either shutting down if its overload protected, or burning out if it isn't.

author: Cranberry
author_rank: Contributor
timestamp: December 28, 2015, 02:57:56 pm
content: @Ian.M: Typo on my end. I re-measured it. They range from 10 Ohms to 5.6 Ohms.

author: Ian.M
author_rank: Super Contributor
timestamp: December 28, 2015, 04:38:31 pm
content: Why so much variation in DC resistance? Surely you wound them on the same size former with the same wire gauge and nuber of turns? If they are within 10% of each other, it will make driving them a lot easier.Depending on the voltage drop of your H-bridge, 10R would be workable with a supply voltage in the 5V to 8V region. A MOSFET H-bridge would be towards the low end of that range and a bipolar one towards the high end. Dont forget that the 0.5A current is per active coil, so if you ever need all 20 on at once you'd need a 10A supply.

author: Cranberry
author_rank: Contributor
timestamp: December 28, 2015, 07:47:24 pm
content: You're right. There is variation because for the time being the coils are of different sizes. I was trying them out at first to see which ones were the best but I figure out which size I will go with and will make more catered to that size. The wire gauge is the same, but the number of turns are not. Would it be better to power all of these with a bunch of those ICs? I haven't been sure about the practicality of using the H-Bridge ICs for so many electromagnets because of the cost per L293d or SN754410.To recap your advice I will need a 10A supply to power this for 20 with a supply voltage in the 5V~8V range. Do I need something to ensure that the current is maintained at 0.5A (plus minus some tolerance value)? If a MOSFET H-Bridge is more viable (and assuming paired with a shift register IC, regardless of MOSFET H-Bridge or IC H-Bridge), are all of the schematics on this page viable?http://www.bristolwatch.com/ele/h_bridge.htmI heard that there are some faulty schematics out there and when I tried a BJT H-Bridge one of my transistors overheated.

author: Ian.M
author_rank: Super Contributor
timestamp: December 28, 2015, 10:35:41 pm
content: You need to be able to adjust the supply rail to the H-Bridges to get 0.5A through the coils., That means either a really beefy switching regulator (buck converter) operating off your +12V rail, or split up the coils into groups by coil resistance and use a smaller switching regulator for each group. The alternative is to use a higher voltage and PWM each coil to maintain 0.5A, which needs a current sensor for each coil and a LOT of PWM outputs.I wouldn't touch the H-bridge circuits from that site with a barge pole. Anyone who thinks a CD4011 makes a good MOSFET H--bridge driver should be horse-whipped to encourage the others! Due to the very limited gate drive available, the H-bridges on that site will blow up if a heavy load is switched too often or if PWM is attempted. Any schematic that doesn't include a specialised gate driver IC for the MOSFETs is highly suspect. Due to the very high current spikes required by the gate drivers when the MOSFETs are switching, this isn't the sort of stuff you can build successfully on a breadboard or protoboard. If the layout isn't right, you will probably blow up chips and/or MOSFETs.

author: Cranberry
author_rank: Contributor
timestamp: December 29, 2015, 02:15:23 am
content: Quote from: Ian.M on December 28, 2015, 10:35:41 pmIt seems like it's hard to suss out good h-bridge schematics from bad ones. If there is a good schematic that you recommend, let me know. I found this:I'm assuming based on my project it's a better route tonotgo with the h-bridge ICs (L293d)? Are there any cons to using an h-bridge IC for this?Anyway, on the assumption that all the coils are of similar resistance value, what would differ? I plan to make them closer in size.

author: Ian.M
author_rank: Super Contributor
timestamp: December 29, 2015, 04:36:18 am
content: Bipolar H-bridge chips are common, relatively cheap and easy to use, but have far higher losses than MOSFET H-bridges so will require heatsinking. The trouble with MOSFET H-bridges is finding one! Integrated ICs tend to be intended for low voltage low power stuff like pager/cellphone vibration motor control, and are invariably in packages that are evil or impossible to hand solder. You can easily find H-bridge driver ICs but must then add external MOSFETS.The schematic you posted looks OK. However the bridge drivers *MUST*be proper MOSFET drivers, not some crappy 4000 series logic chip that cant supply enough gate current. There are also a lot of possible issues like dead-time and shoot-through that make a dedicated H-Bridge driver advisable, and prototyping it is going to be a beast as you don't have the experience and probably don't have the test equipment to develop something like this without filling a couple of 1lb jars with blown-up MOSFETs and burnt-out controller chips. This can be alleviated to some extent if the H-Bridge driver chip manufacturer has a development kit available that you can copy the PCB layout from, but if all you've got is loose components and datasheets, much trouble and smoke is certain.Unless you are going to production or need to minimise size/weight or power consumption and losses, I'd go with bipolar H-bridge chips on a large heatsink. It will be cheaper for a one-off and far easier to get going.Quote from: Cranberry on December 29, 2015, 02:15:23 amIf each coil has a significantly different resistance, as previously stated, you either need:* a PWM capable H-bridge for each with a sense resistor and a feedback loop to a PWM controller to set the current - which is moderately complex + you need to repeat the circuit 20 times,or you need to:* control the supply voltage to each individual H-bridge to set the current for its coil, so 20 H-briges + an adjustable switching regulator for each.If the resistance values are similar, you can supply all the H-bridges with the same voltage and the current will be determined by I=V/R, so if all R falls within a 10% range, so will all I. This is a great simplification as you now only need one switching regulator, albeit a heavy duty one.

author: Richard Crowley
author_rank: Super Contributor
timestamp: December 29, 2015, 05:30:32 am
content: Take a look at this. Rather a sophisticated current-controlled driver chip for a very low price...http://www.bgmicro.com/ICSL294.aspx

author: Ian.M
author_rank: Super Contributor
timestamp: December 29, 2015, 05:58:23 am
content: That would do it if you don't need to be able to reverse the solenoid current. However Cranberry apparently wants to be able to both attract and repel a magnet (+ an off state) for each.

author: Cranberry
author_rank: Contributor
timestamp: December 30, 2015, 05:44:02 am
content: Quote from: Ian.M on December 29, 2015, 04:36:18 amI've been doing them this way. Where do the external MOSFETS come in handy?So I gather for this I would need (using an h-bridge driver IC + heatsinks) a switching regulator and shift register IC, at least.

author: Ian.M
author_rank: Super Contributor
timestamp: December 30, 2015, 06:29:53 am
content: That's a complete bipolar H-bridge in one chip. Don't confuse it with a MOSFET driver for H-bridge applications, as although the driver can supply large currents to charge/discharge the MOSFET gates quickly, it cant supply them for very long without overheating as a MOSFET gate uses no power when it isn't switching.Quote from: Cranberry on December 30, 2015, 05:44:02 amYes. You can probably buy dual H-bridge modules off EBAY cheaper than you can build them, and the same goes for buck regulator modules. As the cheap EBAY buck regulators have limited current capability, you would need more than one, and split the h-bridge modules up into groups so as not to overload the buck regulators. You need 40 digital I/Os, and that bit is probably best built yourself using 74HC595 chips.

author: Richard Crowley
author_rank: Super Contributor
timestamp: December 30, 2015, 08:31:27 pm
content: Quote from: Cranberry on December 28, 2015, 07:47:24 pmL293D costs around 38 cents on Ebay which is 19 cents per coil. Is what what you mean by "practical cost"?http://www.ebay.com/itm/10Pcs-L293D-L293-Push-Pull-Four-Channel-Motor-Driver-IC-/140832908826http://www.ebay.com/itm/10PCS-Push-Pull-Four-Channel-Motor-Driver-IC-ST-DIP-16-L293D-/361426492817http://www.ebay.com/itm/10x-L293D-L293-Push-Pull-Four-Channel-Motor-Driver-IC-LJN-/181873916632http://www.ebay.com/itm/10PCS-L293D-L293-Push-Pull-Four-Channel-Motor-Driver-IC-DIP-16-NEW-/311173671055