LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

smoothing

Dear Dennis Knutson :

Do you know how to use windowed filters to do smoothing to signals in LABVIEW? I have to translate the following ASYST codes into LABVIEW,But I don't know what is the conterpart function in LABVIEW for the codes:" 0.5 set cutoff frequency, MOBEX(array used in the to convey the data in the old codes), smooth.

As explained in the AYST MANUAL. The following are the expanation of the functions of "smooth" and " set. cutoff.- frequency"

SMOOTH:
thsi word returns a smoothed version of the data array taken from the top of the stack. the smoothing is carried out along the last index of the array. and is implemented by convolution with weights obtained from a low pass Blackman window frequency response. the cut off frequency of the fil
ter is initially set to 0.25(cycles/point),but can be reset at any time by using the word SET .CUTOFF .-FREQUENCY.

SET.CUTOFF.-FREQUENCY:[f0]

The cutoff frequency for the low pass filter applied by smooth is set to equal f0. the number f0 is specified in units of cycles/point and should be limited to teh range of 0.5
I'm a little doubtful about the expanation of"SET CUTOFF FREQUENCY": because I when I tried to adjust the value to be larger than0.5, the error says: the value can not be more than 0.5.
0 Kudos
Message 1 of 9
(4,808 Views)
Sorry. The ASYST code is:

0.5 set cutoff frequency
Mobex
smooth.
0 Kudos
Message 2 of 9
(4,808 Views)
fenny wrote in news:506500000008000000A9940000-
1042324653000@exchange.ni.com:

> Dear Dennis Knutson :
>
> Do you know how to use windowed filters to do smoothing to signals in
> LABVIEW? I have to translate the following ASYST codes into
> LABVIEW,But I don't know what is the conterpart function in LABVIEW
> for the codes:" 0.5 set cutoff frequency, MOBEX(array used in the to
> convey the data in the old codes), smooth.
>
> As explained in the AYST MANUAL. The following are the expanation of
> the functions of "smooth" and " set. cutoff.- frequency"
>
> SMOOTH:
> thsi word returns a smoothed version of the data array taken from the
> top of the stack. the smoothing is carried out along the last index of
> the array. and is implemented by convolution with weights obtained
> from a low pass Blackman window frequency response. the cut off
> frequency of the filter is initially set to 0.25(cycles/point),but can
> be reset at any time by using the word SET .CUTOFF .-FREQUENCY.
>
> SET.CUTOFF.-FREQUENCY:[f0]
>
> The cutoff frequency for the low pass filter applied by smooth is set
> to equal f0. the number f0 is specified in units of cycles/point and
> should be limited to teh range of 0.5> denotes the size of the last demension of the data array to be
> smoothed.{n of my data is 256).
>
> I'm a little doubtful about the expanation of"SET CUTOFF FREQUENCY":
> because I when I tried to adjust the value to be larger than0.5, the
> error says: the value can not be more than 0.5.

I suspect a typo. Assuming your cutoff frequency is scaled to sample rate,
You cannot design a filter with a cutoff of more than 0.5 because a given
sample rate can only accurately represent signals containing frequency
content not exceeding half the sample rate.

As I recall, ASYST was somewhat weak on filtering, in one version even
applying the window in the frequency domain instead of the time domain (I
called in that bug in around 1990 or so).

I wouldn't worry so much about exactly recreating the ASYST algorithm in
Labview. Worry more about what you are trying to achieve. You are trying
to filter your data using a low-pass filter. Search Labview examples for
"filter". You will come up with FIR and IIR examples. The ASYST code, if
I recall, is an IIR filter. Follow the IIR examples, and they should show
you how to implement a simple low-pass filter.

--
Scott
Reverse first field of address to reply
Message 3 of 9
(4,808 Views)
Thank you, SCOTT.

Yes,as you said, the "smooth" is applied to the frequency domain in stead of time domain.

So the original ASYST codes are questionable. right?

Then, I can not have exactly the same result as the original ASYST code even if I perform correct "smoothing" in LABVIEW.

I'm just trying to do the same things as the original ASYST code(that's what i want to achieve),because I don't have the mathimetics of the code. So I have to follow each step of the old codes.(that's the biggest trouble I have with this task.)


in fact,I don't know if this "smoothing" is necessary.
because the old codes did this "smoothing", i want to do the same thing to see if i can get the same results.
i want to match my result with the old ASYST codes perfe
ctly!

another problem is that: the frequency domain signal is obtained by deviding one frequency domain signal(velocity) by another frequency domain signal(force).

I don't have the time domain signal(mobex) in the first place.

is it possible to transfer the frequency domain back to time domain(IFFT)and perform filtering to the time domain signal and FFT back to frequency domain?
0 Kudos
Message 4 of 9
(4,808 Views)
fenny wrote in news:506500000005000000BD080100-
1042324653000@exchange.ni.com:

