LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Eliminating undesirable data

hey all,

i am acquirind displacement and by this data, in labview i use derivative VI and get velocity.

The problem is:

When the program makes the derivative, I think in each buffer the value return to an specifical value.

On can see this problem in 2 pictures attached and Main VI is also attached.

 

Thanks since now,

Arthur.

Download All
0 Kudos
Message 1 of 12
(2,833 Views)

Arturo,

     The problem is "hidden" in the Express VIs that are all over your Block Diagram.  I'm guessing you are new to LabVIEW and might not completely understand digital signal processing, so are taking the shortcuts that NI provides.

 

     You want to take a derivative.  If you look at the Help for the Derivative Express VI, you'll see that it computes y[i] = (x[i] - x[i-1])/dt.  So to take the derivative of 500 points, you need 501 data points!  In particular, you need to supply x[-1], which (in the absence of instructions from you) takes on the default value of 0!

 

     If you again look at the Help for the Derivative VI,  you'll notice an input called "Calculation Mode" that, by default, is "Continuous" (meaning it uses data from the previous set of data to compute the derivative.  This is the correct setting for the second, third, fourth, ... iteration of this loop, but needs to be set to False for the first one (to avoid the x[-1] problem mentioned above).  Do you know about Shift Registers?  Put a Shift Register in, wire "False" (the Boolean constant) as an input from the outside of the loop, wire the Shift Register to the Calculation mode, and then wire "True" to the output of the Shift Register from inside the loop.  Do you understand what this does?  It makes this input False for the first loop and True afterwards, exactly what you need.

 

     See it this fixes your problem.

 

Bob Schor

 

P.S. -- and try to learn how to avoid using Express VIs, and especially avoid those Dynamic Data Wires (the dark blue checkered wires connecting most of your Express VIs).

Message 2 of 12
(2,809 Views)

Hey Bob, thaks for your post.

When you say put a shift register o meaning to put it on the while loop about the whole VI or to build a new for loop around the derivative VI and introduce the shift registers ? 

Also, what you mean with ~wire the Shift Register to the Calculation mode~ ?

 

thanks again,

Arthur.

0 Kudos
Message 3 of 12
(2,756 Views)

My apologies.  I just now opened your code, threw out almost everything except the Dreaded DAQ Assistant, the Filter, the Select Signals, and the Derivative (mind you, I've never used any of these Express VIs, except a very brief "trial" when the Dynamic Data Wire was first introduced, and I found it so tedious and difficult that I learned all about Waveforms ...).  I then looked for where the assumed (wrong -- never assume, rather carefully read the Help document) Calculation Mode input was placed.  Sigh.  It's not there.  So much has been hidden from you -- it can even confuse "someone who should know better" (like myself).

 

I apologize for leading you somewhat astray and for making a mistaken recommendation for a feature (Express VIs) that I don't use.  So I did an experiment -- I created a Sine Wave generator and fed it through a Derivative, plotting the result (and using all Express VIs).  It worked just fine.

Simple Derivative TestSimple Derivative Test

Your VI is much more complicated, and has many more "moving parts", most of which are not accessible to me.  "When in doubt, simplify" -- take pieces of your code, see what works, try to isolate what "breaks", and then test that separately to try to understand the error.  

 

Bob Schor

 

P.S. -- the Attachment is a LabVIEW Snippet -- drag the PNG file onto a blank Block Diagram and the code with automagically appear.

 

0 Kudos
Message 4 of 12
(2,746 Views)

Hey Bob, 

thanks for your advices,

i tryied to reproduce the exemple you send me in last post but not succesfully. If you have a look at the first point of a derivative line in the waveform chart, you can see it still recording the first number (0 ----> x[i-1]).

 

Thanks again,

Arthur.

0 Kudos
Message 5 of 12
(2,724 Views)

@Arthuruuuuuu wrote:

Hey Bob, 

thanks for your advices,

i tryied to reproduce the exemple you send me in last post but not succesfully. If you have a look at the first point of a derivative line in the waveform chart, you can see it still recording the first number (0 ----> x[i-1]).

 

Thanks again,

Arthur.


Bob's picture is a "magic picture" called a "snippet".  It takes advantage of the ability of png files to contain metadata by stuffing data into there that, when dropped into a block diagram, LabVIEW uses to reconstruct the actual code.

 

So save that png file and drag it onto a block diagram - and watch the magic as it transforms into LabVIEW code!  🙂

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 12
(2,714 Views)

yes !

but if you have a look it still recording de first value of loop so is highligthed in picture attached.

 

the path by shift registers sound better but i could not figure out how to link the boolean and shifters with the calculus.

 

Thanks,

Arthur.

0 Kudos
Message 7 of 12
(2,707 Views)

I'm sorry, I don't get the point you are trying to make.  Because (as I tried to say), when you estimate the derivative from data, you calculate a "slope", which means you need two points for every point of your sample.  The usual way is to take it from the current point and the previous (or following, or both previous and following) point(s), but there will always be a "missing point".  A common "fudge" is to say the derivative when you don't have data to compute the derivative is 0 -- perhaps a better thing to do would be to say "I can't say", and use NaN (which won't plot).

 

Bob Schor

0 Kudos
Message 8 of 12
(2,702 Views)

Hey Bob,

this is what i am saying. All graphs i use with a derivative, they carry this firts point and make the result aways go back to firts interation. (you can see this point highligthed by a red circle in the picture attached on this post).

You also can have a look at the main VI.

Sounds very strange for me that i have done in another project and worked very well.

thanks again,

Arthur.

0 Kudos
Message 9 of 12
(2,674 Views)

Here

Download All
0 Kudos
Message 10 of 12
(2,673 Views)