Author Topic: Controlling 20 electromagnets with Arduino, best practices?  (Read 11564 times)

0 Members and 1 Guest are viewing this topic.

Offline CranberryTopic starter

  • Contributor
  • Posts: 18
Controlling 20 electromagnets with Arduino, best practices?
« on: December 24, 2015, 06:35:58 pm »
Hey everyone,

I am making this project that uses a bunch of electromagnets, pretty much close to this project here with 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.
« Last Edit: December 25, 2015, 02:21:35 am by Cranberry »
 

Offline Aodhan145

  • Frequent Contributor
  • **
  • Posts: 403
  • Country: 00
Re: Controlling 20 electromagnets with Arduino, best practices?
« Reply #1 on: December 24, 2015, 08:28:15 pm »
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.
 

Offline CranberryTopic starter

  • Contributor
  • Posts: 18
Re: Controlling 20 electromagnets with Arduino, best practices?
« Reply #2 on: December 25, 2015, 12:37:37 am »
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.
Could 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 on this schematic I found but it caused my transistor to overheat.
« Last Edit: December 25, 2015, 02:23:01 am by Cranberry »
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12855
Re: Controlling 20 electromagnets with Arduino, best practices?
« Reply #3 on: December 25, 2015, 01:01:52 am »
What's the DC resistance of your electromagnets?
 

Offline CranberryTopic starter

  • Contributor
  • Posts: 18
Re: Controlling 20 electromagnets with Arduino, best practices?
« Reply #4 on: December 25, 2015, 01:13:25 am »
What's the DC resistance of your electromagnets?
Really low, about ~56 Ohms.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12855
Re: Controlling 20 electromagnets with Arduino, best practices?
« Reply #5 on: December 25, 2015, 01:26:53 am »
That's about 215mA when powered from 12V.  If you don't need to reverse polarity consider using some TPIC6A595 chips.  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.
« Last Edit: December 25, 2015, 02:07:12 am by Ian.M »
 

Offline Richard Crowley

  • Super Contributor
  • ***
  • Posts: 4317
  • Country: us
  • KJ7YLK
Re: Controlling 20 electromagnets with Arduino, best practices?
« Reply #6 on: December 25, 2015, 01:55:12 am »
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.
« Last Edit: December 25, 2015, 01:56:53 am by Richard Crowley »
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12855
Re: Controlling 20 electromagnets with Arduino, best practices?
« Reply #7 on: December 25, 2015, 02:11:59 am »
 

Offline CranberryTopic starter

  • Contributor
  • Posts: 18
Re: Controlling 20 electromagnets with Arduino, best practices?
« Reply #8 on: December 28, 2015, 07:12:15 am »
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 project http://www.e-alexander.net/magic_slippers.php where 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.
« Last Edit: December 28, 2015, 02:58:39 pm by Cranberry »
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12855
Re: Controlling 20 electromagnets with Arduino, best practices?
« Reply #9 on: December 28, 2015, 07:54:03 am »
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.
 

Offline CranberryTopic starter

  • Contributor
  • Posts: 18
Re: Controlling 20 electromagnets with Arduino, best practices?
« Reply #10 on: December 28, 2015, 02:57:56 pm »
@Ian.M: Typo on my end. I re-measured it. They range from 10 Ohms to 5.6 Ohms.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12855
Re: Controlling 20 electromagnets with Arduino, best practices?
« Reply #11 on: December 28, 2015, 04:38:31 pm »
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.   
 

Offline CranberryTopic starter

  • Contributor
  • Posts: 18
Re: Controlling 20 electromagnets with Arduino, best practices?
« Reply #12 on: December 28, 2015, 07:47:24 pm »
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.htm I heard that there are some faulty schematics out there and when I tried a BJT H-Bridge one of my transistors overheated.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12855
Re: Controlling 20 electromagnets with Arduino, best practices?
« Reply #13 on: December 28, 2015, 10:35:41 pm »
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.
 

Offline CranberryTopic starter

  • Contributor
  • Posts: 18
Re: Controlling 20 electromagnets with Arduino, best practices?
« Reply #14 on: December 29, 2015, 02:15:23 am »
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.

It 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 to not go 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.
« Last Edit: December 29, 2015, 02:23:24 am by Cranberry »
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12855
Re: Controlling 20 electromagnets with Arduino, best practices?
« Reply #15 on: December 29, 2015, 04:36:18 am »
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.

Anyway, on the assumption that all the coils are of similar resistance value, what would differ? I plan to make them closer in size.

If 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.
 

Offline Richard Crowley

  • Super Contributor
  • ***
  • Posts: 4317
  • Country: us
  • KJ7YLK
Re: Controlling 20 electromagnets with Arduino, best practices?
« Reply #16 on: December 29, 2015, 05:30:32 am »
Take a look at this.  Rather a sophisticated current-controlled driver chip for a very low price...

http://www.bgmicro.com/ICSL294.aspx
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12855
Re: Controlling 20 electromagnets with Arduino, best practices?
« Reply #17 on: December 29, 2015, 05:58:23 am »
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.
« Last Edit: December 30, 2015, 06:05:23 am by Ian.M »
 

Offline CranberryTopic starter

  • Contributor
  • Posts: 18
Re: Controlling 20 electromagnets with Arduino, best practices?
« Reply #18 on: December 30, 2015, 05:44:02 am »
You can easily find H-bridge driver ICs but must then add external MOSFETS.
I'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.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12855
Re: Controlling 20 electromagnets with Arduino, best practices?
« Reply #19 on: December 30, 2015, 06:29:53 am »
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.

So I gather for this I would need (using an h-bridge driver IC + heatsinks) a switching regulator and shift register IC, at least.

Yes.  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.

 

Offline Richard Crowley

  • Super Contributor
  • ***
  • Posts: 4317
  • Country: us
  • KJ7YLK
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf