11-13-2020 11:36 AM
I am collecting data from a DHT11, photocell, and a range finder. The DHT11 and photocell determine if a room is "clean" or "dirty" and if it is occupied. The indicators are boolean led's on the front panel. If the room becomes "dirty" due to unfavorable conditions or because it has been occupied since it was last cleaned, I would like the "dirty" indicator indicator to stay illuminated until a wave in front of the range finder of less than 10cm.
I am new to LabVIEW and hope I explained this well. I have tried while loops and nested case structures without any luck. I attached my VI below.
Right now all indicators work as expected. I removed my attempts to hold the dirty indicator true until the wave is given.
The best way I can think to explain what I tried is:
if (dirty == true)
if (time > 0) //somehow loop waiting for time to be reset by range finder
dirty = true
elseif (time == 0)
dirty = false
11-13-2020 11:37 AM
here is the vi
11-13-2020 02:16 PM - edited 11-13-2020 02:32 PM
Can you reduce it to a simple simulation example?
(Who wrote this VI? Lots of questionable stuff that's difficult to decipher. Use of "bytes at port". Loops inside cases inside loops. Many parallel index array instead of one resized to several outputs, What's the string coming out of the read function? Shouldn't that be interpreted as 1D array? uninitialized shift registers, strange feedback nodes (probably auto-inserted due to accidental wire loops), dead code, "equal FALSE" is the same as "NOT", etc. All you probably need is a simple state machine, right?)
11-16-2020 09:31 AM
Thanks for your reply. First I should state I have no formal training or classes using LabVEIW which is likely apparent from the VI. Also, I am not working in any professional capacity. I really appreciate the feedback and questions you have provided and already have ideas to clean this up a little.
I wrote the VI and as I am new to LabVIEW, I am unfamiliar with all of the available tools. I was able to get this working with what I understand how to use so far. I am sure there are much simpler ways to write this VI. I'll try to address your questions as best I can.
--I am using "bytes at port" to open the loop when LabVIEW has something to read from an Arduino Mega 2560 I am using. Then the system is just to monitor surrounding environmental conditions until it is asked to stop.
--The parallel index array tools are simply because I don't know how else to parse the information coming from the Arduino string, relative humidity, temp ºF, temp ºC, range in cm, resistance measurement from photocell, and reads as "25, 77, 25, 245.18, 714"
--The shift register is used to hold the values from one loop iteration to the next to write the data to a file. I may not be using them correctly but it's all I understand.
--The strange feedback is indeed strange and was auto populated, I will try to the VI without it and see if it is unnecessary, I just assumed it was supposed to be there.
--The equals false is because I don't know how to write the equivalent of an "if, else" statement so I just asked for it explicitly. I have seen the NOT tool but haven't used it yet and will explore that to help clean this up.
--A state machine is exactly what I am trying to build.
11-16-2020 01:50 PM
@Niteondarun wrote:
--I am using "bytes at port" to open the loop when LabVIEW has something to read from an Arduino Mega 2560 I am using. Then the system is just to monitor surrounding environmental conditions until it is asked to stop.
The correct way in 99.9% of the cases is to define a termination character so the receiver can automatically tell that a complete message has been received.
@Niteondarun wrote:
--The parallel index array tools are simply because I don't know how else to parse the information coming from the Arduino string, relative humidity, temp ºF, temp ºC, range in cm, resistance measurement from photocell, and reads as "25, 77, 25, 245.18, 714"
You can resize a single "index array" for as many outputs as you need. No need to wire indices if you want the elements in order. Just drag down. Use a 1D array as type.
@Niteondarun wrote:
--The equals false is because I don't know how to write the equivalent of an "if, else" statement so I just asked for it explicitly.
A "equals false" (or NOT) has nothing to do with "if, else".