Control solenoid via USB

icoris

n00b
Joined
Dec 12, 2003
Messages
11
I'm working on a project and I need some way to be able to simulate a finger pushing a button with a computer. I want to do this using a USB interface.

Sooo I'm trying to figure out how I'd do this. I'm thinking right now some sort of USB controller like these and wiring a solenoid to work with it. I'm not really sure how I'd do that though, my expertise would be with programming everything and getting it all to sync up. I have limited engineering experience, but I'm okay with that ;) .

Will these kinds of controllers work with a solenoid? How would I wire it? Is there a cheaper way to do this because these phidgets seem pretty simple for how much they're charging. For the solenoid, I'm thinking something like these, probably the 1350 or 1632. I'm thinking a solenoid rather than a servo because they SHOULD be easier to program (just on or off) and they're cheaper, I can get more force out of them, but also the speed is VERY important, even a high speed servo (which are quite expensive) can't compare to a solenoid and I need the time between when the instruction to fire is called to when the system on the button's side receives the input to be minimal.
 
Not sure about the capabilities of the USB Spec/API etc, but you could always just cut in/out the VCC/GND (0V/+5V). Otherwise, data signalling (NRZI) over D+/D- to the servo using libusb or something.
 
Not sure about the capabilities of the USB Spec/API etc, but you could always just cut in/out the VCC/GND (0V/+5V). Otherwise, data signalling (NRZI) over D+/D- to the servo using libusb or something.

that is very unlikely to work. The USB root must first recognize and install the device. Looking at the webpage, it appears that the linked Phiget devices are pretty much geared for motor control. I do not know how much feedback they can give to windows, you'd have to look into the source code/ API for the libraries that Phiget supplies. From a quick glance, I would think that the devices are very much "output only".

edit:

