LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

StateCharts and Wait Timers

Continuing with my StateChart work, I seem to have hit a little snag. 

My second version of a vending machine has a cooling cycle added to it.  The cooling cycle simulates cooling by reducing the temperature by “1” every second.  Once the temperature has reached the set point, there is a transition to an idle state.  In the idle state, the temperature is increased by 1 every second. 

For some reason now there is a huge lag in picking up my control events.  I tried adding some wait timers to all my static reactions to make sure there was ample processor time for all.  But that didn’t seem to make any difference at all.  I can think of maybe a few other things to try and I’ll update this thread if I find something that works.  But if someone can have a look at what I’ve got so far and let me know if I’ve missed something I’d appreciate it.

 

 

 

---------------------
Patrick Allen: FunctionalityUnlimited.ca
0 Kudos
Message 1 of 5
(3,112 Views)

I think I may have discovered at least a part of what was going on. 

Because the event structure timeout is set to 500ms, my Statechart will only receive the Null Trigger every 500ms.  I supposeI kind of missed understanding that at first.

That still doesn’t explain why I can’t have any wait timers in a state though.  This is something I’ve often done using a traditional state machine.  Especially if the default transition is back to the same state.  (ie. Static Reaction)

In this version of the code I’ve taken out the wait timers, and the responsiveness is back.  Although a 500ms wait timer would probably not be good here, because you can input way more than a dollar.  In fact if you keep putting in more money a timeout will never happen and none of the transitions will ever see a Null Trigger.   I suppose I have some more work to do before I can figure out how to implement this tool in my typical projects.

I suppose the only way to have a state “wait” for a period of time would be to send an output to an external loop that would send a trigger when the waiting was complete. 

The code I’m posting here has also got some weird problems on my PC.  Whenever I do anything to the StateChart Diagram, the whole thing jumps to the left.  If I make a change and commit by clicking OK, everything jumps a few steps to the left and down.

I don’t know what I did to cause this behavior.  Perhaps turning off Autogrow on all the structures had something to do with it?  Maybe I resized them to smaller than they should be?

I’d like to know if this code does the same thing on someone else’s computer.  As well, I’d really like to know how to prevent this from happening.

---------------------
Patrick Allen: FunctionalityUnlimited.ca
0 Kudos
Message 2 of 5
(3,104 Views)

HI Patrick,

I don't have the SC loaded so I can only share my impresion.

A wait in a state of a SC will stall the entire SC. I understand the SC this way;

The SC Toolkit is a tool that allows the design and development of nested case structures using a UML type interface. When you put a SC in a loop each iteration results in it executing one of the cases.

So when you are hung in a state (case) the rest of the SC is hung. If you read the detailed help for the SC you will see that it says that sub-SC will execute "concurrently" rather than in parallel. So SC's with sub-SC's can be thought of as "Queued State Machines" where a single SM implements multiple operations by sequencing all of the operations. THis subtle difference between SC's and SM's is what has kept me from trasistioning to the SC. Virtually all of my applications require parallel operation and mutltiple SM are great at this. Before I can transition to the SC, I will have to subject myeslf to a "paradigm shift" when I do my app architectures.

Back to your desire to impelement a wait:

If you add Wait_Time_Start, Wiat_Time_Duration, and Wait_Time_Active_Flag, you should be able to mod the SC to do the waiting explicitly in the SC diagram.

I hope this help,

Ben



Message Edited by Ben on 04-26-2008 10:03 AM
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 3 of 5
(3,070 Views)
Hi Ben,

Thanks for the reply.  

The light of understanding got a little brighter after I went home and played around a little more last night.  I believe it basically boils down to me trying to do something the SC isn't meant for.  

I had read about the way sub-SC executed code.  Now I have a much better understanding of what this means.  
---------------------
Patrick Allen: FunctionalityUnlimited.ca
0 Kudos
Message 4 of 5
(3,063 Views)
Hey Patrick, I responded in the other thread to the jumping issue which we've been able to replicate. I'll try to keep the discussion of/updates on that issue over here so this thread can be about the wait timers, etc.

Thanks,
Nick

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