Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

A little guidance with hardware control...

I am trying to learn basic hardware control with LabView. I want to control 4 relays via USB and could use some help getting started. I'd like to be able to turn the relays on and off individually. The relays will handle 120V max, something like a light-buld (US here), but will most likely control 12-24V units like solenoids or motors.

I have a PC and Labview. Can I connect a relay directly to a USB port? I think I read where you can send a stream of 1's to a serial port to provide a constant voltage (like turning it on and off). Could I match the relay to the output voltage of the USB port (5V ?)? If so, can I address up to 4 relays individually? If not, what other hardware will I need? I'm trying to keep this project as cheap as possible.

Thanks,
Dave
0 Kudos
Message 1 of 7
(4,375 Views)
Dave,
for cheap (and easy when you now hardware) you can use the RS232 port (COM) to control 3 relays or the printerport to control up to 8 relays,
schematics can be googled, but I have never seen something similar with the USB.
However, have a look at the NI digital IO USB box, it is cheap and plug/play 🙂
Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 2 of 7
(4,361 Views)
You should not connect a relay directly to a USB port. For one thing, I'm not sure the current output is enough to turn on a relay. You would also run the risk of damaging the USB port without some isolation. And, even if you managed to determine what the raw USB command to generate a logic one is, this would only control a single relay. As Henrik mentioned, NI sells an inexpensive USB DAQ. It has digital outputs that can be used for external control. The current sink of the digital I/O is still not enough to drive a relay but inexpensive relay drivers can be added (such as ULN2003).

I agree with Henrik that the cheapest way would be to use the serial or parallel port with some addtional hardware (i.e. the realy drivers I mention above). You can find a tutorial on using the parallel port here.
0 Kudos
Message 3 of 7
(4,357 Views)
USB means Universal Serial Bus. AFAIK there's no direct Pin that allows to change its level permanently.
Unlike the serial port, where you have the HW Flow Control Pins that can be set permanently, this is impossibel with USB.
USB has a standard current supply of 5V/500mA. This should be enough to drive some smaller relays, but you need an USB controller that communicates with the USB master and receives a command to 'change one of its pins that controls your relay'. There are some ICs that emulate serial or parallel ports on an USB port, but even with those it is quite tricky to write a driver and control it from within LabVIEW. Long words short meaning: Use a standard port OR a standard device!

Greetings from Germany!
--
Uwe
0 Kudos
Message 4 of 7
(4,352 Views)
I'm with Dennis. I wouldn't connect a relay, or any other inductive load to the port. Even if you could drive enough current, I'd be afraid of kick-back nailing your PC. Opto-isolators are good for this purpose.
John

"Praise the Lord and pass the ammunition."- Lt. (j.g.) Howell Forgy, Sky Pilot, USS New Orleans, 12/7/41
0 Kudos
Message 5 of 7
(4,345 Views)
Thank you all for your help. I will have a look at the PnP USB box from NI. I will also look at the COM port option. The computer that I will be using has two COM ports and a printer port so it gives me plenty of room to grow. I was figuring on trying USB because some of the newer computers don't even offer COM ports anymore. I'll worry about that issue when it becomes an issue. 🙂

Thanks again!
Dave
0 Kudos
Message 6 of 7
(4,340 Views)

Hello All,

 

I've got the same question.  I have a lot of NI hardware and I am familiar with doing what I want to do with the cRIO chassis or any of the DAQ-mx stuff.  But I'm trying to help some students out with a complex valve setup which is preventing them from aquiring a cheap timing device and requires a PLC.  I'd like to use a pair of solid state relays (which I have) that will operate on as little as 3.2VDC but they don't have the same budget as I do for buying hardware.  So what would I need to do to make a program that turns the pins of a serial port on and off to control my relay?  Thanks

0 Kudos
Message 7 of 7
(3,743 Views)