LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Converting to state machine

I have the code and it is doing what it is supposed to do. but it looks crappy. Would be great to have some suggestions on how to make it look good. 

As you can see, i have 8 case structures fo each switch/led combinations running in parallel. 

 

 

 

Switch_Control.PNG

0 Kudos
Message 11 of 17
(1,955 Views)

Hi zezen,

 

didn't I mention to remove race conditions?

- You should replace all local variables (or "value" property nodes) by wires when possible!

- Remove the classic Rube-Goldberg too: "IF TRUE THEN FALSE ELSE TRUE" 😄 (There's a palette full of boolean functions including a NOT!)

- Replace the ElapsedTime ExpressVI with a version able to handle the delay with reentrancy:

store new start time on rising edge of boolean input
output := boolean input
IF (delay > 0) AND (current time-start time > delay) THEN
   output := FALSE
ENDIF
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 12 of 17
(1,946 Views)

Thanks GerdW.

Just found out how riduculously stupid this was of me. Thanks

 


- Remove the classic Rube-Goldberg too: "IF TRUE THEN FALSE ELSE TRUE" 😄 (There's a palette full of boolean functions including a NOT!)

0 Kudos
Message 13 of 17
(1,940 Views)

For scaling to N values you need arrays. Express VI Elapsed time does not work with arrays, get rid of it:

First make one case without elapsed time vi: use Tick Count and shift register to store start time. Then convert everything to arrays. Since all get the same time, you do not need multiple Tick counts.vi.

There was a quick drop tool for fast conversion of controls, constants and indicators into array.  http://forums.ni.com/t5/LabVIEW/QD-Shortcut-Chage-To-From-Array/m-p/3073741#M877536

0 Kudos
Message 14 of 17
(1,924 Views)

@zezendapuss wrote:

Thanks GerdW.

Just found out how riduculously stupid this was of me. Thanks

 


- Remove the classic Rube-Goldberg too: "IF TRUE THEN FALSE ELSE TRUE" 😄 (There's a palette full of boolean functions including a NOT!)


There's a reason why it's called "classic".  😉

 

I remember reading about the silliness of comparing a Boolean to a Boolean a long time ago... and realizing - with a start - that it applied to me.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 15 of 17
(1,920 Views)

Hi,

 


@Alexander_Sobolev wrote:

Since all get the same time, you do not need multiple Tick counts.vi.

 

I am not sure i understand this, but all do not get the same time. All controls have to be timed individually. 

e.g. switch on LED1 for 30s, LED2 for 45s, LED3 for 10s at the same time the user toggles other LEDs independently.

 

I am not able to grasp how a single timing fucntion can do the above task in parallel.

 

0 Kudos
Message 16 of 17
(1,881 Views)

Elapsed time.vi saves timer value when you initialize it and compares current time with stored value. For all your channels current time (when you check) is the same - you can use single Tick count.vi - unlike elapsed time approach when each of its instances uses its own copy of Tick count . 

Stored start timer values and interval are your data, nothing prevents them to be array.

 

0 Kudos
Message 17 of 17
(1,863 Views)