From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Digital io program setup

I am pretty new to labview programming and am needing some direction. I am currently trying to setup a simple program to monitor the status of a few digital io. I need to start a timer when one input goes high and stop and record the time when the other input goes high. This needs to be looped in order to constantly monitor cycle time.I have included what I have done already. I currently only have the program running for one cycle and then stopping. Would anyone be able to help improve this?

 

Thanks

John.

0 Kudos
Message 1 of 3
(5,129 Views)

Hi John,

 

I've had a look at this for you and we can make this run continuously using a reasonably simple architecture for your code called the Producer-Consumer.

 

This whitepaper has some information on the architecture and how it works: http://www.ni.com/white-paper/3023/en/

 

I've created a simplified version of the project template you can get through the Getting Started Window on LabVIEW 2013 and attached that below. This uses a Queue FIFO to send messages between a master loop and a slave loop (producer and the consumer). In the producer loop you have an event structure which detects button presses of your front panel objects and sends an appropriate command to the consumer via the queue.

 

Here's a brief description of an event structure: http://www.ni.com/white-paper/3331/en/

 

In the consumer this reads the first message in the queue and uses a case structure to select the code to run based on the command. You can add in your functional code into each case depending on what you'd like to do. I've left this open for you so that you can adapt it to your requirements and it will be easier to expand moving forwards if you introduce extra functions etc. I've also linked the stop button press so that it will stop both loops on the same button press.

 

I trust that helps.

 

James

James P
0 Kudos
Message 2 of 3
(5,101 Views)

Hi James,

 

Thank for your swift reply. I will have a closer look at your suggestion and see how it goes.

 

Thanks again

John.

0 Kudos
Message 3 of 3
(5,095 Views)