01-26-2021 10:47 AM
Hello NI community,
I am relatively new to labVIEW, and I am attempting to make a closed-loop control program to control the velocity of a linear actuator. One issue that I am having is that the X Axis of my waveform charts are not in seconds. I would like to have the charts in terms of elapsed seconds so that I can compare the estimated velocity of the actuator (mm/s) to taking the difference in a potentiometer position reading over the elapsed time (mm/dt) as a sanity check. Right now the X axis seems to relate to time, however it is not the true elapsed time. Any pointers as to how to get the X axis in true relative time?
Thanks! (program attached below)
01-26-2021 10:59 AM
A waveform *chart* doesn't have a notion of "time history" as it's just a collection of points. Think of it as an array. A waveform *graph* can display X/Y data. I almost always use graphs as I find it easier to manually handle my time data, and the waveform data type is very easy to use. Use "Build waveform" and set the Y array to your accumulated data and the dt to your time period. Note you'll need to manually keep track of your accumulated data instead of feeding it one point at a time.
If you don't want to do that, here are a couple more options you could modify to suit your needs:
https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000YHcoCAG&l=en-US
https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000YGxCCAW&l=en-US
Last, you could always right click and go to "Properties" then "Scales" then "Time (X-Axis)" then modify the Scaling Factor Multiplier to something that makes sense. For example, if your sample rate is 10 Hz, then set your scale factor to 1/10 or 0.1.
01-26-2021 11:02 AM
I'm going to go with the obvious first. Since you said Waveform Chart you should have a known dt. Did you format the x axis scale as relative time?
01-26-2021 11:10 AM
I've tried relative time and floating point, but it still isn't the true time.
01-26-2021 11:12 AM
Thanks for your response. I've thought about trying to use a property node and scaling the X axis, but i want a definite conversion, not something that I try and do guess and check on. I may look in to using a graph instead. What block should I use to create the X axis as time? And one thing that is convenient is to monitor the chart in real time, but I think I may try and do both.
01-26-2021 01:01 PM
You can monitor a graph in real time, just accumulate the data and plot it to the chart once every so often. Keep the old data in a shift register.
And scaling the X axis isn't guess and check. You set the scale factor to 1/dt and it's exactly right (assuming, of course, that your sample rate is known and constant). If it's not constant, you probably shouldn't use a chart anyway, but you can kind of "cheat it" a little with this trick:
01-26-2021 01:06 PM
Thanks for the reply, kind of a stupid question here, but how can i check the sampling rate? I saw in one of the links about using a DAQmx "Sample clock" and a property node, but is there a more basic way to check or obtain that info?