LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Converting to state machine

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

Download All
0 Kudos
Message 1 of 17
(3,969 Views)

Try basics of LabVIEW and Design patterns.

 

http://www.ni.com/tutorial/7595/en/

https://decibel.ni.com/content/docs/DOC-36967]

 

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 2 of 17
(3,954 Views)

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?

0 Kudos
Message 3 of 17
(3,945 Views)

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.

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 4 of 17
(3,933 Views)

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!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 17
(3,932 Views)

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..

0 Kudos
Message 6 of 17
(3,921 Views)

Hi zezen,

 

for a state machine you need to define certain states.

What would be the states in this application???

 

I recommend a simple loop with some input and output arrays…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 17
(3,914 Views)

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.

Example_VI.png

 

 

 

 

Thanks
uday
0 Kudos
Message 8 of 17
(3,902 Views)

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.

 

Switch control.PNG

0 Kudos
Message 9 of 17
(3,890 Views)

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!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 17
(3,881 Views)