LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Waveform Chart Does Not update correctly

I am trying to display a voltage signal from a MCC USB-201 DAQ and display it.  I also wanted to make it so I could control how much time the x-axis spans.  I found a code which did this using property nodes and case statments and then modified it to my parameters.  The problem I am encountering is two fold: 

 

1) The way the graph updates causes it to look like a square wave.  Where when it updates it seems to grab a value and plot it and the rest of the time it plots zero.

2) It also is not updating the value that is being sent to the chart.  The data indicator outside the case structure seems to update with each iteration of the loop, but the data2 indicator which reflects the value of the chart only updates once. 

 

I have tried messing around with removing the case structures, but then the x-axis doesn't update the way I want.  Any ideas would be appreciated. I feel like I am missing something obvious.  I have attached my code.  I also have added in a two element array of random number which can be wired into the data line since you don't have access to my DAQ.  The voltage is being read as a Analog 1D DBL NChanels 1 Sample.  Thanks.

0 Kudos
Message 1 of 5
(5,539 Views)

I think I can explain some of your problems.  But, more important, I can make a suggestion (which you've actually started) to help you debug this yourself.

 

The problem isn't DAQmx, it is plotting.  Make a copy of this routine, get rid of the DAQmx calls, and substitute the "Generate random data" (which you've started already).

 

Another suggestion is to think about What Am I Doing?  What you want to do is (a) Initialize the Plot, (b) go into a loop where you Generate and Plot Data, (c) have a condition (which is usually done with a Stop control, for good reason) where you Stop the loop, and (d) if you need to restart, have a second "Do This Multiple Times When I Say To" loop that surrounds everything.

 

Incidentally, every function that NI gives you with an Error Line should (except in rare cases) have the Error Line wired to it.

 

You (probably) don't need or want to wire X-Scale Offset -- when you clear the History, I think it will start with the first Sample Point.  [Post your revised Demo program following my suggestions, and if I'm wrong about this, I'll figure out the fix for this]  Note that your DAQmx functions are not outputting Waveforms, but arrays of DBL with no time information in the data.

 

Bob Schor

0 Kudos
Message 2 of 5
(5,522 Views)

Bob, 

Thanks for your reply.  First off I know that I am only getting an DBL array with no time data.  The name of the VI was based off of previous iterations on another VI which had more to do with logging time values that what I am trying to do.

 

 I stripped it down to create my data using the random generators.  Here is where I start to get tripped up.  If I just create a chart and wire directly too it (Chart 3) the plot looks like what I want and is what I think you outlined in your original post.  The only issue is that it only shows 2 minutes of data at a time. I need to be able to extend this. When I try to replicate that using property nodes like in chart 2 I can’t even see where the data is being plotted. Also when I remove the x offset/multiplier from the property node for the original chart which sort of worked it no longer updates. 

 

I have been experimenting with many different values and settings trying to understand the how changing different property nodes, timing settings, loops, etc affect my waveform chart and while some of that has been very helpful in growing my understanding of how waveform charts work, I feel I am missing something important.  Let me know what you think.  Thanks. 

 

 

0 Kudos
Message 3 of 5
(5,466 Views)

Well, that's just a convoluted mess! Maybe you could clarify some things.

  • You did not mention "waveform chart 2" what' its function since you seem to be clearing it as fast as possible. (it is not clear what happens first, the clearing of the history or the writing of the data. Race condition!
  • Who operates the boolean? And what should happen if they do? What should happen if they don't?
  • What is the purpose of the shift register resized to height=2? Seems unecessary.
  • You are building a 2D array for the graph. Do you want two traces or one. Feeding a 1D array will concatenate the new data to the old in a single plot, meaning you get two time points per iteration. If you want two traces with one point each, you need to use a cluster (or a transposed 2D array with one column).
  • Your x-scale definition is only approriate until the history buffer fills, at which point the oldest time gets discarded and new ones added.
  • Do you want absolute or relative time on the axis?
  • Your VI cannot be stopped.
0 Kudos
Message 4 of 5
(5,452 Views)

To clarify things I started with a VI I found on the forums (I have attached that VI below it is called Time Tab).  The boolean control, shift register size and the fact that there is no stop button what a program choice made by someone else so I can't say why they are there.  Take that up with original author.  All I know is that if I take out the boolean/case structure the plot no longer works properly.  It just flashes green.  So I am trying to understand the mechanics behind what I want to do and see what I can come up with.

 

I am collecting data from 8 sensors using a MCC USB 201 DAQ.  I have been bringing that data in as Multiple Channel Single Sample 1D Array.  I want to display each channel on the graph as Plot 0, Plot 1 and so on.  When I added my DAQmx code to accquire the signals into the Time_Tab VI (which is the Logging Time VI on the original post) it was plotting what appears to be a square wave.  Which based on your comment below is because I am feeding it 1D array and it is concatinating.  You mentioned using either a cluster or transpose 2D array.  I tried the 2D array and now I am getting the multiple plots that I was hoping to see, but the shape still seems that it is plotting zero in between actual values.  I should be seeing a mostly straight purple line since my sensor values are not really fluctuating from 0.998 much.   FYI I only have one line actually reading data so the others are at zero. 

 

Capture.PNG 

 

 I want absolute time and that is what should be displaying on the charts.  The main problem I have is adjusting the settings so that I change how much time is displayed on the charts (ex. 3 min or 5 min of data on the x axis).  I figured it had something to do with the history buffer, but I have been unable to figure out the settings related to this to make that work other than using that other person's VI which still doesn't do exactly what I was hoping.  

 

Bob suggested I didn't need the x-offset/multiplier so I took it out and Chart 1 stopped filling with data.  I would see what appears to be the first point and then nothing else.  I decided to try this outside of the case structure on chart 2.  I was also playing around with the history value and a few others  to understand it better.  Unfortunately I cannot show or easily outline all the different combinations/values of the property nodes I have tried on this chart.  Suffice it to say that I did not make much progress.  I have primarily only used Labview with NI DAQs and Express VIs so I am still wrapping my head around the more basic mechanisms of Labview so bear with me.

 

0 Kudos
Message 5 of 5
(5,427 Views)