LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to apply a threshold to some LEDs

Solved!
Go to solution

Greetings,

 

I'm relatively new to bigger LabVIEW projects and currently working on a pretty complex setup but I'm separately working on a smaller part of it before anything and this specific .vi should just turn some LEDs on when a certain threshold is passed. I currently have 3 LEDs that need to turn on when they pass their respective thresholds and each threshold is different. I used an existing forum response for reference on how to generate random example data on 3 different graphs in a singular setup (since it's similar to what I'm aiming for) and aside from this I looked up a tutorial on how to set thresholds but each time I run the code all LEDs turn on regardless of the set threshold (the thresholds in the file are random for testing, any threshold will do for now). I'm doing this within a while loop and the generated signals + the LED controls are all inside a singular event structure with only the first event (timeout) taking care of everything but I'm guessing that's where I'm encountering my issue. 

 

The data is currently just an example but later the data will come from a DAQ which will be retrieving readings from different sensors and these readings determine internal features of the system which is why these LEDs have to act together but react to different thresholds (in other words, calculations will be involved later on for this graphical representation)

 

In summary, system has 3 sets of data coming from 1 source and 3 LEDs with independent thresholds. Individual LEDs need to turn on when these thresholds are individually met.

 

Would also be nice to know how to make these LEDs turn off when the code stops running or to have a "clear out" case but that's a whole other step. Regardless, my current .vi is uploaded and hope anybody can help me out! Let me know if I'm missing anything or if any extra information should be provided.

 

Thank you in advance!

0 Kudos
Message 1 of 6
(190 Views)
Solution
Accepted by PDBSteenhuisen

Hi PDB,

 

on your code:

  • Why are "CHx LED" controls when you want to use them as indicators?
  • Why don't you use a simple comparison function to check for your limit thresholds? (What about ">="?)
  • Why do you wire float values to case seletors?
  • Did you notice those coercion dots? Do you know what they mean?
  • Why did you place a FOR loop in the timeout event?
  • Why are all threshold set to zero? Why don't you save senseful default values?
  • Why don't you use the AutoCleanup feature?
  • Why is there no stop button in the loop?

Suggestion:

You should place the threshold controls into an array of 3 elements: no need for the BuildArray node.

You should place the "LED" indicators into an array: no need for IndexArray…

 

You can use clusters instead of arrays as long as you use fixed number of elements you can apply math/comparison on numeric clusters too:

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Download All
Message 2 of 6
(161 Views)

Are you rally (really??) using LabVIEW 2009 or did you simply use "save for previous"?

 

In newer versions you can eliminate your cluster a visible property and just show the visibility checkbox.

 

altenbach_0-1757425716996.png

 

Message 3 of 6
(140 Views)

@PDBSteenhuisen wrote:

Would also be nice to know how to make these LEDs turn off when the code stops running or to have a "clear out" case but that's a whole other step.


Once the VI goes back to edit mode, the LED states are completely irrelevant. It is however important to reset them to a known state when the program starts, but this is only needed if they don't get updated immediately. As has been said, they should be indicators, not controls. After that you can configure the execute option to "clear indicators when called".

0 Kudos
Message 4 of 6
(133 Views)

Hey!

Thanks for your fast reply 🙂

 

1. CHx LEDs were controls instead of indicators based on the tutorial I was watching but I must admit I also didn't understand why but having them as indicators makes more sense now that I'm looking at your suggestion.

 

2. Simple comparison didn't work in my setup because when sending the output to the case selector, it doesn't accept that type of signal.

 

3. Just following the example I had.

 

4. I did notice the coercion dots but did not know what they meant, honestly. Just looked it up and yeah that checks out!

 

5. Combining tutorials doesn't always translate as well in practice, especially with limited knowledge in LabVIEW (been at it for less than 4 months and not full time either).

 

6. Thresholds were not set to 0.00 on my end. I only had CH1 at 0.00 and that was after trying out more thresholds. Decided to keep one at 0.00, one at a negative value and the last at a higher value.

 

7. I do sometimes but it tends to make things less aesthetic or just makes it messier sometimes with bigger projects. This .vi I wasn't applying my aesthetic at all and just dropped stuff basically anywhere.

 

8. Stop button was included in the bigger picture, this .vi was just for testing but yeah you're right on that one, my bad.

 

Regardless, your feedback was extremely helpful and I got it working right away. I wasn't too far off - just a lot of things I don't really know yet and have to learn. 

0 Kudos
Message 5 of 6
(126 Views)

Nice! Thank you. Solved the main issue but this is a nice extra feature I will implement too. I'm running LabVIEW 2025 but I just exported an older version for anybody using an older version (saw that was an issue in other community question). As for the old features, just following an older tutorial so probably some outdated stuff.

 

Again, thank you!

0 Kudos
Message 6 of 6
(125 Views)