Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Trigger Relay from serial / usb port

Status
Not open for further replies.

stuee

Member
Hi.
I have picked up a old cash register thats broken, i pulled off the main bit to leave the draw. the draw opens with a solenoid and voltage is tested to open 9v+.

I would like to incorporate in some software im using to print a receipt that i could get it to call a software .exe then that sends a single signal to a port which in turn triggers the solenoid. I know i will have to put a relay in between as im guessing a std com port wont have enough umph to trigger it. I will test it soon and see the ampage i pulls, if i could get away without a relay and power supply that would be great.

Any ideas / schematics/ links appreciated.

Cheers
Stuart
 
If you want to do it from a small simple GUI on the computer and you have an RS232 serial port it can be done pretty easily. You will need an external power supply and at least a transistor. Doing it from a USB port would require an additional hardware interface and gets more complex. While I have not messed with it for awhile I think the RS232 port has two logic output lines and I think they swing from -12 to +12 volts. One of those lines could likely be used. All you want is something on a form that you click and the draw opens correct? Can you write in any programming languages?

Ron
 
Hi Ron.
Thanks for your reply. i dont know programming so thats out for me.
How would i wire up for the powersupply ready for the signal?
thanks
 
Hi stuee,

I think the pulse can be generated using windows hyperterminal (All Programs -> Accessories -> Communucations -> Hyperterminal)

Here is a circuit suggestion. Board dimension is 2.550X1.375".

Boncuk
 

Attachments

  • SER-SOL-SCH.png
    SER-SOL-SCH.png
    14.3 KB · Views: 597
  • SER-SOL-01-BRD.png
    SER-SOL-01-BRD.png
    8.8 KB · Views: 486
  • SER-SOL-02-BRD.png
    SER-SOL-02-BRD.png
    9.4 KB · Views: 460
Last edited:
Deleted (double post)
 
Last edited:
OTAY, I made a little program you can play around with. You can use it with the schematic Boncuk was kind enough to provide.

First you can download the program here. Just click the link. You will be prompted to save the file so save it to a convenient location on your computer. Right click the folder and choose Extract. Open the extracted folder and double click the .exe file and the small program should install.

Run the program and before all else choose your computers Comm port you plan to use. Then click the Start button. Each time you click "Pulse Out" button you will get a 500 mSec pulse out of the RS232 port Pin #4 (Pin #5 is Ground).

Questions, just ask.

Ron
 
Hi there,

I am looking to do the exact same thing. I looked at your circuit and I am wondering what the 4 terminals are. X2-*

As for the relay I have 2 questions:
-if I wanted to use a 5v relay instead would I just change my power supply to a 5v?
-Will a reed relay work or do I need a mechanical relay?

thank you
Marc
 
If you got a connector you could rob 12v from the pc's power supply, black gnd and yel +12, the solenoid would be ok for just a blip, just put a back emf diode across the coil to prevent any back emf upsetting the pc.

You could use a transistor and a relay to drive the relay coil from the port (or even drive the solenoid coil direct), or if you want even simpler you might be able to drive a reed relay directly from the port, check the current capability of the port is enough to provide the relay with enough mA.
Someone here probably knows.
 
Last edited:
Hi there,

I am looking to do the exact same thing. I looked at your circuit and I am wondering what the 4 terminals are. X2-*

As for the relay I have 2 questions:
-if I wanted to use a 5v relay instead would I just change my power supply to a 5v?
-Will a reed relay work or do I need a mechanical relay?

thank you
Marc

Hi Marc

The X1-X4 are just points on the board. You are simply driving a relay using a transistor. That being the basic circuit. Yes, you could use a 5 volt relay. The only trick is to make sure the transistor can drive the relay used.

Ron
 
I have been doing some reading on transistors and there are different ones for different purposes. Which common one should I use. I did some testing and the DTR or CTS signals are strong enough to drive a transistor, Unfortunately I want to use the Data signal as that one does not trigger when the PC is booting up. I prefer not to "steal" power from the PC, I would much rather use an external power supply, that way no changes are needed within the PC. That said, can I join the negative side (ground-Pin5) of the serial port to the negative side of my power adaptor without causing problems.

thank you
Marc
 
Hi Marc

Yes, you can have the different power supplies share the same common (ground). As to a transistor just about any common NPN switching transistor would be fine, for example a 2N2222 can handle as much as 800 mA to drive a relay coil but I would keep it lower than that. Another NPN choice for small relays with low current coils is the 2N3904.

Now if you want to use the actual data lines things get more complicated. This is where I would suggest a pre made card form a company like the VELLEMAN K8090 8-CHANNEL USB RELAY CARD - KIT A Google of USB Relay Card or RS232 Relay Card will bring up plenty of results. Most provide software plus software development examples in several common languages to create your own.

Ron
 
Hi Ron,

Thanks for your reply. Why would it be better to purchase a card to use the data line? I did some tests with DOS and LEDs and I am able to easily control the data line, the only thing I noticed is that the data line current seems much lower than the DTR or CTS. Therefore probably not enough to control the transistor.

I had thoughts of somehow using the DTR or CTS to boost the signal. Or use an AND gate. Would that work? Since I'd be using a 12v @ 500ma PS to switch the solenoid. Would I be able to use resistors to drop the voltage/current to power the AND gate?

Thanks
Marc
 
Hi

My thinking with using a pre made card is that I can buy a simple card with as few as 4 relays all self contained for less than I can likely build one. Most kits like this include the basic software plus a SDK (Software Developers Kit) including a DLL file that makes writing code pretty easy. Also, if I want to expand things a little I can buy a simple DAQ starter kit like this one for $59 USD and get really carried away. I can't build one of those for $59. Additionally, the old parallel port is all but totally extinct and the serial RS232 port is about dead on new systems. Using a canned USB card or little DAQ like I linked to makes for easy use of the USB port.

I had thoughts of somehow using the DTR or CTS to boost the signal. Or use an AND gate. Would that work? Since I'd be using a 12v @ 500ma PS to switch the solenoid. Would I be able to use resistors to drop the voltage/current to power the AND gate?

What exactly are you trying to do Marc? :)

Ron
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top