09-09-2016 08:51 AM
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.
09-09-2016 09:00 AM - edited 09-09-2016 09:05 AM
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
09-09-2016 09:12 AM
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!)
09-09-2016 11:10 AM
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
09-09-2016 11:18 AM
@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.
09-12-2016 04:02 AM - edited 09-12-2016 04:03 AM
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.
09-12-2016 09:28 AM
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.