I'm looking to be able to individually control each electromagnet in a 16x16 matrix. It's also important to note that I want to control these via an Arduino and maybe eventually a Raspberry pi - depending on the future requirements and environment I want to work in with my project. Both however, limit me pin wise.

To get around my lack of infinite pins, I was looking into multiplexing, but I'm not sure how I'd go about it completely for 16 columns and 16 rows. However, I'm also honestly not 100% sure that multiplexing with electromagnets is an ideal solution because I'm not sure how much that will effect how strong the magnet works, due to it turning off and on repeatedly. I'd assume I might only get ~6.25% potential output from the electromagnets due to multiplexing, but that's assuming electromagnets work well in a multiplexing environment - for all I know they need some "warm up" time - but again, I'm not a real electrical engineer lol. I imagine since electricity is flowing through the electromagnet I should expect the electromagnet to turn on/off almost as instantly as an LED.

The electromagnets I have on hand are ZYE1-P20/15's. 12V DC, 3W, 0.25A.

So, if you think multiplexing might work, could I get any good recommendations on what driver I could use to multiplex for a 16x16 matrix? Any tips and advice would also be welcome.

If you don't think multiplexing is a good idea, what other options are there?

  • 2
    \$\begingroup\$ Will only one electromagnet be on at a time, or can any number be on at a time? \$\endgroup\$
    – Mattman944
    Commented Feb 4, 2020 at 14:47
  • \$\begingroup\$ I'm looking to have the ability to have any number of them on at a time, or at least, seemingly. \$\endgroup\$ Commented Feb 4, 2020 at 14:51
  • 1
    \$\begingroup\$ Then you need 16*16 drivers. You can multiplex access to them, if each has 1 bit of storage (e.g. a 256 bit shift register, with each bit driving one magnet via a power transistor) \$\endgroup\$
    – user16324
    Commented Feb 4, 2020 at 15:00
  • \$\begingroup\$ What's the power consumption of these magnets, 100mW each, 100W each? What's that in volts and amps? \$\endgroup\$
    – Neil_UK
    Commented Feb 4, 2020 at 16:20

1 Answer 1


You have two options. Power multiplexing - where you have an array of magnets and you pulse the power into them, or Control multiplexing - where you have an array of magnet driver devices, and you distribute the logic level control to them.

Power Multiplexing

It is theoretically possible to do power multiplexing with electromagnets. If you supply one electromagnet with 16x the rated voltage for 1/16th of the total time, and provide a free-wheel path round it with a diode, it will operate at more or less the same current as giving it the rated voltage for the whole time.

A 16x16 array can therefore be multiplexed driving a whole row at a time, each column for 1/16th of the time, with the PSU supplying 16x the voltage and 16x the current as for a single magnet.

That makes a number of assumptions about the magnets (a) the insulation will take the extra voltage (b) you are multiplexing fast enough to get a current smooth enough for your application.

The magnets will not turn on and off as fast as a LED, if fact your 'warm-up time' is closer to the mark. While the voltage is on, the current in the coil will increase rapidly. While the other columns are being driven, current continues to flow through the free-wheel diode, decaying slowly due to the voltage drop in diode and the coil resistance. The time taken to bring the current up, and to decay away, depends on the supply voltage, the inductance, and the resistance of the coils.

A big argument against multiplexing 16x the voltage to an array is what happens if when the software crashes and a column of magnets receives a continuous 16x voltage supply. Fuses or current limiting is needed, and/or a multiplex failure shutdown of the supply.

As you say in your OP that you are at best dangerous, building a 4A 192v system with some built-in failure modes is probably not the best way to go.

Control Multiplexing

The alternative control multiplexing would be far safer. The standard way that people expand their arduino or pi outputs is to use a string of HC595s, in your case 32, as they have 8 outputs each. They require 3 pins from the MCU to drive them, clock, data and a strobe. You can get standard software libraries for pi and 'duino that will handle this array for you.

One option for magnet driving is to use the ULN2803, an 8 channel darlington driver, capable of 30v and 500mA per channel, with built-in kickback diodes. However, package dissipation would limit each one to driving only four channels at the same time, so it's not necessarily a good choice.

If you use FETs for driving, and want to connect them directly to the 595 outputs, then make sure that they are 'logic level' input types. This means not only Vgsth << 5v, but also an RDSon specified at Vgs of 5v or less.

A large series gate resistor should slow down the turn-off transient through the Miller effect sufficiently to avoid the need for a kickback diode (as long as you do the calculations and measurement) though such diodes are only pennies, so would be sensible to include anyway.

While buying 256 single FETs seems like a lot, you'd get quantity pricing, and you already have 256 magnets, so are handling the scale somehow. You might want to design an interface board that handles (say) 2x HC595 and 16x FETs, gate resistors and kickback diodes, as a module, to simplify your integration and wiring. I usually use DirtyPCB for things like this, but plenty of other cheap, online, PCB suppliers are available. Having multiple small boards eases things like power distribution (a 4A wire to each board), and repairs (build a few extra boards, and swap one if needed), and bringup (just build one board, get it working, add another, rinse and repeat).

  • \$\begingroup\$ The OP hinted that he will need help with the driver circuit. \$\endgroup\$
    – Mattman944
    Commented Feb 4, 2020 at 15:12
  • \$\begingroup\$ Well the answerer might need help with the details of what is to be driven. \$\endgroup\$
    – Neil_UK
    Commented Feb 4, 2020 at 16:17
  • \$\begingroup\$ The electromagnets I have on hand are ZYE1-P20/15's. 12V DC, 3W, 0.25A. The thread size is also labelled as M3 if that helps. That's an interesting idea to supply 16x the voltage and 16x the current.. But yeah, any help selecting the driver and any supplies would be much appreciated. Or if you know of any videos that may help me figure it out more for myself would also be great! I get hesitant watching videos on multiplexing with LED's because I feel like I need to do something different with these magnets. \$\endgroup\$ Commented Feb 4, 2020 at 17:35
  • \$\begingroup\$ flinging 192v around might be a bit exciting, especially if you're dangerous at best, however you only need 32 high voltage drivers. It may be easier to go for 256 cheap and easy low voltage drivers, and multiplex the controls. The easiest way to get 256 bits controlled by a 'duino or pi is to use 32 off HC595 shift registers. Each output controls a low cost FET or darlington driver. Depending on how many magnets may be energised at the same time, you might be able to group drivers into 8s, using ULN2803, but thermals mean they'd only drive 4 out of 8 at a time. \$\endgroup\$
    – Neil_UK
    Commented Feb 4, 2020 at 18:01
  • 2
    \$\begingroup\$ There is no rule that you need to use a 16 x 16 electrical matrix, you could use a 32 x 8 electrical matrix to keep the duty cycle and voltage reasonable. \$\endgroup\$
    – Mattman944
    Commented Feb 4, 2020 at 21:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.