LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic data type error

Solved!
Go to solution

Hello,

I am measuring signal from DAQ assistant and I am taking average of all the data I get over one cycle,for that I am using a while loop and a shift register and after the while loop completes running i divided the output of the shift register by i of the while loop +1.

But I am getting the following error :"Error in add:Waveform has different dt".

 

Can anyone please help me how I can I get rid of this error?

 

Thanks

 

0 Kudos
Message 1 of 10
(4,153 Views)

You have to initialize the shift register with a waveform that has a dt that is the same as the waveforms you are getting with the DAQ Assistant. For example:

 

 

That said, I am HIGHLY SUSPICIOUS of your use of local variables. To the point where they don't make sense. The way you've used "Current Cycle Number" implies that it's being changed someplace else. This smells of a race condition to me. 

Message Edited by smercurio_fc on 08-07-2009 04:22 PM
Message 2 of 10
(4,138 Views)

Thanks for your reply.Yes my current cycle number variable is changing in another parallel loop in the same VI when the axis completes one cycle of motion.So far I only knew that using global or shared variable has the risk of  race condition.Can you make the point more clear?

Also I dont know the dt for my signal from DAQ asssiatant.I tried to use Get Waveform Attribute VI from the waveform palette but it does not accept dynamic data type.How can I know the dt of my signal? 

 

Aru

 

0 Kudos
Message 3 of 10
(4,126 Views)

Oh that was a stupid question,inverse of the sampling rate of my DAQ assistant express VI is the dt.

 

 

0 Kudos
Message 4 of 10
(4,121 Views)
ok I just initialized the shift register accrodingly but it still gives me the same error.Any clue why?
0 Kudos
Message 5 of 10
(4,106 Views)
Solution
Accepted by topic author poorinLabVIEW

You need to do someting similar to this.

 

 

 

Here is a picture of the old example using a FOR loop. Modify as needed.

Message 6 of 10
(4,102 Views)

poorinLabVIEW wrote:

Yes my current cycle number variable is changing in another parallel loop in the same VI when the axis completes one cycle of motion.So far I only knew that using global or shared variable has the risk of  race condition.Can you make the point more clear?


This is a prototypical race condition and makes no sense whatsoever. It is highly likely that the two local variable instances are read within nanoseconds (one right before the loop starts and one right after to loop has started. There is a very high possibility that they return the same value and thus the loop will stop after one iteration, messing with any attempts at averaging.

 

Why don't you attach some actual code instead of images?

0 Kudos
Message 7 of 10
(4,099 Views)

Thanks,it worked but I am not sure if my code does what I want it to do.I want  to get the mean of all the data collected in one cycle (as long as current cycle numberbefore iteration =current cycle number )and have it plotted against the cycle number.My buffer size for data acquisition is 100 and sampling rate is 1KHz. I am simply dividing the sum of all data by the total number of iteration which I am not sure if the same as total number of samples in one cycle.

You used an uninitialized shift register which I didnt understand why.

I am using stop if true for while loop stop terminal so it will only stop when the value of current cycle number is no longer equal to the current value of current cycle number.I would really appreciate any c     omments regrading the possibility of contamination with race condition after taking a look at my code.

0 Kudos
Message 8 of 10
(4,082 Views)

Don't overcomplicate things. Keep the "add" node and get rid of the math express VI.

 

You want to add waveforms, so at the first iteration (i=0), you simply place the current waveform into the shift register. Since we ignore the value from the shift register, it does not matter if we initialize or not. Only starting with the second iteration (i=1..) we add the new waveforms to whatever is in the shift register.

 

(Your method with the initialized shift register will not work, because even though the dt is correct, the initial data in the shift register has no values (zero elements), so you cannot add. Additions are element by element, so the shorter array wins.)

 


poorinLabVIEW wrote:

My buffer size for data acquisition is 100 and sampling rate is 1KHz. I am simply dividing the sum of all data by the total number of iteration which I am not sure if the same as total number of samples in one cycle.


Sorry, I don't have any DAQ tools installed, so I cannot really inspect your code. Still, Your sentence above makes little sense to me.

Message 9 of 10
(4,072 Views)

altenbach wrote: 

(Your method with the initialized shift register will not work, because even though the dt is correct, the initial data in the shift register has no values (zero elements), so you cannot add. Additions are element by element, so the shorter array wins.)


You're right. I neglected to consider the array portion of the waveform, and was only looking at the error's cause, which was the mismatch in dt.

0 Kudos
Message 10 of 10
(4,059 Views)