02-24-2021 05:06 AM
Hi all, wondering if I can get some advice on a setup, firstly on the hardware approach to take, and then if different communications (modbus? ASCII?) are preferable to use with labview
I need to control 2 solenoid valves, which will open when a sensor exceeds a certain value, and I understand the current requirements are too high to control them directly from my DAQ USB-6363. From reading on here it seems I need a relay, but I get a bit lost after that. I think my options are to connect my DAQ to a digital output to relay module (?), that to the relay, relay to valve. Or get an external ethernet relay, connected to the computer(?) and to the valve. Whichever relay will be connected to my power supply (?), and the sensor will be connected to the DAQ. I’ve done the DAQ course, but I have little to no knowledge on circuits/hardware, hence my uncertainty.
I haven’t bought anything yet, so am looking to buy whatever is going to make life easiest.
With this in mind, when looking for hardware to interface with labview, are there ideal communication means to look out for?
Is modbus an easy way to communicate for example? ASCII? Or are there certain things that are a pain to program while some lend themselves to nice code?
My program is a continuous acquisition, which has kept me away from using express VIs (if I recall), is based on a QMH and it interfaces with another couple of instruments using drivers, but these seem to vary quite a lot in how easy there are to find/use.
I'm happy to learn something that’s not immediately straightforward if it makes my code better in the end.
Any advice on the hardware approach to take and then what comms to look for will be much appreciated.
Thanks for reading
Solved! Go to Solution.
02-25-2021 08:12 AM
Okay I've done more reading and I am very confused but i think I've gotten further. Nevermind about the comms stuff as I'm going to go via the DAQ.
So, I need:
DAQ, connected to a relay module, which has it's own power supply, and then connect the relay to the two valves.
How do I provide a power supply? I have no electronics background, so to me that sounds like plugging something in to the wall. In reality is it that I have something plugged in to the wall, and then something else going between that and the relay module?
02-25-2021 09:40 AM
Much will depend on your choice of "relay module".
For example, where I work we've sometimes used simple off-the-shelf relay boards such as this one from Numato. They need either 12V or 24V DC power, and DC power adapters are pretty easy to come by. They're controlled via serial communication rather than DAQ though, so they may not be a good choice for you.
I'm afraid I don't have a specific recommendation for a DAQ-digital-output-controlled relay module, just general tips.
- When you control relays via DAQ digital outputs, you'll need to check the specs of your DAQ device for its ability to source current from its digital outputs and the specs of your relay module for its current demands.
- You should also be sure to do some reading on the "inductive kick" that solenoids will have, and what you might want to do about it (hint: diodes).
-Kevin P
02-25-2021 10:02 AM
Thanks for your response and tips.
When you use your separate relay controls do use just wire them straight in to the adaptor?
I'm happy to use serial communication, one of the other instruments I have on there is controlled the same way.
Thank you for mentioning the diodes, I had no clue about that, or what a diode was, so that's very helpful.
So the set up will perhaps be Serial connection with PC - relay board (connected to power adapter) - diode - solenoid
02-25-2021 02:25 PM
If you're ok with the serial communication, here's some specific help about the Numato USB relay board(s):
1. Wiring
The Numato boards we've used have screw terminal connections for the relays. Each relay has a Common (C), a Normally Open (NO), and a Normally Closed (NC) terminal. You'll want your solenoid power supply to use the C and NO terminals so that when the relay is OFF, the circuit is open and the solenoid is unpowered. The relay literally acts like a switch. When OFF, the circuit is open and no current flows. When ON, the circuit is completed, current flows, and the solenoid activates.
They also have screw terminals for the DC power connection. We use pretty unfancy DC adapters rated for 1.0A which is far more than enough for 8 relays.
2. Serial Communication
They actually connect via old-style USB cable, the kind often used with printers. Their driver makes them behave like a serial port, except that many standard serial port settings like baud rate are irrelevant. Whatever you choose will be accepted and also ignored because it'll actually just do its own thing over USB.
3. VISA
It took some trial and error to discover some things about the messaging protocol that were either not mentioned, not clear, or not prominent in the manual. The most important one is that the proper message termination character to use is '>' rather than a line feed or carriage return. It's also important to know that it'll echo back every line you send it. And it'll add a line feed - carriage return combo after the echo as a line terminator.
I'm going from memory, but here's an example. Note that '\n' designates a linefeed character and '\r' designates a carriage return character.
You send:
relay read 2\r
Device replies:
relay read 2\r\n\roff\n\r>
To parse out that sort-of-a-mess of a reply, I use Match Pattern to find the string I sent. Then I keep the 'after match' output and get rid of the trailing '>' character. Then I use Trim Whitespace to get rid of whatever # of leading and trailing '\n' and '\r' chars there may be. What's left after all that is what I actually care about, "off".
It was a bit of a pain to get things worked out initially, but once we did the boards have worked out quite reliably.
4. LabVIEW
Numato has simple code examples for many languages, including LabVIEW. Like a lot of LabVIEW code written by people who are primarily text programmers, it's pretty terrible. Do NOT use it!
Below is some LabVIEW code I modified slightly from a shipping example to make it more usable. The shipping example is pretty un-great too, my mods made it slightly less so (at least for my immediate purposes).
5. Diodes
I'm aware of the potential importance of protective diodes, but have rarely needed to build them into a test fixture myself. When I've needed to in the past, I spent some time researching to be sure I was doing the right thing the right way. I'm reluctant to shoot from the hip and give you possibly wrong suggestions now, I'd instead encourage you to look into things enough to figure out what you need to do.
-Kevin P
03-03-2021 06:24 AM
Amazing, that's really so helpful, thanks, definitely looks like something I can incorporate. Thank you so much for your time!
03-03-2021 12:31 PM
FWIW, and at least for the moment sticking with the same company Numato, perhaps it'd be even more straightforward to use a relay board controlled by TTL digital signals, since you already have a DAQ board with digital outputs available. Programming DAQmx for DIO should be a much simpler way to control your relays than having to deal with quirks of serial communication. I simply hadn't looked into it before as a lot of our serial-driven relay board usage is on systems with no DAQ devices attached.
There are probably plenty of other suitable options if you scour around maker-oriented vendors.
-Kevin P