upon closer inspection of the C API (http://www.phidgets.com/documentation/C_API_Manual.pdf pg 15) It seems that there are ways to connect an input button to this device and use CPhidgetMotorControl_getInputState to query the state of that input device.

edit2: I just noticed that this is an output application. DUH. I have limited experience with solenoids, but I'd suggest to make sure that the input characteristics match the USB board's output characteristics, i.e. voltage and current.
 
Not sure what you are trying to accomplish in the end but try this.

1 low voltage relay (3 to 5 volts with low current draw) the most common are called “single throw double pole, or you could even use a single pole.

How ever many solenoids you think you will need, preferably 12v-Push with power on, self retracting try to keep the throw (distance the plunger will move) short 3 to 5mm should to it if you are trying to push a computer button.

You will need a good 12-volt connection (plus ground so 2 wires) from the least loaded part of your 12v power supply rails.

You use the low USB voltage to trigger the relay; the relay then switches 12 volts to the solenoid.

A solid-state switch for everything might be easier and less clunky, but this setup will work.

PM if any of that is Greek

Luck
 
I'm working on a project and I need some way to be able to simulate a finger pushing a button with a computer. I want to do this using a USB interface.
I'm just curious to verify my understanding of this... you are building a physical model of a hand/finger pushing a button? Do you have to replicate the actual force and/or speed a person would be using to push this button?

I'm just wondering about the physical requirements opposed to simply using a relay or optocoupler to activate the circuit. Or why usb vs. simple printer port control.

Also, you'll find much better prices in the surplus market, like All Electroniucs and the like.

Don't forget a dc powered solenoid will create huge voltage spikes when the field collapses, you need to provide a reverse biased flywheel diode across it's terminals to protect the rest of the circuit, much the same as relay coils. Also, solenoids tend to requie a good bit of inital current, make sure whatever switching circuit you use is able to handle that. Typically you'll need a medium sized transitor or mosfet to handle the load if you are switching via ss.
 
It looks like you need something like this USB to Relay Box. You would need to provide your own power for the solenoids (could use 12V from a PC.

Is this some kind of automated tester for a pushbutton panel?
 
I'd recommend you run the solenoid(s) off a separate power supply--don't use the one that's powering your motherboard, hard drive, etc....
 
I'd recommend you run the solenoid(s) off a separate power supply--don't use the one that's powering your motherboard, hard drive, etc....
^^ Agreed. Even with flyback diodes, why risk sensitive pc components with transients like that. Opto-isolation is the preferable interface here.
 
Really appreciate all the help!!!!

Okay there seems to be a need for a bit more clearification on the project. I'm not building an actual finger or hand or anything. I have a button (kinda like a big arcade button) and with different data collected and then processed in real time on my laptop I will need to stimulate the pressing of that button a specific times. I'll do this with the solenoid stilling on top of the button ready to strike. So the stroke of the solenoid plunger would be like .25" at the most ...does that make sense?

So far it looks like the most suggested idea is to just break open a USB cord, and trigger a relay to power the solenoid.. this is cool because it sounds cheap BUT I'd need my hand held (no homo :) ) through the wiring of the relay and stuff.. I'm just a programmer, I really WISH I had the expertise to do that. So.. can someone help me out and explain how I'd go about doing that? I'm not a total idiot about it but you should probably act like I am. Soldering is not a problem.

Also.. this has to work off a laptop.. this is why I need USB rather than serial or whatever. This also means that I can't hook anything up to atx for power and I'm definitely NOT opening up the transformer or splicing the power cord or anything.

Thanks agent420 for the links! I haven't looked through them yet but if anyone else has some place to get solenoids for cheap that would be REALLY helpful.. most places aren't interested unless you need at least 100 of them. What about something like a starter solenoid or something like that which I could pick up at Pep Boys? Think that would work?
 
From the above posts It looks like you are wanting to control a single solenoid directly over a USB connection. USB is a serial data interface, so that is not going to happen if you expect the USB interface to turn power to the solenoid on or off. You will need something similar to the box I posted earlier, or a parallel or serial port connection. Most of those will not supply power sufficient to drive a solenoid either, so you may still need to design an interface circuit and supply separate power.

If you can tap into the pushbutton switch wiring (bypassing the actual switch) you can simulate the switch being pressed using the box I posted earlier.
 
From the above posts It looks like you are wanting to control a single solenoid directly over a USB connection. USB is a serial data interface, so that is not going to happen if you expect the USB interface to turn power to the solenoid on or off. You will need something similar to the box I posted earlier, or a parallel or serial port connection. Most of those will not supply power sufficient to drive a solenoid either, so you may still need to design an interface circuit and supply separate power.

If you can tap into the pushbutton switch wiring (bypassing the actual switch) you can simulate the switch being pressed using the box I posted earlier.

Thanks but yea I'm using 1 solenoid which I'm trying to get for <$20 that I'm thinking will run somewhere in the ballpark of 5VDC-12VDC so a huge 16 output industrial, err.. thing is not really the solution that I'm looking for. A little widget with maybe a 9V or two taped on the underside seems much more portable and less three-hundred-dollar-ey :cool:

I just need some help with how I'd hook everything up, which kind of relay/solenoid, then finally hacking the durn thang

EDIT: Good question, but no I cannot bypass the button switch. Otherwise I would not have to go through all this!
 
Sounds like some hack for a skill-stop slot machine or something ;) Automated pinball player? Do we get a percentage of the payoff? :)

You are probably better off using a Phidget like interface for usb rather than some usb power hack because you'll have more programming control and no worries about Windoze complaining about it. Another interface to consider would be this usb interface card or read through this bit-bang usb pdf if you are feeling adventurous. These provide inputs for your sensors as well as outputs, and the proper VB or C device driver libraries.

Any of the small solenoids from the All Electronics link (or similar surplus) should work fine. I doubt you'll find cheaper. Of course, you could always make your own :). I think a starter motor solenoid is overkill in both force and power supply demand; you're more likely to smash the button than press it. I'll bet they cost more than the surplus units as well.

