LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding two waveform

Solved!
Go to solution

Hello,

 

I am trying to write a Labview nxg 3.1 code in which I add two copies of the same signal, the original one and it's delayed version.

I used a shift register with a wait function. The shift register should add the previous signal to the delayed one.

However an error 1802 is occuring on the addition. It says that the two waveforms have different dt. Can anybody help me with this ??

0 Kudos
Message 1 of 7
(3,099 Views)

Check the waveform components and see what the dT's are.

 

I'm not familiar with NXG.  If you attached your gvi, then people who have NXG installed could run it.

 

I think the problem is you have an uninitialized shift register.  So when you run your VI, you are trying to add a waveform together with a default waveform which would be an empty Y array, a dT of 1, and a T0  of 0.

 

Try putting in a case structure so that on the first iteration of the while loop, it does not do any addition, but just feeds the captured waveform to the shift register.

Message 2 of 7
(3,089 Views)

Thanks for replying,

 

Yes that's exactly what the program is doing. But why should I initiate the shift register ? I just want to add the waveform from the previous iteration as it is after some time delay. Isn't it works with waveforms just as it works with numbers ? For example if I have a 1+1 addition in the loop and the result is connected to the shift register on the right, after one ifteration i'll have 2 in the left part of the shift register. I need to do the same thing but with a signal, If you think that this way is wrong kindly help me to correct it.

 

Thanks.

Download All
0 Kudos
Message 3 of 7
(3,064 Views)
Solution
Accepted by AliSabra

Because what happens at iteration 0?  There is no valid waveform in that shift register you are reading from the first time you run that VI!

 

With a number, you don't have a 1 in that shift register to start, you have a default value of 0.  To that first iteration, you can add 0 + 1 and put a 1 in that shift register on the right had side.  Second iteration then you read 1, add 1, and put in a 2.

 

Waveforms are different.  They are a special kind of cluster.  The 3 major components are a Y array of values, a t0 for initial value timestamp, and a dT for the time difference between elements.  They also have a variant for holding additional information about the waveform.  When you first run that VI, the shift register contains a default value for a waveform.  So what makes up a default waveform?  An empty array, a t0 of 0, and a dT of 1.   When you go to add waveforms, it tells you that you can't add a waveform with a dT of 1 with a waveform of dT whatever it happens to be.

 

Just don't do the addition of waveforms on the very first iteration  (i=0) of that loop!

Message 4 of 7
(3,061 Views)

Now it makes sense, thank you.

do you know how to skip the addition operation in the first iteration ?

0 Kudos
Message 5 of 7
(3,059 Views)

Put it in a case structure.  Connect i  =0 to it. 

 

Just wire the waveform through in the True case.  Do the addition in the false case.

0 Kudos
Message 6 of 7
(3,054 Views)

It took me sometime to figure out that I should use a comparison between 0 and the iteration number. It works now.

Thank you so much!

0 Kudos
Message 7 of 7
(3,039 Views)