LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Running Slope Display on Front Panel

I am slowly building a vi that records and displays pressure from a pressure gage. Right now, it continuously reads pressure, then every minute it will write the pressure, time, and date to a text file. It also plots to a chart once a minute. I can post the vi later, but I can't access it from this computer.

 

What I need to do, is program it to calculate a running slope from the data points. I need some sort of cache that will hold the most recent 15 pressure readings, and use them to calculate the slope and display it. When a new reading is taken, I need the oldest pressure to be kicked out and the newest one added to be used in the calculation. Any ideas on where to start with this?

0 Kudos
Message 1 of 8
(3,900 Views)

queue with 15 elements.  15 element strip chart.  ... lots of ways


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 8
(3,897 Views)

Here is the vi that I'm working with. I looked at the queue functions (LV 😎 and I'm not sure how to wire them up. I'm a beginner LabVIEWer and this is my first program to build.

0 Kudos
Message 3 of 8
(3,871 Views)

A very simple solution uses a shift register, build array and array subset. as shown in this snippet.

slope.png


"Should be" isn't "Is" -Jay
Message 4 of 8
(3,864 Views)

Jeff,

 

I tried to duplicate the the block diagram you provided with one change. I moved the slope functions inside my case structure, so it would only calculate the slope off of written pressure values. I get no errors, but it produces a "NaN" (Not a Number) message in the slope and intercept displays. I feel like I'm missing something...

0 Kudos
Message 5 of 8
(3,800 Views)

Have you tried running Jeff's example as is prior to making your modifications? It would be helpful to know whether this problem is directly tied to the changes you made, or if it's a lingering issue with the original code.

0 Kudos
Message 6 of 8
(3,779 Views)

I know this is an old thread, but my work took me away from this and has brought me back around. Never did get it figured out.

 

Tim, I did try it exactly as Jeff has it. Then I made modifications and it still didn't work. The slope desplay still shows NaN. Also, It only reads/logs pressure one time, then the rest it plots a 0 even though there is actually pressure on the system. I've attached the most current version I have that includes suggested changes.

0 Kudos
Message 7 of 8
(3,692 Views)

Hi Cramezl, 

 

It may be that initially the array does not contain enough points for the Linear Fit.vi to interpolate the slope. Try taking a few aquisitions prior to entering the loop, just to populate the initial array. 

 

-N

National Instruments
Staff Certification Engineer
0 Kudos
Message 8 of 8
(3,676 Views)