LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

state machine

hello everyone,

I'm new to labview (i have Labview 2019) and I'm working on small project which is reading holding register program of a PID regulateur using modbus library throught serial connection RS485, i want my program to

1 to verify that there is indeed a machine connected and display "machine connect" message

2 to verify the machine address (because later i will be contrilling two machine

3 read the holding register for the first task i created a connect button i tried to work with states machine but the button is not working i know i made a mistake somewhere but i cant seem to locate it I'm hoping you guys can help me.

i have attached the code below.

thanks in advance

Download All
0 Kudos
Message 1 of 5
(936 Views)

What exactly is not working? Did you try to debug your VI using the Highlight Execution?

Lucian
CLA
0 Kudos
Message 2 of 5
(931 Views)

currently my problem is

when i push the button and althought my machine is not connected it display machine connected message 

0 Kudos
Message 3 of 5
(890 Views)

That doesn't make sense.

 

Your VI compares the 0th index of your Modbus Read to the value of 1.  By the way, it is a bad idea to compare floating point numbers for equality.  Two numbers that might look the same might not be *exactly* the same.

 

If your Modbus Read didn't work, then you'd get an empty array, and the zeroth index would become the default value of 0, once you try to index out its value.

 

You could also check the value of the error wire to see if you have any errors when you try to communicate with your device.

 

By the way, you really don't have a state machine.  It looks like you do.  You have two enum values that say "Connect" and "Stop".   Those really should be turned into a Type Definition.  But you never do anything with the value of that enum when it comes out of the shift register on the left hand side.

0 Kudos
Message 4 of 5
(866 Views)

@RavensFan wrote:

By the way, you really don't have a state machine.  It looks like you do.  You have two enum values that say "Connect" and "Stop".   Those really should be turned into a Type Definition.  But you never do anything with the value of that enum when it comes out of the shift register on the left hand side.


So you're saying it's a Fake State Machine? A Faux Machine? 🙂

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 5
(815 Views)