LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to create a time-based transition in statechart

Hi,

I just started using the statechart module (8.6) and I'm having some difficulty.  I believe my statechart should be asynch because it will rely on discrete I/O for triggers and what not, but I'm not 100%. 

 

Some of my states have 2 possible transitions leaving the state:  1 is based on whether it gets a certain value from the hardware input, and I want the 2nd transition to occur if the proper value from the hardware input does not arrive withing a specified amount of time.  Should I create a timer function withing the action of the transition/state, or should the timer function be in the calling VI.  I made an initial attemp to create a parallel loop in the calling VI with a timer function that is activated by a statechart output and then sends an external trigger back to a statechart transition...but it's not working.

 

I searched the forum and couldn't find anything similar.  Any suggestions would be greatly appreciated; and if someone has done such a thing, some simple example code would be even better.

 

Thanks in advance,

 

Mike

0 Kudos
Message 1 of 5
(2,818 Views)
You could use the timer function within the state and have the action setup in such a way that if it has not received the hardware trigger or the specified time has not elapsed, then it comes back to the same state otherwise it transitions to the next state. Have a look at the Elapsed Time express VI. If you still have questions with this, be sure to post an isolated version of your code, and we can help you out.
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 2 of 5
(2,803 Views)

Adnan, thanks for the tip.  I may have been making it more complicated than it needed to be.  I've attached a simple program which I think is working the way I want it to.  The statechart is synchronous because I can't seem to get an asynchronous statechart to run (but that's another issue).  The statechart enters State 1;  if the input string is equal to 1111 within the Time Target input, it transitions to State 2;  if it does not equal 1111 within the Time Target input, the statechart terminates.

 

This is basically what I was trying to do, but I will attempt to make it a little more elegant in my full statechart.  Please let me know anyone see's any major flaws.

 

Thanks again.

0 Kudos
Message 3 of 5
(2,781 Views)

Hi Mike,

 

I looked at the program.  It looked like it would accomplish what you wanted.  The only thing that I saw was that you are sending a constant "0000" into the string value.  This was done on the block diagram of the main VI.  When I deleted this constant the program worked like you described it.  Did you have any other questions regarding this issue?

 

Message Edited by Jon S. on 01-07-2009 12:52 PM
Regards,

Jon S.
National Instruments
LabVIEW NXG Product Owner
0 Kudos
Message 4 of 5
(2,765 Views)
No more questions at the moment.  Thank again for your help.
0 Kudos
Message 5 of 5
(2,746 Views)