LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timing a case structure

Solved!
Go to solution

Why would you need local variables for this?

0 Kudos
Message 11 of 22
(2,406 Views)

Can you give me an overlay of the state machine?

0 Kudos
Message 12 of 22
(2,367 Views)

I have designed a state machine VI for my application as you suggested. However i am facing a problem.  I have three states mentioned :
1. Waiting for sensors
2. Sensor 1 triggered
3. Sensor 2 triggered

The IR sensors that I'm using stays ON for 2 secs, and when sensor 1 is triggered, i disabled the sensor 2 and incremented the counter and when sensor 2 is triggered, I disabled sensor 1 and decremented the counter.

The problem is that for state 1, how do I wait for both sensors 1 and 2? I tried giving it sequentially using 2 case select functions but that does not work.

I have attached my VI

Download All
0 Kudos
Message 13 of 22
(2,354 Views)

Could you also look at my VI above and suggest a solution ?

0 Kudos
Message 14 of 22
(2,353 Views)

Hello, 

 

Here's a simple solution. This implies that the state of the first "TRUE" statement will be outputed.  You should also put a time delay in the "Waiting for.." case otherwise your CPU will be a 100%.

 

trigger.png

Message 15 of 22
(2,342 Views)

This works when pir 1 is cut followed by pir 2 wherein pir 2 gets disabled, but does not work vice versa (probably due to the linear  nature of search 1d array)

0 Kudos
Message 16 of 22
(2,332 Views)

Ok, I took a look in the code and what you need is a queue state machine which allows you to add more then one state.

Message 17 of 22
(2,325 Views)

Could you throw in some more light on that?

0 Kudos
Message 18 of 22
(2,319 Views)

Here's an example (very simple) of the most basic kind of a queue state machine.  I suggest that you get familiarized with the queues instead of using the example below (which is using array for the queue).  I disconnected the typedef.

 

0 Kudos
Message 19 of 22
(2,313 Views)

I shall look up on queues, but the above vi doesnt seem to work

0 Kudos
Message 20 of 22
(2,302 Views)