LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with state machine

Solved!
Go to solution

hello everyine,

 

i am working on a state machine. i have seen some videos of the same and i need some assistance.

 

i have attched the  code below.

 

my issue is that i cant jump from the first case to the last one. 

 

after the first case is executed i want LabVIEW to check fot the  boolean control attached to the select function. i have used a xor gate for the operation. if the "TERMINATE" condition is satisfied i want it to go the last case to which  local variable is used to turn off the START LED.

 

at the moment i cant go to the last case. i want the code to keep on checking the condition, and whenever the user  presses the END button the the LED should turn off irrespective of the execution time. 

 

pl suggest ways to complete a task... am still a newbie 

 

Regards

 

Jalashwa

 

 

0 Kudos
Message 1 of 8
(3,229 Views)

Hi Sindhurakshak,

 

Can you explain what your code does in the form of state diagram? Can you tell me where is your state diagram stuck at?

 

One way you can start troubleshooting is by adding an indicator after the input of the shift register to see the input that is going into the selector terminal of the case structure. My guess is that your code may have transitioned to the ENTER OTP state.

 

You should refer to the link below on how to do a state machine or look at an example in the NI Example Finder (LabVIEW >> Help >> Find Examples >> Search keyword: State Machines):
http://www.ni.com/white-paper/2926/en/

 

The below link provides info on multiple possible transitions: http://www.ni.com/white-paper/3024/en/ 

 

If you want to trigger a state transition via user interface, this link should provide you some info:
http://www.ni.com/white-paper/2962/en/

 

Warmest regards,

Lennard.C

Learning new things everyday...
Message 2 of 8
(3,214 Views)

You should really start out by checking out this tutorial.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 3 of 8
(3,206 Views)

hey lennard

 

thanks for the ni papers. they really helped.

 

you were spot on. i was not shifting to the next case. 

 

i am made modifications to the design- removed some useless loops and logic gates. 

 

Sadly i still cant access the last case ie, TERMINATE. Hence i cant switch on the boolean control led.

 

Request you to please help me out

 

find the modified vi below

 

regards

 

Jalashwa

0 Kudos
Message 4 of 8
(3,170 Views)

You have no timeout on your evenstruture in the OPT case.

This way your program gets stuck on this event case.

wiring the timeout fuction will solve this problem

---

UnCertified LabVIEW Student
Mistakes are for learning, that's why suggestions are always welcome!
Message 5 of 8
(3,149 Views)

Here is a tip that will make your life a lot eaiser with state machines and LabView in general.

 

Learn how to use a TypeDef

 

In this case if all your Enum's were a TypeDef adding ot removing a state to your program is a lot simpiler. Because you only have to update one of the TypeDef and every instance if the Enum will be updated.

sbtd.PNG

========================
=== Engineer Ambiguously ===
========================
Message 6 of 8
(3,120 Views)
Solution
Accepted by topic author Jalashwa

Hi Sindhurakshak,

 

You're welcome. I believe the problem still lies on the Event Structure at the "OTP" state. I can suggest the following (let's say everything still ends up to OTP from what I understand from your current code):

 

Remove the select and create an additional Event case for "end" boolean switch. Place the enum for terminate in that case as shown below:
State 1.JPG
The above modification means that if "end" boolean switch value is changed (presuming that it will change to true), the event case will run the "end" event case which will then pass the "Terminate" enum value to the shift transition. Let's say that if "end" boolean button has not changed (meaning has not been pressed), It should run the rest as shown below:
state 2.JPG

state 2.JPG

state 4.JPG

 

I'll leave the "OTP" enum value in Timeout, presuming that you want the state to still run the "OTP" state when idle unless you press the "end" button to trigger the "Terminate" transition.  

 

Hope it helps

 

Warmest regards,

Lennard.C

Learning new things everyday...
Message 7 of 8
(3,073 Views)

hey lennard ,

 

thanks for taking so much pain to help me out .

 

i made some more modifications to my design and made sure that the event structure is the last case.

 

its working fine now 

 

Thanks a ton 

 

 

Regards

 

Jalashwa

 

0 Kudos
Message 8 of 8
(3,044 Views)