LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sending digital output signals in a timed sequence

Solved!
Go to solution

Hi,

 

I need to be able open remote valves using DO signals as well as with separate switches outside of the sequence. I thought using local variables (for the control switches) inside a flat sequence would work for this, but I've been having issues with it. I can actuate the valves by clicking the switches, but when I start the sequence, the switches move on the front panel but don't actually send a signal to the valves.

 

I have attached a simple model VI of the situation (Sequence_Model) as well as the relevant portion of the full VI I'm using for data acquisition. Any help is appreciated, whether it be changing the structure of the VI (i.e. not using a flat sequence/local variables, etc.) or just any other small changes that would make it work.

 

Thanks much! 

Download All
0 Kudos
Message 1 of 7
(3,043 Views)

Hi Joey,

A local variable is linked to a piece of data in LabVIEW, and has no physical significance until you send it to the hardware. I cannot view your VI due to LV versions, but I assume you are using DAQmx drivers to send your digital values to hardware. So, simply writing a value to a local variable is not equivalent to writing it to hardware.

 

For a sequence of functions, people often use the state machine template, especially when timing/decisions are involved, or the code simply takes up too much real-estate to fit on the screen linearly.

0 Kudos
Message 2 of 7
(3,032 Views)

I have attached 2016 versions of the two VIs to this reply

Download All
0 Kudos
Message 3 of 7
(3,021 Views)
Solution
Accepted by topic author joeyjackson97

Ah, I see now. Let's focus on your code inside the loop.

 

Whenever two functions are side by side (or top and bottom) of each other with no data dependencies, they will operate in parallel. So here's a timeline of what is happening in milliseconds, when ignition == true.

 

 t=0 : go to frame 0 of sequence structure. Run DAQmx write VI.

t=750 : go to frame 1 of sequence structure, set OV-5 to true.

t=5750 : go to frame 2 of sequence structure, set NV-2 to true and OV-5 to false.

t=9750 : go to frame 3 of sequence structure, set NV-2 to false.

 

You are writing the values to hardware only one time, so all of your local variable updates will not get to your hardware until the next iteration. (Though, by the end of the sequence structure nothing has changed).

 

So, you must set the boolean value, write with DAQmx, wait, set boolean value, write with DAQmx, wait, etc... A state machine would still be my recommendation for this.

 

Also, take careful consideration into your timing. For instance, in your sequence structure OV-5 is set to true right as the 5000ms timer starts, and is set false in the next frame, so it stays true for approximately 5000ms. This may be exactly what you wanted, but I just thought it was worth pointing out.

 

0 Kudos
Message 4 of 7
(3,011 Views)

The switches will move and dependent on which values are set when it builds the Boolean array will determine what is sent to the digital outputs.  If you wish to have each state driven by the outputs, then make it a state machine rather than a flat sequence within your case statement.  Turn each sequence into its own case that points to the next case when it loops around again in the while loop.

Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
0 Kudos
Message 5 of 7
(3,004 Views)

That makes sense. So within the case structure in the state machine, each frame (or state I guess) would correspond to one of the frames in the current flat sequence? And when ignition==false, the state should include no timing elements, just the switches for manually controlling the valves?

(I apologize if these are dumb questions, I was made responsible for the VI for the project I'm working on without any previous LabVIEW experience)

 

Also, the end VI will have multiple sequences in addition to the one I already have in place, and if I'm understanding correctly, the end result should just be a state machine with several frames (maybe 16 or so assuming 4 frames per sequence for 4 sequences, not sure on the number) that are all dependent on each other?

0 Kudos
Message 6 of 7
(2,997 Views)

What states do you require?  Individual state or a consistent Delay can be added after they are written each time to the DO.  Is there one that should always begin the sequencing?

Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
0 Kudos
Message 7 of 7
(2,991 Views)