Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Substract present value of signal from the value 2 seconds ago

Solved!
Go to solution

Hi,

I am fairly new to LabView but I went through the Forums and googled a lot and didn't find a solution. I have this problem:

I have an analog signal obtained from my NI DAQ USB6009. I want to take the signal I obtained 2 seconds ago and substract its value from the present value. And I want to do it countinously.

My data are acquired 1 sample on demand by NIDAQ Assistant in while loop.

 

Result signal should be something like:

Y(t) = y(t) - y(t-2), where Y is a result and y is a signal from NIDAQ.

 

Can You help me or specify anything else You need to know to help me? Thanks.

 

 

 

0 Kudos
Message 1 of 8
(4,566 Views)

What do you have so far?  How often are you sampling?

 

The simple solution is to just put your values into a shift register.  You can then subtract the value in the shift register from the newly read value to get your output.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 8
(4,560 Views)

Hi,
in case your sampling frequency is 1 S/s stacked shift register is definitely the easiest way how to implement given formula. It can look like this:

 

code.png

 

Regards,

 

Ondřej K.

NIEE AE

CLA, CTA, CLED
0 Kudos
Message 3 of 8
(4,539 Views)

I have daq assistant (1 sample on demand) in while loop. That's it. There is no "wait" or "delay" in that loop. To tell You the truth I am not sure how can I determine the sampling frequency in this case, but when I store measured data in file it looks like the sampling frequency is 42-43S/s.

That would make 84 shift registers for two seconds, wouldn't it? That seems not the best solution to me. Even more when I want to be able to change the delay time somehow easily.

 

What I have done so far? I have quite a bit of code, which does some stuff for me. I think the relevant code is only the one in red square:

LVprtscrn.png

0 Kudos
Message 4 of 8
(4,533 Views)
Solution
Accepted by zipac

You would use a ring buffer instead of the shift register.

Delayline.png

 

Your signal source should be configured to read continously (take more readings (best would be multiples of line periode) and mean)

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 5 of 8
(4,527 Views)

Thank You for Your answers.

Henkrik, please, can You describe at least the main parts of Your project. I didn't catch what it does at all, probably because of my poor knowledge. I would appreciate Your help very much.

 

Thanks 

0 Kudos
Message 6 of 8
(4,515 Views)

@zipac wrote:

Hi,

I am fairly new to LabView but I went through the Forums and googled a lot and didn't find a solution. I have this problem:

[...]

Can You help me or specify anything else You need to know to help me? Thanks.

 

 

 


Well even If I did already most of your homework 😉  bevore googleing and forum readings comes LabVIEW tutorials! 

REading a book and reproduce the examples can help too.

 

When I find time I will write some comments on my 5min (8min with cleanup) work, but some basic understanding of dataflow, loops, shift register, datatypes,...  is needed

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 7 of 8
(4,510 Views)

Thank You for doing my homework. I'll do my best to find out whats going on by myself.

Don't bother yourself with doing anything else, please. It would be more educative for me to learn the basics by myself.

Thanks 

0 Kudos
Message 8 of 8
(4,506 Views)