LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

daq relay control

Solved!
Go to solution

I'm trying to create a vi that will control (actuate and release) several relays using a USB 6501 DAQ. This should be a relativily easy task but I keep getting flumoxed by errors. I've tried using the examples but I keep getting an error telling me that I need to use 1 sample (On Demand) generation mode. Please help

0 Kudos
Message 1 of 8
(2,898 Views)
Yes, you must use 1 sample mode since the device is software timed. You cannot have any timing functions so your code is basically just the nchan 1samp DAQmx Write.
0 Kudos
Message 2 of 8
(2,894 Views)

I need to be able to be able to actuate the relay for about 10 Sec and then releas for about 10 sec while running the vi. Can I do that with a single sample?

0 Kudos
Message 3 of 8
(2,887 Views)

@bfort wrote:

I need to be able to be able to actuate the relay for about 10 Sec and then releas for about 10 sec while running the vi. Can I do that with a single sample?


Sure, what is the precision you need?  Windows timing (or software timing) is sorta arbitrary.  If your relay was on for 10.001 seconds is that okay?  What about 10.01 seconds?  What about 10.1?  How consistent it is will rely on how many other things Windows is doing, and how good of a computer it is.

 

But generally if you have your code running in a while loop, doing nothing else, you can probably expect <10ms of variation.

0 Kudos
Message 4 of 8
(2,882 Views)

How do I control the timing?

 

0 Kudos
Message 5 of 8
(2,877 Views)
Solution
Accepted by bfort
Sure. The simplest way is to have one DAQmx Write followed by a Delay function, followed by another write, followed by another delay. Simply connect the error connections to control the dataflow. The VI would be pretty unresponsive though so you might want to use a state machine or the Elapsed Time function so that the VI can be stopped without waiting for the waits to finish.
0 Kudos
Message 6 of 8
(2,870 Views)

There's the Wait (ms) function.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 8
(2,869 Views)

@bfort wrote:

How do I control the timing?

 


With a While Loop and probably the Elapsed Timer VI.  You can wire to it a constant, and it will tell you if that amount of time has elapsed or not.  When it has do something using a case structure.

0 Kudos
Message 8 of 8
(2,868 Views)