controlling 56 outputs

Thread Starter


Joined Mar 17, 2007
I'm thinking of building a silly little thing, but I need to control 56 small electromagnets from a PIC18F4550.

I need to vary the power to the magnets as well, and they need individual control.

Any thoughts about how to do this?




Joined Apr 20, 2004
You need to be able to address each magnet individually. Each magnet will need a register to hold the value relating to intensity of the magnet's field, and also some means of turning that value into current through the magent coils.

Thread Starter


Joined Mar 17, 2007
that about sums it up.

On another forum, someone suggesting usign a series of 74HC595s, but that's pure digital.



Joined Sep 20, 2005
You could use something I would call binary controlled PWM.

thought A: for one channel, you could use series of pulses, average the voltage by low pass filter, and send it to PWM or just use the voltage created for controlling the current through the magnets. For example for 0.125*maxpower resolution, sending 0000 0001 would create 1/8 of maximal power, 0000 0011 1/4 and so on.

thought B: now you use a demultiplexer 1 of 64 and an enable signal. The pic would cycle through the 56 addreses and send also the enable signal when there is a 1 in on that position for the decoder. So sending one data block to each magnet would take 8*86=512 clock cycles. You would also need to amplify the singnal of the decoder by 56 to get the same voltage like in thought A.

And that´s what I worked out after coming form a pub :)


Joined May 16, 2005
If you use seven each of the 74HC595s, you could drive 56 mosfets with their outputs. Minimum pulse width would be 1/56 of the shift rate.


Joined Jan 17, 2007
If you can use linear voltage to control the magnets (instead of PWM), you could use a little fleet of multi-channel DACs (I, personally, would choose the ones that interface to the PIC via I2C).

Thread Starter


Joined Mar 17, 2007
I looked into the I2C idea, and a quad DAC runs about $6, so for a prototype I don't care about the price, but for reproduction, I think it's overkill. Even at high QTY, the DACs would run over $40 for 14 of them.

What about using a 1 wire network?


Joined Apr 19, 2007
Have you looked into multi processing? at 32I/O lines and PWM you could forget multiplexing your IO lines to get the results you need.


Joined Feb 24, 2006
I suppose 56 PICs, or one per electromagnet would be out of the question. I guess you'd need the original one to control all the slave devices


Joined Apr 19, 2007
How about analog multiplexing, using op-amps (LM324's) to sample and hold and using CD4067's, 16 chan demultiplexers to select and refresh them.
All you need send from the PIC is a count of 0 to n to address the 4067's, and a new analog voltage on each new count to sample.
You can then hold the level required for each magenet in memory, and just refesh the whole lot with a subroutine within the program.

After the op-amp, just use a simple emiter follower to drive each magenet.
It sounds complicated, but that's how I send 256 lighting channels from my lighting desk to the stage (down a ballanced mic cable).
Ah!!! before enyone says it... Yes it is faster and more reliable than DMX !!!
and has been running now for 9 years. every day....

4 x 4067's, 1 x 4028, some inverters, 16 x LM324's, 1 transistor per output and some cap's. will give you up to 64 channels..

Mmm... sounds like a lot of work, but when you think about it, If you are doing it on 1 PCB, it is all repeated. So after one channel is designed it is just copying.
If you can do it in surface mount, it would be quite compact..

If you need an idea for a schematic... let me know.

Hope this helps.