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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating delay to read input

Hello,

 

I am trying to give delay before i read input. In the attached code, as soon as component sensor senses, after some delay (3 sec in the code) i need to read reed contact input. If its high my result is pass.

 

But in the code when try by highlighting the execution option it works, but in auto run it continuously says fail.

Can somebody please help me with this? 

Download All
0 Kudos
Message 1 of 6
(2,755 Views)

You only have a wait in the start state case and I can't find any code that interacts with hardware (e.g. "read contact input"). can you explain in a bit more details how to use it, what we should see and what we are supposed to see instead.

 

For example, you are reading the "digital in " terminal before the wait, so any changes during the wait will not be reflected in the process data until the next iteration.

 

What determines the loop time if it is not in the "start" state?

 

Seems all a bit convoluted. I bet that if you would structure the code a bit more logical, things would fall into place.

0 Kudos
Message 2 of 6
(2,741 Views)

I am checking this code by manually giving the input in front panel via Boolean array.

 

For example, you are reading the "digital in " terminal before the wait, so any changes during the wait will not be reflected in the process data until the next iteration.

This might be the problem in my code, where should i connect "digital in"  to have the output as expected

 

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

How about creating a separate state for the delay?

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

Separate delay works. in the same code cycle time is not being updated. What might be the reason for this?

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

@suma_n wrote:

Separate delay works. in the same code cycle time is not being updated. What might be the reason for this?

You have two indicators named "cycle time".

  • One is visible on the front panel, but not connected to any code. This one will never update!
  • One is outside the visible FP area, has the wrong representation, but is connected to the code. This one will update IF the surrounding case structure is true.

 

It is generally a very bad idea to have two front panel elements with the same name. If you want them to show the same label use the caption instead.

0 Kudos
Message 6 of 6
(2,672 Views)