From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

How can I simulate or capture a decaying signal?

Hello I hope someone can help.
I am trying to simulate an exponential decay so I can verify that my theory works before I manipulate the real data.
I wish to record and then analyse a decaying signal and determine the resonant frequency.
I can simulate a standard sine wave and manipulate this signal even buried in noise and extract the fundamentals.
but how would I go about simulating a decaying signal.
I haven't been able to find functions for this
the signal would decay for say 300mS to 1seconds
which should be enough time to determine the freq ( in the audio range)
and then be stored ready to do analysis on it.
What is the easiest or best way for me to do this.
I would prefer not to use express VIs as the system should be real time.

Also I would like to be able to simply switch between the simulated signal and the real signal on the fly.
by simply pressing a trigger button (or have a hardware trigger ).
the signal is for a ringing bell and I want to isolate the fundamentals and harmonics as it slowly decays

0 Kudos
Message 1 of 8
(3,581 Views)
I forgot to say thanks before I posted

steve
0 Kudos
Message 2 of 8
(3,571 Views)
Hi,

Can't you just gradually decrease the amplitude of the sine wave?
For this you would need to have a variable for amplitude that you
change in every iteration of a loop. If you want to be able to change
the time it takes for the variable to decay, you will need calculate
the amount of decrease in the amplitude in every iteration based
on the time it takes to decay.

In pseudocode it would look something like this

amplitude = 100                     # variable for amplitude
time_ms = 3000                      # variable for time in milli seconds

decrement = amplitude / time_ms     # calculates the amount of decrement per iteration

while(time_ms > 0)
  amplitude -= decrement            # gradually decay the sine



Now the amount of decrementation is constant, if you want it to be
exponental/logarithmic you will need more complicated calculations
done inside the loop.

This should give you a good starting point, at least I hope so Smiley Very Happy
0 Kudos
Message 3 of 8
(3,564 Views)
Thank you so much for the comments.
yes I did realise that I would have to do that.

sorry i should have been more specific
The equation for the natural logarithmic decay function is y=e^-kt where k is the decay constant.
but i was confused how to go about multiplying this by the sine function that I'm simulating.
how do I ensure that the correct points are lined up?
or do I just code this in discrete components and not worry about how they line up.
I will worry about the real acquisition later but for the simulated signal I am guessing
I would have to set the sample rate, and the number of samples and that would give me
the time to sample.
then convert that into some sort of array., then multiply this out.
then what happens to the data - where does it go?
when I use the express vis if I change the parametres I'm measuring eg extract the fundamental tone.
then as soon as the amplitude is adjusted in real time the tone info also disappears.
ie if the signal decays to zero the tone information disappears. which is not what I want
I would like to record this somehow as well,  as the signal will only last for about 1 second at the most.
but will be approx 100 - 1000hz range so there should be lots of chances to get a sample before it decays to zero.
I would like to be able to record (simulate) a decaying waveform, display the result, and then use the standard functions
fft etc on the captured waveform.
then repeat if neccesary

thanks for your help

steve


0 Kudos
Message 4 of 8
(3,560 Views)
Steve,

Create an array of the exponential decay function with the same number of elements as the sine wave and multiply the two arrays together element by element. You did not say which simulation VIs you are using or which version of LV so it is difficult to be more specific. The windowing functions do this, although at both ends of the input data set.

Lynn
0 Kudos
Message 5 of 8
(3,539 Views)
thaks for the comments and help

I am using labview 8

I have included my decay.vi for people to look at
I have put my notes in light yellow
and questions bright yellow and red.

if people could make suggestions or comments or changes to the file
that would be appreciated.
any help at all would be appreciated..

thanks


steve
0 Kudos
Message 6 of 8
(3,528 Views)
 Hi Steve,

For your question regarding switching signals and and the controls for the sample rate and the number of samples, if you want to switch signals you could just use a case structure that a button could toggle true and false. When true you could use the simulated data, and when false you could use your acquired data.

The controls for sample rate and number of samples will be are on the DAQmx VIs you will be using to program your daq device. If you are not familar with daq programming I suggest check out the tutorials on ni.com and the LabVIEW help section on DAQmx, it is very helpful.
Nick R
NI
0 Kudos
Message 7 of 8
(3,496 Views)
Ok thanks for the help regarding the Daq.
and switching between
- but I am still struggling to figure out the other half of my original question - how to simulate a decaying signal.
I have included my vi in the posts above called decay.vi
I have looked through many tutorials and found nothing regarding decaying signals.
it seems that there doesn't appear to be a use for that or maybe no-one has done it before.

also I know how to sample a real signal
but the problem seems to be when I either simulate or capture  it works but if I try to switch and join the signal paths
the program doesn't like me to join the signals.

I wish to be able to perform other tasks on the signal later.
also how do I ensure that only the data from the sample is displayed and not all the data on the graph.
if I want to sample for 2 seconds how do I only display and then record for future use  2 seconds of data.

if someone could look at my decay.vi that would be good.

thanks

steve



0 Kudos
Message 8 of 8
(3,479 Views)