PDA

View Full Version : Computer -> output?



No0bert
02-25-2009, 02:19 PM
Is using a Max232 and connecting a 12v DC solenoid, and of course 12v and GND into the V+ and GND, to the output of the Max chip as easy as I describe it?

How would I invoke the output's high?

Please don't suggest a Phidgets, as my budget is beyond maxed.
If a uC is required, all source code/schematics very welcome!

ScuD
02-25-2009, 02:34 PM
A max232 is really only designed as a signal level translator, and as such not meant to drive high current devices such as a solenoid.

You can just use a simple transistor with the appropriate resistors to accomplish this through a serial port, although your outputs are limited.

A parallel port increases the amount of outputs, a microcontroller increases outputs and greatly enhances the versatility.

It's all about what you want.

http://www.b-l-w.de/relais.gif

Replace the relay with your solenoid in the above schematic, and voila.
You can leave out the LED if you want, but make sure you don't forget the diodes!

No0bert
02-25-2009, 03:06 PM
Then how do I invoke the high/low of the solenoid?

ScuD
02-25-2009, 03:09 PM
Any programming language you can use to drive the TX/RTS/ line. Basic, visual basic, python, c, ...

Make sure you use a "real" serial port though, most (older) usb to serial adapters do not support bit-banging (eg. turning on/off a single pin)

jes1510
02-25-2009, 03:09 PM
Yep Scud nailed it. You can connect it to one of the handshaking pins on the serial port and toggle that pin to kick your relay on and off. If you need more pins then you can use a parallel port instead.

Edit: D'oh! I just noticed that the DTR and DSR pins are already labeled on the schematic. You can get control of the pins using the pySerial module in python if you want.

http://pyserial.wiki.sourceforge.net/pySerial

Tis may be useful. Primarily this section:
open() # open port
close() # close port immediately
setBaudrate(baudrate) # change baud rate on an open port
inWaiting() # return the number of chars in the receive buffer
read(size=1) # read "size" characters
write(s) # write the string s to the port
flushInput() # flush input buffer, discarding all it's contents
flushOutput() # flush output buffer, abort output
sendBreak() # send break condition
setRTS(level=1) # set RTS line to specified logic level
setDTR(level=1) # set DTR line to specified logic level
getCTS() # return the state of the CTS line
getDSR() # return the state of the DSR line
getRI() # return the state of the RI line
getCD() # return the state of the CD line

No0bert
02-25-2009, 03:38 PM
Any programming language you can use to drive the TX/RTS/ line. Basic, visual basic, python, c, ...

Make sure you use a "real" serial port though, most (older) usb to serial adapters do not support bit-banging (eg. turning on/off a single pin)

do you know of a source code? Because I am not a good programmer, preferably one that has comments so I can learn?