LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Repeating Previous Value

Solved!
Go to solution

I would like to create a VI that records position data and plots it in real-time.  I will be receiving 0 values for some data points, but I would like to filter out those zeros to either:
1. use the previous, non-zero value, or 
2. Or omit the zero from the waveform chart

 

Is there a recommended architecture or function that could do this? 

0 Kudos
Message 1 of 6
(3,558 Views)
Solution
Accepted by topic author LeroiVinncent

Things to consider:

Determine what "zero" actually is.  Is your data actually integer values where you can check for an exact zero value or is it represented by single or double datatypes?  If integers, you can use the "equals zero" comparison primitive.  If single or doubles, I would recommend using the "in range?" comparison so that you can define the zero value tolerance with upper and lower limits.  If you want to repeat the last know "good" value, your application will need some form of memory which could be accomplished by using a shift register or feedback node.  If you want the value to be omitted on the waveform chart but still keep the time axis consistent, you can feed the chart a "NaN" value.  This will only work for waveform charts of single, double, or waveform datatypes.

Message 2 of 6
(3,537 Views)

Hi Leroi,

 

I will be receiving 0 values for some data points,

Most often this is a problem of a badly designed receiver algorithm.

Does your data source really send those "zero" values?

 

but I would like to filter out those zeros to either:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 6
(3,533 Views)

Just to be thorough, you are absolutely certain that zero cannot be a valid data point?

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 4 of 6
(3,505 Views)

Hi Bill

Yes, the data point represents the position of a valve.  A zero value means the valve is fully closed, and I can physically see the valve is not closed.  Also, when using software that accompanied the valve, the zero value does not appear.

0 Kudos
Message 5 of 6
(3,482 Views)

Ah thank you.  I combined all the options you mentioned.  The data points came in the form of strings, which I parsed and converted into doubles.  Then I used a shift register and an "equals zero" Boolean to use the previous value if true, and use the current value if false.

0 Kudos
Message 6 of 6
(3,480 Views)