From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Waveform Duration VI not working as expected

I am trying to find the amount of time a waveform runs with the waveform duration vi. I've hooked up a waveform to the vi and an indicator to the duration output, but I don't get the amount of time the waveform has been running.

 

Waveform Duration VI is at the top right of the main VI

0 Kudos
Message 1 of 8
(3,262 Views)

A Waveform is nothing more than a cluster having (among other things) a component called "dt", the time between samples, and an array, Y, of samples.  So the duration of the Waveform can be computed by multiplying dt * (Number of elements of Y), which is what the Waveform Duration VI does.

 

So the problem isn't there.  It is probably in one of the very-appropriately-named Untitled n (SubVI) VI.

 

I'm a Great Believer in sub-VIs, but I have "rules" for them -- every sub-VI must (according to me) have a name, an icon, and a description (and shouldn't have the phrase "SubVI" as part of the name).

 

Try to simplify.  Work backwards from Waveform Duration VI, which will work if you give it a "real" sub-VI.  Make a (truly-untitled) test VI that you throw away when you are done that has whatever "feeds" the Waveform Duration VI and make it "do something" and see if you get a meaningful duration.  If so, work back another step.

 

If you are systematic in this way, it is pretty easy to debug your own LabVIEW code.  Do it in pieces, and when pieces work, add more pieces until something breaks, then look closely there.

 

Bob Schor

Message 2 of 8
(3,236 Views)
I change the SubVIs so often that I usually don't immediately name them. I see your point though. Ideally, I'd have a plan of how to do things and create SubVIs with the plan in mind, but since I'm new to Labview, I'm learning as I go which means I'll try something, get it to work, and then realize there is a better/cleaner way to do things a couple hours down the line after I've already made a dozen additions/changes. After doing that for awhile, I'll have a mess of code that I try to make more manageable by randomly grouping things into SubVIs.

Haha basically all the things you're not supposed to do, but I guess it's how I'll learn as time goes on. Hopefully I'll start with SubVIs and not end with them.

As far as the waveform duration thing, I have tried back tracking and wiring different waveforms to the vi to see if that works, but nothing has worked so far. I won't be able to work on it again until Monday unfortunately.

Thanks for the suggestions. Have a nice weekend.
0 Kudos
Message 3 of 8
(3,213 Views)

If you are not successful on Monday with the troubleshooting, create an indicator on the Array of Waveform wire going into Untitled 2 (after the DAQ Assistant). Run the VI until some data is present on that indicator. Then Edit >> Make Current Values Default. Save.  Post that VI. It will have some of your data saved in that indicator so we can see what is happening.  We do not have your hardware or experimental setup so we cannot get data by trying to run your VI as it is now. 

 

Looking at the DAQ Assistant, it appears that you have it set to acquire one sample on each of 4 channels each time it is called.  That means the waveforms will have a length of 1.  It also means that the dt value of the waveform is undefined. Without testing I am not sure but that likely results in the defalut dt = 1.

 

At the very least such a waveform is rather meaningless.

 

Place indicators on the error out terminal of Waveform Duration to see if it generates an error.

 

You should probably be sampling at 1000-1200 Hz to get good motor voltage and current waveforms.

 

Lynn

0 Kudos
Message 4 of 8
(3,178 Views)

I've updated the VI to include an error out for the waveform duration and an indicator for the array of waveforms. It seems the dt value is defined as 2 currently so that doesn't seem to be the problem. I am sampling at about 2 seconds per sample which is enough for me at the moment. I have sensors that output a dc voltage that give good values after some math that I have checked with a calibrated voltage and current sensor to see if they match.

 

The values stored as default are when nothing is turned on except the DAQ. I also get no error from the waveform duration. Mysterious problem... I'll continue troubleshooting until I run out of ideas.

0 Kudos
Message 5 of 8
(2,989 Views)

I wired a build waveform into the waveform duration and I found out that the duration indicator will read how long the waveform will run from the very beginning. This would mean that the waveform duration doesn't show how long a waveform has been running, but only how long a waveform will run, and to know how long a waveform will run, it needs the whole waveform from start to finish ahead of time. 

 

I wonder if I've come to the right conclusion or maybe I'm missing something. For now though, I'll look for a VI (or create something) that will update how long a waveform has been running.

0 Kudos
Message 6 of 8
(2,984 Views)

I don't think you quite get it.  Suppose I said I was going to store my data in an Array at one point/second.  Question -- how can you tell how long I've been sampling?  The only way is to look at the array and see how big it is!  If I don't yet have the array available (maybe because I'm still sampling into it), I can't answer the question unless I could Predict the Future (which, regrettably, I cannot).

 

Same with a Waveform, which is just an array with some extra "timing bits" tacked on (or you could call it a Cluster with an array of samples).  In any case, the only way to know how many samples there are (and thus for how long data has been stored in the Waveform) requires determining the size of the array.

 

BS

 

 

0 Kudos
Message 7 of 8
(2,959 Views)

 

I don't think you quite get it.  Suppose I said I was going to store my data in an Array at one point/second.  Question -- how can you tell how long I've been sampling?  The only way is to look at the array and see how big it is!  If I don't yet have the array available (maybe because I'm still sampling into it), I can't answer the question unless I could Predict the Future (which, regrettably, I cannot).

 

Same with a Waveform, which is just an array with some extra "timing bits" tacked on (or you could call it a Cluster with an array of samples).  In any case, the only way to know how many samples there are (and thus for how long data has been stored in the Waveform) requires determining the size of the array.


 

Perhaps I wasn't clear, but basically you just reworded what I said. So good! That means I understand. Now Labview just needs a Predict Future VI...Smiley Very Happy

 

I think I'm going to hook up an indicator to one of my while loops to show how long I've been sampling (in reality how many loops have iterated). I put in a wait function so I know how long has passed since the loop iterated.

 

0 Kudos
Message 8 of 8
(2,951 Views)