09-24-2021 02:56 PM
I've seen a how-to from NI on sending date time information to a chart, but not a graph. When I try to build an array with a dbl type and a date/time type, obviously I get an error.
Can anyone shed some light on such a simple task? Thanks
Solved! Go to Solution.
09-24-2021 04:46 PM
Hi, David.
Bob Schor
09-25-2021 07:19 AM
Do you have one time value? If you have one time value t0, one data array [Y], and an explicit or implied time increment dt, you have the essential elements of a waveform datatype. Wire those elements into a build waveform node. Connect the waveform to a waveform graph terminal. Right click on the graph and deselect 'Ignore Timestamp'.
09-25-2021 09:33 AM
Oops, Doug's answer is "more correct" than mine. You mentioned explicitly a Waveform Graph in your question. What I should have said was to drop a Waveform Graph (not an XY Graph) on your Front Panel, hover over it and see that it wants a Waveform (a LabVIEW Cluster with a Starting Time (t0, which can be 0 if you want the Time axis to be "Seconds, starting at 0"), a time interval (dt) representing seconds between the equally-spaced samples, and Y, a 1D Array of Dbl representing the data to be plotted. The difference between a Chart and a Graph is that Charts plot "a point at a time", and can scroll past, while a Graph plots "all at once", and the only way to update it is to plot another Array, again "all at once".
Bob Schor
09-27-2021 11:05 AM - edited 09-27-2021 11:10 AM
So if my loop's timing is set to 10ms, my waveform graph time interval (dt) should be set to 0.01? Which can't be right because my graph is increasing in time way too fast
09-28-2021 02:59 PM
@Bob_Schor wrote:
....a time interval (dt) representing seconds between the equally-spaced samples...
Bob Schor
Is the time interval supposed to be at the same rate as the loop speed? I tried this and it increases in time faster than my computer's clock
09-28-2021 05:16 PM - edited 09-28-2021 05:19 PM
Waveforms and waveform graphs are best suited for equally sampled data where you acquire/generate/read/process multiple (N) samples at a time. The loop rate determines the cadence with which you get a new block of N samples; the sample rate determines the sample interval.
In this hardware-timed example, the DAQmx API puts all the timing information (t0 and dt) on the waveform.
09-29-2021 08:52 AM
The reason there are Charts and Graphs in LabVIEW is they are for different purposes. Use a Chart when you want to see the data as they are arriving, like an Oscilloscope or a Strip Chart recorder, which show you each point at the rate they are acquired. On the other hand, you use a Graph when you have all of the points you want to plot and you want to see a "static Image" of all of the data.
In your example of sampling at 100 Hz, that's the rate that each sample occurs. If you want to plot each sample as it is acquired, you want to use a Waveform Chart and plot every sample at a rate of 100 Hz, or a time delay of 10 ms. You'll see a graph that increases at 100 points/second. For this type of Acquisition and Immediate Viewing, you want the acquisition and Viewing to run at the same rate, so you might put the Chart next to the DAQmx Read and take the single acquired Sample and wire it to the Chart input.
On the other hand, if you want to acquire, say, a Waveform of 1000 points (which will take 10 seconds), you could wire it to a Waveform Graph (or, indeed, to a Waveform Chart), and after 10 seconds (required to build the Waveform), you'll see all 10 seconds. If you are generating the data using DAQmx Reads, the Read will "clock" your While Loop -- if you specify the output to be a Waveform, the DAQmx Read will wait until the Waveform is build (which is why I said it takes 10 seconds). So if you are simulating a DAQmx Read (say, using a Random Number generator), you need to use a For Loop with 1000 iterations to create the Waveform for the Waveform Graph (otherwise you'd be plotting 1000 Graphs of single points, which is kind of silly).
Bob Schor