LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

master slave system with a que, que is changed without reason

I have two while loops, the first is to receive button events. These are then send to the other loop which controls a machine. But the case 'LogControl' should loop during execution. This works but a variable which is set, PowerState which can be PowerOn and PowerOff is changing during the states. The led should stay on. But instead it starts blinking.  I cannot find where the state is set to PowerOff.

 

It should do: State: LogControl, PowerOn -> State : LogControl, PowerOn.   But instead it does: State: LogControl, PowerOn -> State : LogControl, PowerOff ->  State : LogControl, PowerOn 

 

0 Kudos
Message 1 of 2
(2,398 Views)

It looks like you are building a State Machine (nice), but you don't seem to understand how to do it properly.  You also don't seem to understand how to use the Event Structure with Booleans.

 

Your State Machine appears to have the following States:  Start, Log Control, Stop, Power On, Power Off, Timer On, Timer Off.  You should probably add an additional State, Initialize (which you start in).  This will be rendered as a single Enum called State.  Note that these "State Machine States" are not necessarily the same as what I'll (mis-)label the Status of your system -- you have three Status indicators, one having three values of "Start", "LogControl", and "Stop", and two Booleans, "Power" and "Timer".  

 

We'll come back here in a minute, but first, the Event Structure.  This is used to "signal an Event", which here will be to place a State on the State Queue.  Booleans used this way should be set to Latch when Released (I notice yours are Latch when Pressed).  If you place the Control (say, Start) inside the Event that reads it (e.g. "Start": Value Change), when it is read, the "Latch" property will make it reset, converting it from an On/Off switch to a Momentary Push Button, something you might find more useful.

 

Your Slave (the While Loop) now only needs a single Case Statement.  For example, the Start: Value Change Event puts Start on the Queue.  The Slave "sees" the Start State and does whatever is appropriate (probably it puts Timer On on the Queue, followed by putting LogControl on the Queue).  Note that if you have Status indicators (such as "Power", "Timer", "State") that need to be initialized, you can put Initialize on the Queue just after you Obtain the Queue, outside the Master or Slave.

 

If you reorganize your code this way, you will probably find out that there are States that you don't need (and don't want) -- I suspect "LogControl" is one of these.

 

BS

0 Kudos
Message 2 of 2
(2,374 Views)