You can probably find a cheap dc wall wart that will suffice as a power supply, eliminating an electronic design project from your list of needs. The interface card outputs do not provide much current, so you'll need to use relays or some other larger transistor driver to fire the solenoid. If you Google around for solenoid or relay driver schematic, you will probably find what you need... I don't have the time atm, but I'll post a couple of links later should you need them.
 
That usb card thing is pretty much the same thing as the 0/8/8 Phidget. I'm going to try the USB cord hack first and if that doesn't work I should have a relay and solenoid that are still working and I will just add a Phidget into the mix.

Anyway, this is the solenoid I've chosen to go with.
SOL9551.JPG

From the website:
10.5 VDC SOLENOID LEDEX, #122089-001. Tested at 10.5 VDC this solenoid pullsapprox. 1 lb. at 1/16 . DC resistance 31 ohms. 0.34 amp at 10.5 VDC. Intermittent duty.Has straight plastic boss with groove at end of solenoid for mounting. Mounting boss is5/8" dia. x 3/8" long. A 3/32" wide groove is located adjacent to the body for mounting into a slot, etc. Actuatingplunger is 5/16" dia. x 1/4" long. The plunger has a 1/8" groove cut in its O.D. for connecting plunger to load,etc. Dimensions: body 3/4" dia. x 1-29/32" max. length not counting plunger. Stock #SOL9551
So what kind of solid state relay should I get?
 
I don't see a "0/8/8" Phidget on their website. If you mean "8/8/8", it claims to drive a solid state relay (specifications are rather vague though). Solid state relays can be had from Digikey... http://www.digikey.com/scripts/DkSearch/dksus.dll?Criteria!!!!!!!439263&Site=US&Cat=34210934. I have experience using relays from Crydom and IR both of which are good.

OTOH, if the "0/0/4" will work, it has built in relays. Mechanical relays have some contact bounce time (around 100-300 or so milliseconds) but should work unless you are concerned with a potential 1/10 to 1/3 second delay. Probably not an issue since solenoids have similar delays.
 
I'm going to try the USB cord hack first and if that doesn't work I should have a relay and solenoid that are still working and I will just add a Phidget into the mix.
What OS are you running this on? Do you have a driver that is low-level enough to allow you to control the USB signaling lines directly? If not, I am quite certain that "breaking open" a USB is not going to work. From my little experience with USB, I feel confident to say that USB is a lot more complex than a "standard serial port" and that there is quite a bit of stuff going on in the background -such as clocking- that will utilize the D-lines, therefore break your design.
Agent420 and Frank4d have suggested quite a few viable solutions. Another option may be a USB-to-serial converter and then hack that serial interface, which is a lot simpler than USB. I assume that your USB requirement stems from the lack of Serial ports on your computer.
 
Okay so it seems that everyone is pretty much saying that hacking the USB by cutting into it is a stupid idea... Sigh, and I have to agree. I'd have no idea how to start hacking to USB to get a small voltage to trigger the relay to power the solenoid and I know that would be a total pain in the ass.

USB is the only out that I have on my laptop, no parallel or serial or anything else I have to hack. I'm runing a C2D Macbook Pro so I have the option of running OS X, Windows XP or Linux, but I think that for this project I would really like to have everything running through native Ubuntu.

Time is really a factor, so I'm really pressed to use a solid state relay. I know solenoids aren't exactly instant but the less lag time the easier tuning will be so the 0/0/4 Phidget is not my first choice. There really isn't a Phidget that is exactly what I need so I might get the 8/8/8 or 0/16/16 or the one agent420 linked to but most likely I will get the 1-Motor PhidgetServo and hook the relay up to the servo out.

But I still have zero idea what kinda of relay I need for the kind of solenoid I posted earlier, or how to wire it up for that matter. I still have lots of research to do I guess.
 