> Thank you, SCOTT.
>
> Yes,as you said, the "smooth" is applied to the frequency domain in
> stead of time domain.
>
> So the original ASYST codes are questionable. right?
>
> Then, I can not have exactly the same result as the original ASYST
> code even if I perform correct "smoothing" in LABVIEW.
>
> I'm just trying to do the same things as the original ASYST
> code(that's what i want to achieve),because I don't have the
> mathimetics of the code. So I have to follow each step of the old
> codes.(that's the biggest trouble I have with this task.)
>
>
> in fact,I don't know if this "smoothing" is necessary.
> because the old codes did this "smoothing", i want to do the same
> thing to see if i can get the same results.
> i want to match my result with the old ASYST codes perfectly!
>
> another problem is that: the frequency domain signal is obtained by
> deviding one frequency domain signal(velocity) by another frequency
> domain signal(force).
>
> I don't have the time domain signal(mobex) in the first place.
>
> is it possible to transfer the frequency domain back to time
> domain(IFFT)and perform filtering to the time domain signal and FFT
> back to frequency domain?

Starting to understand slightly better. The filter routines I was talking
about are time domain techniques, not frequency domain. Frankly, I'm not
sure of the best way to do this in labview.

As a long-time signal processor, I'd say that smoothing is for the time
domain, not the frequency domain. There's little reason to make an FFT
look smooth-- it just won't help with subsequent operations, and could
actually hurt your estimates.

It sounds like you're trying to estimate a trasfer function of a system
that uses velocity as an input and generates force as an output. Filtering
your FFT's shouldn't be necessary to do this. All this would do is kid you
into thinking you have a better answer than you actually have.

The approach I would take would be to use the tfe function in the signal
processing toolbox in matlab to estimate the transfer function, and the
cohere function to calculate the coherence as a function of frequency. I
don't use Labview for this type of stuff, though I'm sure its possible,
just not as convenient as Matlab for me. In fact, I implemented this
entire method in ASYST in the early '90s.

Yeah, you can probably exactly replicate the ASYST code, but I'd take the
approach of getting the best answer, instead. You can get better estimates
of transfer function than the techniques you describe. I would recommend
finding a book by Marple, I think the title is Random Signal Processing,
and read about the Welch Periodogram.

My overall recommendation would be to not attempt to replicate the ASYST
code directly, operation by operation. Instead, post what arrays you have,
and what you need to do to them-- i.e, what does the original code do? So,
if you generate a thread like "need help doing transfer function estimation
in Labview", and describe the signals you have, you'll get much better
advice than you would if you post requests for help for each step in the
processing. Give us the overview of what the program needs to do, and
you'll be surprised at how much help you'll get.


--
Scott
Reverse first field of address to reply
0 Kudos
Message 5 of 9
(4,808 Views)
attached is the ASYST including the "smooth"(The smoothing function included in the subroutine called TOTIM).
0 Kudos
Message 6 of 9
(4,808 Views)
sorry, the AYSTS code is here
0 Kudos
Message 7 of 9
(4,808 Views)
fenny wrote in news:506500000005000000CD080100-
1042324653000@exchange.ni.com:

> vv1 fft zmag vst := vst [ 2 ] 2 / vst [ 1 ] :=
> pp1 [ 201 ] 0. = if 0 pp1 := else
> pp1 fft zmag fst := fst [ 5 ] fst sub[ 1 , 4 ] := then
> vst fst / hf * 1 rotate sub[ 1 , 512 ] mobexp := .5 set.cutoff.freq
> mobexp smooth mobexp := 0 mobexp [ 1 ] := sm set.cutoff.freq
> mobexp [ 3 ] 2 / mobexp [ 2 ] := mobexp 1e-7 * mobexp :=
>

A program listing isn't quite a description of what you need the program to
do, unfortunately.

You really have your work cut out for you. Undocumented asyst code is very
opaque because of the way the stack is manipulated. Conditional statements
can be particularly difficult.

It looks like the guts of the program are really in the colon definition
TOTIM, so I understand your hangup.

FWIW, I think your time signals are present as vv1 and pp1, if I remember
Forth syntax. Also, if SMOOTH does what I think it does (which is the
filtering of a time-domain signal), its isn't really necessary to perform
on mobex. In fact, I'd venture a guess that the original author didn't
really understand what it did to mobex, and I'm not really sure how to
define the cutoff frequency on a frequency axis instead of a time axis.

Now, as to filtering in the time domain, this will attenuate the fft result
at high frequencies, but it won't change the ratty appearance of the fft.
FFT's are supposed to look ratty. If you don't like ratty fft's, use less
points in the fft.

Further, if zmag function takes the magnitude of the complex fft result,
like I think it does, you'd be much better taking the magnitude after the
division of vst and fst, not before (assuming whatever application you're
using can do division of complex numbers). Also, if you really feel
compelled to smooth the fft like you describe, you should probably do this
after the division as well. At least the division won't have a host of
numerical errors built into the inputs.

I think you'd be much better off doing a Welch periodogram to find the
relationship between vv1 and pp1. Signal processing has come a long way
since the tools ASYST stopped developing more than 15 years ago. Don't
lock yourself in.



--
Scott
Reverse first field of address to reply
0 Kudos
Message 8 of 9
(4,808 Views)
Smoothing is easy as nothing in time domain:
http://www.info-labview.org/the-archives/vi/lv5/FIRFunct.txt
http://www.info-labview.org/the-archives/vi/lv5/FIRFunct.zip
0 Kudos
Message 9 of 9
(4,808 Views)