LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

State Machine and Running Timer Help

Solved!
Go to solution

Hello,  I have created a program using the JKI state machine template to test a product.  The unit is initially powered and then the program continually monitors the current to see if it drops and then performs certain events.  One of the events is to wait a certain amount of time before the next event.  I have put an indicator on the front panel entitled "Stabilization Time" to see a live timer of this "wait time" but it does not work.  The program does wait the desired amount of time but it isn't displayed "live" on the front panel.  Anyone know what I am doing wrong?

 

My second problem is that when I start the test by pressing the "Start Test" button the front panel, the program becomes unresponsive.  When I use the "Stop" button on the front panel I expect the VI to shutdown but it does not do anything.  I am using an event structure to register to continually monitor and response to front panel buttons.  Any ideas?

 

I have attached my code.  Thanks,

0 Kudos
Message 1 of 3
(2,813 Views)

Think DATAFLOW, you have placed an "Time Delay" Express VI in parallel to your "Elapsed Time" Express-VI, both initialized with the same waiting time. Now, the Time-Delay will just wait until it is finished, so the Elapsed Time is called only once.

 

Change your code to something like this:

 

grafik.png

 

Regards, Jens

Kudos are welcome...
Message 2 of 3
(2,809 Views)
Solution
Accepted by ANON12345

Think about your States!!

 

You go from

Start Test to Cycle Test: Start

Cycle Test: Start to Cycle Test: Run

 

Then you enter an infinite loop of Cycle Test Run

 

In Cycle Test: Run

these are the states

PSU: Get Current
Time Delay: Delay >> 0.5
Cycle Test: Run

 

In PSU: Get Current in one of the cases you go back to Cycle Test: Run.

 

There is no escape.

 

  1. Rethink your state transitions.
  2. The JKI State machine only responds to events when in the "Idle" State. In the above loop you never go into the "Idle" state, so it is impossible to respond to front panel events. If you need to interrupt a sequence of states you need to put an idle in between them. Use a short timeout, so if there are no events, the transition is fast.
  3. Rather than use the time delay state, reset the timeout of the event structure instead.(see below) That way the UI is still responsive to clicks. If there is a click during the timeout you need to decide what to do with the states stored in the queue.

mcduff

 

Snap5.png

 

 

 

Message 3 of 3
(2,774 Views)