LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Running Histogram

I'd like to create 4 separate running histograms selectable by tabs.  The part I'm struggling with is how I should have the histogram update...
 
The machine that I am monitoring does not have consistent time cycles.  The time cycles range from 21 seconds to 45 seconds, and if an operator takes a break, the time cycle can be up to 35 minutes.  Machine downtime can be hours at a time. 
 
So, I can't specify a time interval for which the histogram will update.  Is there a way that I can track a variable and update the histogram when this certain variable changes from 0 to 1? 
 
 
0 Kudos
Message 1 of 12
(4,375 Views)
Hi squirrel,

to detect changes of a variable you can use a shift register in your while loop and compare the actual value with the value from last iteration. Wire the result to a case structure and do whatever you want in the true case...
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 12
(4,365 Views)
Ah!  *slaps self in forehead again*
 
I must not have had enough coffee this morning..
 
Thanks!
0 Kudos
Message 3 of 12
(4,360 Views)
Ok, now I'm having some problems with the histogram itself.
 
I have the "Create Histogram" express VI connected to a waveform graph.  The signal only hits the histogram vi when the While-Loop allows for it.
 
Unfortunately, I'm only getting a flat bar going across the histogram. 
 
 
0 Kudos
Message 4 of 12
(4,354 Views)
Show us your code! 🙂 A VI is worth a thousand words! 😄
 
I really don't understand all you technical terms such as "...hits the histogram...", "...flat bar...", and I have no idea how a while loop can allow or disallow something. 😉
Message 5 of 12
(4,346 Views)
I have attached the VI.
 
I'm almost positive that I'm making this more complicated than it needs to be...
 
Ignore the "Flow Value" section.  The Test Result section isn't important either- except for "D."
 
Basically, I want to record the values of Test Result D in a moving histogram.  I ONLY want the histogram to update when "Robot Position 11 Monitor" equals "1."   That tag is the only variable in the entire machien that only changes once per cycle.  I want the histogram to update once per cycle.  So, I figure that the Case Structure with the While Loop will do that for me; update the histogram only when the robot is at position 11. 
 
I hope this makes sense.  I'm used to object-based programming, so this is quite a learning experience.
 
 
0 Kudos
Message 6 of 12
(4,341 Views)
I think the key point you have not understood in making the transition from text based languages to LabVIEW is data flow. LabVIEW can do OOP, but that is irrelevant to what you are trying to do. The loop inside the case structure will run as fast as the processor will allow, repeatedly adding the same point (Test Result D, first value) to the histogram until the stop button is pressed. Then the outer loop will run again and as soon as the Robot position 11 = 1, the same thing will repeat.

Fixes: 1. Get rid of the inner While loop. (The Point by Point Vis ahve an inner loop with a shift register to accumulate values).

2. Use the Histogram Graph output of the Histogrm VI. It does exactly the same thing internally as you do to connect to the graph. Open it up and take a look.

3. Use equality testing (Robot Postion 11) in real number with great caution. Due to finite precision representation in the computer, the number 1 could be internally represented as 0.9999999982 which is NOT = 1. Use the In Range and Coerce with suitable tolerances.

4. This is personal preference, but I like the In Range and Coerce primitive much better than the In Range express. It uses less diagarm space and the limit values are visible on the diagram rather than being hidden inside the config dialog.

5. The front panel was huge. Scrolling for 5 minutes to find the other controls does not make a very good user interface. You can put descriptive names on the tabs.

Lynn
0 Kudos
Message 7 of 12
(4,328 Views)
All you need to do is delete the inner while loop (inside the case structure) and it's stop button.
 
Right now, the inner loop spins at infinite speed while reading the same value from the input tunnel over ond over, and blocking iteration of the big while loop at the same time.
 
Then you should also add a small wait in the big loop (10-100ms) so the loop does not spin out of control.
0 Kudos
Message 8 of 12
(4,326 Views)
Fixes: 1. Get rid of the inner While loop. (The Point by Point Vis ahve an inner loop with a shift register to accumulate values).
I did that, and the histogram reset after plotting a single value.  I tried copying the pt by pt histogram VI into that, and yet it still does not accumulate values.

2. Use the Histogram Graph output of the Histogrm VI. It does exactly the same thing internally as you do to connect to the graph. Open it up and take a look.
Will do

3. Use equality testing (Robot Postion 11) in real number with great caution. Due to finite precision representation in the computer, the number 1 could be internally represented as 0.9999999982 which is NOT = 1. Use the In Range and Coerce with suitable tolerances.
In this case, it is True or False coming in from the PLC.  If I place a numeric indicator on it with 0.00000001 accuracy, it is still 1 or 0.  That's why I use it. However, your point is very valid and it was a good reminder, so thank you.

4. This is personal preference, but I like the In Range and Coerce primitive much better than the In Range express. It uses less diagarm space and the limit values are visible on the diagram rather than being hidden inside the config dialog.
I agree.

5. The front panel was huge. Scrolling for 5 minutes to find the other controls does not make a very good user interface. You can put descriptive names on the tabs.
I know; I did that on purpose so it would focus on the histogram for now.  I would never implement something like that for our operators... 
 
0 Kudos
Message 9 of 12
(4,318 Views)
Re: 1. Are you sure that you are feeding new data in on each iteration? With the VI you posted the data comes from a control. Unless you change the value of that control for each iteration, the loop will process the same data repeatedly (and as Altenbach pointed out much faster than an operator could change the control). I presumed that you had some mechanism for entering meaningful data which was not posted, but maybe that is where the problem is.

If you run with executiom highlighting on (the light bulb on the diagram toolbar), you can see what the program is doing including the values on the wires at each time.

Try that and let us know whether the data is changing.

Lynn
0 Kudos
Message 10 of 12
(4,313 Views)