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: 

Expressed Timer

Solved!
Go to solution

Hello All,

 

I am doing traffic light CLD example by using two different timer:

one with SubVI Timer, the other with expressed Timer.

The SubVI Timer is just modified expressed Timer by copying its block digram to

make a subVI.

The one with SubVI Timer works well, But the one with expressed Timer does not.

This confused me. Pls give a clue.

 

Thanks

 

Guoguang

0 Kudos
Message 1 of 5
(2,414 Views)

You'll have to give more details.  Saying "one works well and the other does not" doesn't tell us anything.  Tell us how they are behaving differently and why you think one is correct and the other is wrong.

Message 2 of 5
(2,406 Views)

Hi Ravens,

 

Thank you for your reply.

The one with SubVI timer works as well as solution given by NI.

But the one with express timer only works at beginning. After several

going through several states it just skips states with yellow traffic lights.

It is odd. If you can help figure it out I will appreciate it. Thank you. Guoguang

 

 

 

0 Kudos
Message 3 of 5
(2,398 Views)
Solution
Accepted by topic author elephant88

I see what you mean.  I think I know what the problem is.

 

With the Express VI, each instance of the Express VI is it's own instance.  So when you have a different set of code with a different copy of the Express VI in each state, it acts independently of the other cases of your case structure.  With Auto reset, and reset turned on, I believe the timer has run out in a given Express subVI before that state ever comes around again.

 

With your subVI, you only have 1 copy of it, and it is setup as non-reentrant.  The same subVI is being used by all states, so you never have a timer that is automatically reset and expired before it is used again.

 

With the express VI, you will need to use the reset and auto-reset inputs appropriately so that the express VI is only reset upon the first time loop iteration into that state at that time.  You don't want it to auto reset.  That is why you are missing the Yellows.  They are the shortest execution time.  Once they run, they automatically reset reset, and that short period of time as already passed again and expired while the longer red and green cycles have gone by.  So it barely executes and resets again.

 

You could probably restructure your code a bit more.  Most of the code in each case is identical.  The only differences are what parts of the cluster you are changing, the time, and the next state.  So if you only put that stuff in the case structure, and put the decision making code and the things like the timer outside of the state case structure, you could have greatly reduce the amount of duplicated code.

Message 4 of 5
(2,395 Views)

Thank you for your feedback and suggestions.

Now I have figured it out. Thanks a lot. Guoguang

 

 

 

0 Kudos
Message 5 of 5
(2,388 Views)