Showing results for 
Search instead for 
Did you mean: 

How to use labjack U12 to control solenoid directional valve with Labview in hydraulic system



I need to control a solenoid operated direactional valve in hydraulic system with Labjack U12. I am using three relays but need some help on the vi. like which instrument drive I need to use etc....


The coil voltage for the solenoid valve is :  AC120V, 60Hz; AC110V, 50Hz 


My goal is to control this solenoid valve open/close at certin time, am using Labview 2011. Any advise would be helpful.


Thank you!

0 Kudos
Message 1 of 14

Have you got the relays working yet.  Do some initial testing with LJlogger to make sure hardware is controlling the relays as expected.  If you need further help with this step, provide a link to electrical details for the relays and describe how you have the relays connected to the U12.


As for your programming in LabVIEW, I suspect you are using digital I/O, so the simplest thing to do is call EDigitalOut() to set a particular line to output-high or output-low, or if you need to set a line to input (for open-collector style control) use a call to EDigitalIn().  Perhaps look at "e function" to get started, and for general information about using the LabJack U12 with LabVIEW see topic #84 from the LabJack forums.

0 Kudos
Message 2 of 14

Really appreciate your help! But I do need furtfurther help on this issue, I don't have any electrical diagram for the set up, the three relays were connected on the RB 16 card as R1,R2,and R3 (pin 2,3 and 4 on the DB25 connector) please see pic attached. How can I use LJlogger to make sure hardware is controlling the relays as expected? Please advise. Thank you!!!

0 Kudos
Message 3 of 14

Looks like you have modules R1, R2, and R3 installed, and I can see connections to the load side of those modules on the RB16.  For an AC load, typical connections would be:


Hot => Rn+ => Rn- => Load => Neutral


Thus the relay module is disconnecting hot from the load.


As noted in the RB16 Datasheet, you use negative logic, so for example set D1 to output-low to activate module R1, and set D1 to output-high to deactivate R1.  Go into LJlogger, and set the direction for D1 to output, then toggle its state between high and low.

0 Kudos
Message 4 of 14

Could you please give me some more detail instructions regarding how to setup the LJlogger?  Thanks!!

0 Kudos
Message 5 of 14

There is no setup required for LJlogger.  You just need to:


1.  Run it.  Find and run LJlogger.exe.


2.  Set the direction of D1 to output.  In the "Digital I/O Commands" box, go to the "D Direction" control and click the radio button for #1.


3.  Toggle the state of D1 between high and low.  In the "Digital I/O Commands" box, go to the "D State Write" control and click the radio button for #1 repeatedly to toggle the state back and forth.



0 Kudos
Message 6 of 14

Thanks sooo much for being patient with me. Now I finally confirmed the relays are working with LJlogger, but still have no clue about using the EDigitalOut vi in labview, like how to set up the ID number? chanel? write D? etc....An example would be really helpful.


I am using the solenoid valve to control a piston to set and retract. (Consider set-retract as one cycle, 30secs to finish one cycle). I need to automate this piston for 3000 cycles.



0 Kudos
Message 7 of 14

Read about EDigitalOut in Section 4.5 of the U12 User's Guide:


You want to pass:


idnum = -1

demo = 0

channel = 1    //because you are controlling channel 1

writeD = 1    //because you are controlling D lines not IO lines

state= 0 or 1 is an example in itself.  You can open it and set those parameters on the front panel and click run to see it work.


To see an example VI that calls EDigitalOut, look at "e function".


Beyond that, it is just normal LabVIEW programming, nothing specific to the LabJack U12.


0 Kudos
Message 8 of 14

Really appreciate your help, now finally am able to control relays through Labview, however, when I use LJlogger, I can hear the relay was running all the time, when I use Labview, I can hear the switch was on and off, on and off...did I miss anything? Could you please help me on this?


0 Kudos
Message 9 of 14

Make sure you are only running 1 program at a time.  You might have LJlogger keep turning it off while your program keeps turning it on.


Remove the RB16 and use a scope or DMM to look at the voltage on your D line of interest versus GND.  If the line is changing states, then something is telling it to change states.  Here is a pinout of the DB25:


0 Kudos
Message 10 of 14