LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Data Not Sampling / Displaying Correctly

Solved!
Go to solution

I'm building a vitals monitor and I can't get my graphs to show enough data when I ask them to dynamically change the time displayed.  I can show beautiful heart and respiration rates if I leave timing alone, but when I try to play with programatically changing the time displayed on the X axis, the amplitudes don't match.  (The peaks and valleys get lumped together if they happen to near each other.) In the attached image the left set of graphs show the data looking nice, but for only 5 seconds at a time.  The right set shows not so nice data with a user defined display time.  My question is, how can I get the looks of the left hand graphs (good peak / valley resolution) with the timing functionality of the right set (user defined X-axis)?  Also attached is the VI.

 

Thanks!

Download All
0 Kudos
Message 1 of 9
(3,302 Views)

I recommend you Drastically Simplify.  Choose one channel, and concentrate on getting one of its plots working the way you want.  In its present state, there is so much going on in your diagram, with little documentation to help the viewer.

 

When considering taking and displaying bio-data, some important factors to consider are the following:

  • The sampling rate of the data acquisition (not that obvious from your Block Diagram, though I confess I didn't spend a lot of my time trying to figure it out).  "Smooth" data displays generally result from more data points, while "straight-line blocky graphs where peaks and valleys merge" are often a sign of gross under-sampling.
  • Your X axis appears to be "clock-time", as opposed to "elapsed time".  Did you mean to do this?  If so, why?  [It may be relevant to know "this peak happened at 9 pm" as opposed to "this peak happened 15 seconds after that peak", but that's a tad unusual].
  • There are lots (far too many) of Express VIs here.  This is often (but not always) a sign of "I don't understand what I'm doing nor how to do it, but someone else gave me this shortcut ...".
  • A lot of Local Variables in a Block Diagram is usually a sign that the Programmer does not understand the Principle of Data Flow, a key element of LabVIEW ("Data flows through wires").  Strive for having zero (0) Local Variables in your Block Diagram.  Learn to use Shift Registers.

Bob Schor

 

0 Kudos
Message 2 of 9
(3,255 Views)

Hi Bob,

 

Thanks for the advice.  I'm still relatively new to LabVIEW, so I am still getting the hang of data flow programming. The variables I'm using here are to keep the block diagram from looking like a jumbled mess.  To answer your second question, yes, I do want it as clock time.  This will hopefully eventually be used on rats, and we will be tracking vital signs in comparison with drug tests.  We will know we give X drug at Y time, so comparing the vitals vs. clock time will be most useful for us.

 

Follow up question for you: I understand that more data points = smoother data.  However, I can get nice smooth graphs using my current sampling rate.  These can be seen on the left bunch of plots.  When I try to fiddle with the X (time) axis some of the data appear to be lost in the mix (right plots.)  If this is indeed what is happening, how can I keep all the data while still being able to change how much time is shown?  Is there a way to set the X axis scale on a waveform?  I tried changing the chart history length, but that didn't do anything.  Any ideas?

 

Thanks

0 Kudos
Message 3 of 9
(3,238 Views)

Since you are (relatively) new to LabVIEW, you need to learn about mixing Science and Engineering.  The Engineer Builds, the Scientist Experiments.  You want to Build a Chart and control it as part of a Big Fancy Instrument.  So here is a Science Experiment -- build a really tiny, simple Test system and play with it to learn how Charts work.  Here's an example:

Chart Example 2.png

The two Block Diagrams on the left come from the Signal Processing, Waveform Generation Palette.  The 1000/1000 cluster is the "sampling information", 1000 samples at 1000 Hz, or 1 second of data at 1 KHz.  The first block makes Gaussian noise with an amplitude of 0.2, the second makes a 10Hz sinusoid with an amplitude of 1 (quick -- what is the Signal-to-Noise ratio?).  Add them together and plot on a Chart.

 

See the little symbols on top of the picture?  This identifies this as a LabVIEW 2016 Snippet.  If you open LabVIEW 2016, do a Ctrl-N to get a blank VI and Ctrl-E to get to its Block Diagram, you can drag this picture from a Web Browser into your Block Diagram and it will become LabVIEW Code automagically.

 

I've taken the liberty of adjusting the Properties of this Chart so that (a) it displays time in H:M:S (without the date) and (b) has a width of 1 (second, the unit of Time measurement).  Run the code, see the plot, then go into the Properties for the Chart and "fiddle" with the Display Format settings for the Time Axis.  Note the difference between Absolute Time and Relative Time.  You might see that the time starts at a weird place, like 7pm -- I'll explain that in a minute.

 

Now go to Scales and look at the Scale settings for the Time axis.  Make small changes in Minimum, Maximum, Offset, and Multiplier until you understand what they do.

 

If you want to programmatically change the scale, you need to learn about Property Nodes.  But first become comfortable with the graph.

 

So why 7pm?  This is because you are generating Waveforms, but are not specifying the Start Time, so 0 is used.  TimeStamps are measured in UTC, with 0 representing 0 UTC on 1 Jan 1904.  If you are in a GMT-5 Time Zone, 0 UTC = -5 = 19:00 your time.

 

Bob Schor

0 Kudos
Message 4 of 9
(3,223 Views)

Since you are (relatively) new to LabVIEW, you need to learn about mixing Science and Engineering.  The Engineer Builds, the Scientist Experiments.  You want to Build a Chart and control it as part of a Big Fancy Instrument.  So here is a Science Experiment -- build a really tiny, simple Test system and play with it to learn how Charts work.  Here's an example:

Chart Example 2.png

The two Block Diagrams on the left come from the Signal Processing, Waveform Generation Palette.  The 1000/1000 cluster is the "sampling information", 1000 samples at 1000 Hz, or 1 second of data at 1 KHz.  The first block makes Gaussian noise with an amplitude of 0.2, the second makes a 10Hz sinusoid with an amplitude of 1 (quick -- what is the Signal-to-Noise ratio?).  Add them together and plot on a Chart.

 

See the little symbols on top of the picture?  This identifies this as a LabVIEW 2016 Snippet.  If you open LabVIEW 2016, do a Ctrl-N to get a blank VI and Ctrl-E to get to its Block Diagram, you can drag this picture from a Web Browser into your Block Diagram and it will become LabVIEW Code automagically.

 

I've taken the liberty of adjusting the Properties of this Chart so that (a) it displays time in H:M:S (without the date) and (b) has a width of 1 (second, the unit of Time measurement).  Run the code, see the plot, then go into the Properties for the Chart and "fiddle" with the Display Format settings for the Time Axis.  Note the difference between Absolute Time and Relative Time.  You might see that the time starts at a weird place, like 7pm -- I'll explain that in a minute.

 

Now go to Scales and look at the Scale settings for the Time axis.  Make small changes in Minimum, Maximum, Offset, and Multiplier until you understand what they do.

 

If you want to programmatically change the scale, you need to learn about Property Nodes.  But first become comfortable with the graph.

 

So why 7pm?  This is because you are generating Waveforms, but are not specifying the Start Time, so 0 is used.  TimeStamps are measured in UTC, with 0 representing 0 UTC on 1 Jan 1904.  If you are in a GMT-5 Time Zone, 0 UTC = -5 = 19:00 your time.

 

Bob Schor

0 Kudos
Message 5 of 9
(3,223 Views)

Hi Bob,

 

I took your advice and am now working on just one channel of data, in this case the heart rate.  There is still the issue of data points lumping together and getting lost when they are converted to scalar values.  In the attached image the left plots are raw signal from my pulse oximeter and the right are a signal that has been filtered to biological frequencies (0.5 - 4 Hz.)  The top plots are unadulterated signal right out of the data acquisition (or filter) and the bottom plots are my attempt at converting to scalar values.

 

As you can see in the bottom plots there are far fewer data points than the top.  On the top it is almost hard to see the trace line for all the plotted points.  Why does the bottom have so few points?  Where am I losing data?  I've tried running the loop anywhere from 1 - 1000ms and it doesn't seem to make a difference.  Any ideas?

 

Thanks

Download All
0 Kudos
Message 6 of 9
(3,192 Views)
Solution
Accepted by topic author athiggins

I am "allergic" to Express VIs, particularly those whose function I don't know or understand.  What are you trying to do?  I see a Dreaded DAQ Assistant that seems programmed to deliver 1000 points at 3.3KHz continuously, so every third of a second you get 1000 points.  [So what is the 100msec Wait doing?]  You seem to have a filter that has a band pass of 0.5 to 4 Hz.  So why are you generating data at 1KHz if you only want signals up to 4 Hz?

 

Something is really wrong here -- it could just be I don't "get" what you are trying to do, but it can also be that you don't understand what you are doing.

 

I'd be interested in reading what you think you are doing, not from how you trying to do it, but what you are trying to do.  For example, "gather xxx data at a sampling rate of yyy, display the raw data, filter the signal using a band-pass filter from A to B Hz, and display that result, as well".

 

Keep it very simple.  Don't worry about Converting Plots or other fancy things, just create an array of data points, filter them, and plot them.  Also, while you are avoiding the Dreaded DAQ Assistance, also keep your distance from its Evil Twin, the Dynamic Data Wire (those are the weird wires connecting your Express VIs).  Stick with "ordinary" wires that convey things you understand, like numbers, arrays, etc.  If you want to get fancy, a Waveform is OK ...

 

Bob Schor

0 Kudos
Message 7 of 9
(3,186 Views)

You think you have the same sample rate between the charts in your first message screen shot.  But you obviously have a different number of points in the same period of time.

 

Why?  Bob has already told you that you should need to avoid Express VI's and blue dynamic data wire.  Sure it makes things easy to connect and the VI starts to work right away.  But it hides the details of what is really going on.  And while it makes it easy for newbies to get it to work, that lack of understanding makes it really easy to get it wrong.

 

You are collecting 1000 samples at 3300 Hz.  So about 1/3 second.  (Why 3.3 kHz?  That is a weird number to choose.)  When you send that blue wire directly to the graph, you are sending 1000 data points at a time and you have a nice smooth graph.  But you also split the wire and send it through the "From DDT" express VI.  That is where your "clumping" is happening.  Not really clumping, but you have it set to extract just one scalar value out of those 1000 points.  I don;t know if it is the first or the last, but you've collected 1000 data points only to throw away 999 of them.  Effectively changing your data rate to 3.3 Hz instead of 3.3 kHz.  If you double click that express VI, you can get it to go to an array, or a waveform, or a number of different datatypes.

 

I see something else odd.  Why are you putting the new data point to the front of your array on the Build array?  I see you proceed to flip it after that.  But that happens on every iteration.  So you aren't building the array correctly, but effectively putting it one end of the data this iteration, the other end of the data the next iteration.  Back and forth forever.  That makes the filtering and display of that data stream completely worthless.

0 Kudos
Message 8 of 9
(3,182 Views)

Hi Bob,

 

Thanks for your help.  I have taken your advice and gotten rid of as many Express VIs as I could.  The only ones left are to acquire my data and turn on/off the acquisition device.  Everything out of the acquisition box is quickly converted to "normal" datatypes.  My updated program is working quite well.  Thanks for the push in the right direction.

 

Andrew

0 Kudos
Message 9 of 9
(3,148 Views)