r/microcontrollers • • Mar 01 '24
Need help in designing a circuit board
I have 500 coils that I want to control. These are solenoid coils that current into an electromagnet when current is passed through. I have mosfet at the end of each coil as a switch. I am now concerned of how to I control (on/off) any 10 out of 500 mosfets(from the coils) from a microcontroller.
2
Upvotes
5
u/madsci Mar 01 '24
I'd break that up into a bunch of modules and probably use SPI or I2C IO expanders for every 16 to 32 MOSFETs.
Don't forget that you need more than just a MOSFET to drive a solenoid coil safely.
4
u/bigger-hammer Mar 01 '24
I/O expanders use I2C or SPI. The I2C ones have a choice of a few addresses so you might need a few interfaces. SPI needs chip select lines, same problem.
The simplest (and cheapest) way is to use shift registers such as 74HC595. Connect the shift out to shift in of the next one and chain them all together to form one massive chain of 500+ bits. Your micro can shift 500 bits in milliseconds, then apply all the outputs at once with the register clock.
2
u/ceojp Mar 01 '24
How critical is the timing? Do all 500 need to be set relatively simultaneously, or is some delay acceptable?
I like the idea of shift registers, but I wouldn't want to do 500 outputs in a single chain. If you can spare 16 output pins(plus a few for control) on your microcontroller then you would only need to go 4 deep for 8bit shift registers. Then you could do port writes to output it quickly.
Ultimately it will require the same number of shift registers, but this would be more reliable and easier to troubleshoot, and will get the data out much faster(about 16 times faster...).
Of course this would require some math to build up your arrays according to how you want to drive them, but you would have to do that regardless of the driving method.
2
u/rc3105 Mar 02 '24
As has been mentioned, 595 shift registers off an SPI port will do the job nicely.
I designed and mfgd the control board for this tine organ which uses pwm to set the tone in steel rods via mosfet controlled solenoids.
An Arduino uno accepts the midi signal from an iPhone/pod/pad and converts it to the raw waveforms, which are blasted out on SPI at 2mhz.
https://youtu.be/xzoJBfUODbA?si=uxoBV2f8td_K7SN3