LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Nugget: Sporatic Waveform Chart

This is an issue that comes up every once in a while, most reacently here in the Idea Exchange.  So I figured it was time for a nugget.

 

Ok, so we have data that comes in at a non-constant rate (ie, the time between samples is non-deterministic).  But we want to show this data in a chart.  I have heard of people creating code to build up XY graphs based on the time stamp and keep building up the arrays to do the job.  But the chart can already do it all for you!

 

All we do here is create a waveform from our data sample and the current time.  We then write that waveform directly to the chart.  The display of the chart will use the value in the T0 of the waveform to know where to put the first data point in the waveform.

 

 

Attached code is in LabVIEW 2015.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Download All
Message 1 of 11
(11,703 Views)

Thank you!  A picture is worth a thousand words.  Running perfectly.

Message 2 of 11
(11,678 Views)

Adding to Tim's nugget...

 

 The "NI_ChannelName" attribute of the waveform will let you set the name that appears in the plot legend.

 

I belive you have to right-click the chart and make sure the "ignore attributes" is NOT selected for the nugget topic and names thing to work.

 

If you use an array of WF's, the T0s do not have to match and the "Y"s for one or more of the WFs can be empty.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 3 of 11
(11,642 Views)

@Ben wrote:

Adding to Tim's nugget...

 

 The "NI_ChannelName" attribute of the waveform will let you set the name that appears in the plot legend.

 

I belive you have to right-click the chart and make sure the "ignore attributes" is NOT selected for the nugget topic and names thing to work.

 

If you use an array of WF's, the T0s do not have to match and the "Y"s for one or more of the WFs can be empty.

 

Ben


Its my longterm wish that NI document all attributes that are interpreted by graphs/charts.......  shameless hint to my idea  ups has been declined 😞 

 

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Message 4 of 11
(11,587 Views)

Good solution, actually I use this way charts for many years. I beleive someone in the discussion forum showed me this way how to add points to a chart, maybe it was even you 🙂

Message 5 of 11
(11,575 Views)

Very good tutorial/example!. I think I've seen this before on some forum, but I forgot about it.

However, at my work we always want relative (elapsed) time in seconds (or minutes), starting at t=0s.

Simply changing the chart properties to show relative time does not do the trick.

After some thinking, I came to the following solution which also addresses multiple channels (here 2 channels).

 

Chart with relative time.PNG

Message 6 of 11
(11,452 Views)

You can even plot waveforms to a chart like this. It is convenient if your plotting process is separated from the data sampling process: you might have 0 to many points in the buffer you want to plot. But beware, there are some issues related if you go that way:

Chart Redraw Issue with Multiple Plots.

 

 

Certified LabVIEW Architect
0 Kudos
Message 7 of 11
(11,377 Views)

@donkdonk wrote:

After some thinking, I came to the following solution which also addresses multiple channels (here 2 channels).

 

Chart with relative time.PNG


Why so complicated?  And what if you are no longer on DST or you change time zones?  All you need to do is change the first time stamp into a double and be done.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 8 of 11
(11,325 Views)

@crossrulz,

After posting I realized that I somehow should be able to subtract initial time. I also realized that I somehow had to deal with summertime and changing time zones. However, I did not know you can use the "convert to double" primitive. Thanks, nice solution. It does exactly what I want!

 

(I also realized later that I would rather put the build array primitive in the second for loop: it separates the acquired data array from the formatting to the chart).

 

One further remark: for educational purposes, IMO your fixed time interval is not such a good choice; now the chart shows evenly distributed points.

0 Kudos
Message 9 of 11
(11,289 Views)

@crossrulz wrote:

@donkdonk wrote:

After some thinking, I came to the following solution which also addresses multiple channels (here 2 channels).

 

Chart with relative time.PNG


Why so complicated?  And what if you are no longer on DST or you change time zones?  All you need to do is change the first time stamp into a double and be done.


Note:

Now that you are working with Y arrays larger than a single element, dt should be taken into concideration. If the times of points already plotted conflict with the new waveforms presented to the chart, the chart will/may reset. The "will/may" qualifier ws used becuase the behaviour may have changed with LV versions.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 10 of 11
(11,257 Views)