icoris said:
...most likely I will get the 1-Motor PhidgetServo and hook the relay up to the servo out.
Motor control interfaces like that one output pcm signaling that won't be readily usable as a digital on/off control for a relay. I'm guessing that you're trying to save a couple $ because you only need one output, but you will be much better off with a standard input/output interface.

As far as driving the solenoid, you don't necessarily even need a relay, especially for a small solenoid like that... In fact, the circuitry to drive a relay is identical to that needed to drive a solenoid with the exception of power capability (both devices are just coils). You need something like figure 2 here. The output of the card will drive the gate of the mosfet (or base of transistor) turning on the solenoid. Just substitute the solenoid coil for the relay coil in the schematic.

As Frank4d mentioned, the Phidget 0/0/4 already includes relays and would be your entire no-hassle solution. The el-cheapo usb->serial converters may bear some additional research if you absolutely must keep cost down, but I tend to think you do not have the same ability to control the individual i/o lines on those as you can with a conventional on-board hardware serial port; I think most only accept standard serial commands. Those usb converters (both serial & parallel) are really microcontrollers interpreting usb commands and emulating a port; there is no direct connection or memory mapped io to the pins that you can access via programming.

edit -

Also, I wonder if a push-type solenoid would be better suited for your application of pushing a button.... You will need to fabricate some kind of operating lever mechanism with a pull-type like you linked. There are a couple similar push types on that page... Might be able to even build some suction cup mounting for it if needed...
 
Okay I bought a small PUSH type (took agent420's advice on something finally ;)) solenoid from the same website that I posted the first solenoid off of (SOL9153 if you're interested). I hope that solenoid will work.

I also found this. This little guy plugs into any normal 3-prong servo control output, so the PhidgetServo + Scorpion Mini will work, but I've found other USB servo controllers that cost about as much as the Phidget 1-Motor but have way more that just 1 servo controlled off it. Not that I need more than one, but I think it's a better value. So I might take that route, but for right now I bought a USB to DB-9 cord and I'm gonna try to hack the serial - but I still have to find a good C/C++ API for that, I haven't researched it enough yet. The adapter cord was super cheap, so I figured what the hell. If it becomes too much of a pain in the ass I'll finally go the Phidget route and cough up ~$70 I guess. I'll have to wait another paycheck though.

Any help on playing with the RS-232 would be real helpful :D
 
I'm not certain I understand the reasoning of purchasing a usb servo controller that requires an additional card to operate the solenoid, when you really need an off/on signal and a single cheaper standard i/o card provides the same (actually more) ability? Why the servo pcm fetish when you won't really be using it?

There's probably a free api out there somewhere that has control line capability, but I think you're in for a good Google session... Most of the ones like that I have seen are retail 3rd party products, I don't know what's available for MAcs...
 
soloniods can take a lot of current.. not so sure if it's a good idea to source current directly from the USB port.. you could drive the USB interface chip
 
If the button is a standard momentary button, removing the physical button and placing a relay in its place would work alot better. Combine that with a usb pic and you are all set. The other option is a usb<->serial cable, and bit-banging the serial port to turn on the relay.
 
Hrm.. I just assumed this thread was buried but whatev.

As I mention before, removing or tampering with the button and having direct access to the circuit that it completes would definitely make things easier but that breaks constraints for this project.

For all those who are interested:
Currently, I think that I have everything that I need for this part of the project. I have a nice little push solenoid connected to 8x 1.5v AA batteries in a series which give me my 12v. That circuit is switched with a little MOSFET(RF510) which is triggered by the DTR line in a D9 serial port at the end of a USB->serial adapter cable. That's the plan, I just need a little free time to solder everything together, slap some code over top it, and also design and build a housing for the solenoid.

Thanks to everyone who posted in this thread for helping me out and giving their ideas. Spring break is coming up and I should have time to play with this then. I'll post my results when that happens if anyone cares to see ;)
 
Back
Top