LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

controlling digital outputs with timing

Hello,

 

I am having trouble controlling my digital outputs based on using a timer to control them. My problem with this code is that when running case #2 the output comes on both the indicator and the h/w channel as expected but when the timer elaspes the indicator goes off the the digital output channel stays on. Maybe there is a better way or more common practise of controlling logic based on using timers? Any suggestions would be appreciated.

 

Regards,

John

0 Kudos
Message 1 of 6
(2,580 Views)

THe while loop inside a while loop is your problem. This is never a good idea. You need to make everything run in one loop or break it into two loops. That is why tou are getting stuck.

Tim
GHSP
0 Kudos
Message 2 of 6
(2,572 Views)

Hey Tim,

 

So for case #2 how could I turn on output one for the set time and then turn it off without using a while loop to exit? I'm not sure about how to split it into two while loops as I need to run different cases based on the case input wire. Any thoughts on best approach for this?

 

Thanks,

John

0 Kudos
Message 3 of 6
(2,567 Views)

You've got a major misconception of data flow and a very wrong use of locals. Your DAQmx Write is outside the loop. Obviously, the write will not happen until the while loop finishes. Put the write inside the loop and don't use ANY locals.

0 Kudos
Message 4 of 6
(2,564 Views)

Thanks for your comments, I know it's obvious that I have not used Labview much as I am a hardware guy. I see now what you mean about my write. So now it is inside all of my cases, what is the best way to show the ouputs as an indicators on the front panel?

 

Thanks,

John

0 Kudos
Message 5 of 6
(2,558 Views)

Here is an example of what I think you are trying to do. Ask any questions you need to ask and I will explain what I did. There are better ways to do some of the things but I wanted to show you an example of what I thank you are trying to accomplish.

Tim
GHSP
0 Kudos
Message 6 of 6
(2,545 Views)