« Drawings Online | Main | Test Bunny! »
May 21, 2006
How to drive a solenoid with a Mosfet
(or something...)
So not much time for this studio log lately - busy with open studios and then recovering from open studios... It was great and exhausting. Lots of good conversations and ideas spinning around. The "Drip Painter" was a big hit even though it wasn't completely functional. I've spent the last two weeks working on the programming and trying to get two microcontrollers to play nice together, talk to each other and to my Mac. Then my $200. power supply started to get moody- voltage drops from 12v to 6v. Like I have the patience for this? I have no idea what is going on with it.

Diagram from the Wiring project
I was able to get a working interactive version of the control application running: the drip painter following my mouse movements. Worked on the print head today - learned how to use a MOSFET to control a solenoid valve through the Wiring board. That board (and project) is pretty cool. It has two hardware serial ports so it can work as a serial router between the Mac and the stepper board I am using, along with controlling the solenoid printing head. I hadn't worked with it before and it has it's own programming language - so yet another learning curve. Lots of tech help from Hernando Barragán, Wiring's originator, along with Peter Norberg who makes the stepper board controller I am using.
This has all been (mostly) fun and a huge learning experience but I am at the point where I really want to start making art with this tech and not just develop new skills. Soon... I think the "Drip Painter" will get it's first work out this coming week. Meanwhile, I've done some tests with the drinking bird project and the LED stuff.
Classes have all ended (except for the grading) so another cycle of studio work is coming up. Sometimes there is incremental progress and sometimes lurching progress. I think I feel a lurch coming on. And hopefully more time for these rambings.
Oh - so how do you drive a solenoid with a MOSFET through the Wiring board? Well for a start...
To drive a solenoid with a pic and a Mosfet (n channel)
Connect the Source of the Mosfet to the Pic Vss or ground.
Connect the Drain of the Mosfet to the Solenoid
Connect the other terminal of the Solenoid to the proper V+ voltage
(It might be 5, 12, or 24 volts)(doesn't matter if it is
higher than pic Vcc)
Connect the gate of the Mosfet to any output pin of a pic.
When you drive the pin high, the solenoid turns on.
If you drive the Mosfet with a PWM, you will have proportional
action if you are using a proportional solenoid.
HTH
Steve Collins
Except this wasn't quite right. I had to connect both the Wiring ground and the 12v external ground to the Mosfet source. Go figure (sort of makes sense - and nothing blew up)
Nice to hear the pitter patter of little solenoids...
Posted by Roy at May 21, 2006 09:24 PM