09-09-2016 07:06 AM - edited 09-09-2016 07:14 AM
Hey guys,
I would like to create a state machine form of the attached code.
I have 3 similar case structures and would extend to 7 similar case structure to form a byte and send it to serial port.
I am sure there is a more logical/elegant way rather than the haphazard form i have put it into. I am looking for a rough sketch of how to go about it.
Thanks
09-09-2016 07:17 AM
Try basics of LabVIEW and Design patterns.
http://www.ni.com/tutorial/7595/en/
https://decibel.ni.com/content/docs/DOC-36967]
09-09-2016 07:20 AM
No disrespect but i have observed you have a compulsion to paste tutorial links on each and every post.
You can easily refrain from commenting or suggest something concrete maybe?
09-09-2016 07:30 AM
hope tutorials will give clear idea than my own explanation.
if you have anything in particular we can help you out, if you need to use design pattern its always better to follow tutorials before proceeding.
09-09-2016 07:30 AM - edited 09-09-2016 07:31 AM
Hi zezen,
why do you want to use a state machine here?
What are your states?
Instead I suggest to use arrays and autoindexing loops to handle 7 inputs and generate 7 outputs…
While you refactor your code you should remove the race conditions too!
09-09-2016 07:43 AM - edited 09-09-2016 07:44 AM
Hello GerdW,
Thanks for your suggestions.
Basically i am trying to build a system of 8 controls (switch) and indicators (led) in which the user the toggles the Indicators, i.e. press control1 and indicator1 is switched ON, press control2 and indicator2 is ON.....
Additionally there will be an option of timing i.e switch ON indicator1 for 30s and/or freely toggle indicator2...
Now i dont know whether a state machine is required in this case since the toggle is parallel i.e. independent of other 7 controls and indicators..
09-09-2016 07:51 AM
09-09-2016 08:14 AM
Can you see below snippet and tell is this what smething you are looking for?
-Whenever you click on any boolean control the corrsponding LED indicator will be ON
-And for every 200mS index 2 indicator will be blinking.
09-09-2016 08:36 AM - edited 09-09-2016 08:37 AM
Hi Uday,
Thank you for your post. It is sort of similar with one major difference. Attached, please have a look. The code does the following:
- if delay x = 0, the switch toggles the Led x.
-If delay x > 0 (e.g. 30s), the Led x stays ON for 30s, while the other Leds can be toggled independently.
09-09-2016 08:44 AM
Hi zezen,
as you seem to know what you want to achieve all you need to do is creating the code for it! 😄
Create the code for one boolean switch, one delay input and one boolean output. Once it works as expected you can adapt it for arrays of inputs and outputs.
(I suggest to stay away from ExprtessVIs to learn LabVIEW much faster and to avoid problems with reentrancy…)
When you have specific questions don't hesitate to ask!