LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

statemachine: next state when true

I've got an analog value switching from 25 to 525 random at time.
I want to count each time the value goes from 25 to 525. Therefor I created a statemachine but
the problem is I can't switch to the next state. I use the greater than to get a true when the value
is above 100, in the next state the program has to increment by 1, en in the last state the value
must be less than 100 before switch to state 0.
 
The attachment is the code I got till now
 
Please help me on this.

Message Edited by Trabuca on 07-05-2005 05:21 AM

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

Ok, lets examine what you are doing vs. what you want to do. You have fed the output of the analog read to the selector of a "0,Default" or "1" case statement. What is going to happen with your case statement. Most of the time it will be in the 0, default state, occasionally (very occasionally, like probably never) it will get exactly 1 out of the analog read and advance to the other case. Additionally you have to wire something to every output of a case statement, even if it is to set it to output the "default" (a bad pratice, good programming requires that you try very hard to know what every output will be). You want the analog read to detect a <or>  than your preset values (which don't agree in the program with your written description). You want to move the < OR > out of the case, make it the deciding factor ( > 400 implies that everything else is less than 400) and then you will just have a T/F case. Inside you can wire the booleans to the T/F being passed in, with whatever logic to get the desired "states" for them. The trick, sometimes, is to write down, in simple terms, what you are attempting to do in a part of code, then go through the code, trying to see what will happen at each step.

Keep wiring, keep asking questions. The only truely "dumb" question is the one unasked.

 

P.M.

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 2 of 3
(2,521 Views)
Thanks for the tip.
 
What I have don now is that I putted a True/False case inside a State machine case. When the value is greater than 100
the true will lead to case1, when not, the false will lead to case 0 (where we were at that time). I used the STATEM~2.vi
found on the net. This is working well.
 
 
0 Kudos
Message 3 of 3
(2,518 Views)