LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

state machine problem

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, in order to establishe the connection between my program and the machine i created a start button my goal is to run the the program through this button instead of the traditionl run vi i tried to work with states machine but the program freez once i push the start button and the others button stop working i know i made a mistake somewhere_( in the visible property node button most likely ) but i cant seem to locate it I'm hoping you guys can help me.

i have attached the code below.

thanks in advance.

0 Kudos
Message 1 of 9
(1,658 Views)

You have an event structure buried inside a case structure.  And it's Start Value Change case is set to the LabVIEW default of Lock Front Panel Until Event Case Completes.   Also Connect/Disconnect Value Change

 

Read Caveats and Recommendations when Using Events in LabVIEW - LabVIEW 2016 Help

 

The problem is if you hit one of those buttons, it locks the front panel, but if that event structure never gets to be executed because of the flow of your state machine, you'll lock up your VI.

 

A simple fix *might* be to set those event cases to not lock the front panel.  But in general, the VI architecture should be such that the event structure gets handled frequently no matter what state you're in.  That means not burying them in a case structure and bring them up a level or two.

Message 2 of 9
(1,609 Views)

hi there thank you for helpping me i tried what you suggested on a more simple block diagram i unlocked the front panel and it worked however the start button is still not working.

i have attached the code below

0 Kudos
Message 3 of 9
(1,562 Views)

I can't comment on the start button now.  But I do see a huge problem with your queue.

 

When the timeout case of the event structure runs, since it doesn't wire through the queue reference, it will replace it with an empty reference and your queue will never run again.  Right click on those tunnels on the event structure and uncheck "Use Default if Unwired".

0 Kudos
Message 4 of 9
(1,533 Views)

OK donne is this correct ?

0 Kudos
Message 5 of 9
(1,526 Views)

That fixed the wiring problem.  Is it working correctly now?

0 Kudos
Message 6 of 9
(1,512 Views)

well its not blocking anymore and its connected to the machine but it doesnt read my register value 

0 Kudos
Message 7 of 9
(1,492 Views)

Your Modbus register is only read once because it isn't in a loop.  It is in a flat sequence structure outside of the loop, and even that flat sequence structure is unnecessary.

 

Why didn't you put your Modbus read inside the loop?

 

 

 

 

0 Kudos
Message 8 of 9
(1,482 Views)

i guess i was trying to work with supvi which didnt work i spend the whole day wasting my time with it cuz i want my program to identify my machine through the unit ID which is add 01 then start reading the rest of registers adds cuz after this i will be reading add from two machine and i need to identify each of them to not mix the whole process 

0 Kudos
Message 9 of 9
(1,476 Views)