01-27-2014 12:30 AM
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
Solved! Go to Solution.
01-27-2014 01:10 AM
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
01-27-2014 01:22 AM
You should really start out by checking out this tutorial.
01-27-2014 07:52 AM
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
01-27-2014 09:08 AM
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
01-27-2014 12:59 PM
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.
01-28-2014 07:24 PM - edited 01-28-2014 07:26 PM
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:
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:
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
01-29-2014 06:57 AM
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