LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

averaging triangular waveform

Referring to one of my previous posts (http://forums.ni.com/ni/board/message?board.id=170&message.id=99593), I've tried the AverageColumns[1].vi with my triangular photodiode signal and unfortunately the frequency is much too unstable to use this VI. I usually get a gradual increase in frequency which means that my triangles don't overlap. I'm working on the second suggestion - am I correct in thinking that I don't have the align and resample express VI (introduced in version 7)? I found align waveform timestamps...
Here's my current situation: I can specify triangle frequency (best option for me (for experimental reasons) is 333mHz i.e. one triangle every three seconds), but it isn't stable (drifts maybe 20 mHz per 30 seconds, but this is enough to destroy overlap). Is averaging possible with an irregular frequency? My triangular sections won't have the same number of points if data acquisition rate is a constant...
Also (see attachment)what I'd REALLY like to do is remove the triangular shape altogether - it's unavoidable experimentally, but I'd like to look at my signal (wiggles at top of triangular ramp) on a flat background. I've played with this manually - working out a formula for the linear portion and subtracting the line from my collected data (in excel) but it's really time consuming - that's where I'm hoping LabVIEW can help!
0 Kudos
Message 1 of 20
(3,639 Views)
Sue,

I am not sure exactly which portion is your desired signal, so this suggestion may not be entirely appropriate. Try fitting a straight line to, say, the rising portion of the triangle wave. Then sutract the points on the line from the waveform. This should give you the "wiggles" for that segment. Repeat for each segment. Process the wiggles. Wiggles - that is a technical term for mixing chemistry with electronics, right?

The tricky part of automating such a procedure is finding the peaks of the triangle wave. In the sample you posted the positive peak is fairly clean but the negatve peak is not. One possiblity is to use the Peak finder and then ignore a small region near the peaks for the regression. Then use the intersection of the straight lines as the appoximate peak location.

Lynn
0 Kudos
Message 2 of 20
(3,619 Views)
Another idea: The frequency of the desired signal seems to be about 10 times higher than the triangle wave. A high pass filter might help. The triangle wave does have high order harmonics which could interfere, but it is something which could be tried very quickly.

Lynn
0 Kudos
Message 3 of 20
(3,614 Views)
Thanks for the suggestions - I hadn't thought of fitting to just the linear portion. The dips at the peak of the triangle are the signal - they are atomic absoption lines. The 'wiggles' at the dip of the triangle can be avoided with care and, despite the attachment's name, AREN'T typical (!)
0 Kudos
Message 4 of 20
(3,610 Views)
I assume that only the triangular frequency changes and that the "wiggles" have a constant frequency. Since you are only interested in the wiggles in the upper part, I would cut the signal near each of the minima of the low frequecy signal. For each section, fit the rising and falling portion to a line and find their intersection to determine the exact peak. Average all sections with the peaks aligned.
Are you sure that the wiggles are always in phase with the peaks? How many different frequencies are in the wiggles?
0 Kudos
Message 5 of 20
(3,603 Views)
I don't see a graph when I click on your .doc document. The signal processing toolkit has a detrend vi that may help with this signal. Can you send your vi or data in 7.0 format???
0 Kudos
Message 6 of 20
(3,599 Views)
Thanks everyone for being willing to help, but it's tricky talking the same language sometimes, I think I'm just creating confusion:( Attachments here show my 'SIGNALS' (dips on triangular background) using two different lasers. I don't think of the SIGNAL as having a frequency - the rising part of the triangle is the increasing intensity of the laser as I increase the wavelength. My atoms absorb the light only at specific wavelengths (think colour for wavelength if that helps) hence the dips - when they absorb, less of the laser beam reaches my detector. The falling part of the triangle is simply a mirror image of the rising half. To reduce noise I'd like to record up to 100 triangular sections, overlap them all and average. This isn't plausible if I have to do it manually. Sorry I can't post in version 7. I tried playing with the peak detector and got ALL POINTS above threshold detected as peaks, and ALL BELOW as dips. I'm worried that all this is too much too ask - do I have any hope?! I'm not very experienced with LabVIEW - there's so much potential there, but it's a bit daunting at times...
0 Kudos
Message 7 of 20
(3,580 Views)
here's a second attachment
0 Kudos
Message 8 of 20
(3,497 Views)
As you mentioned, you have a lot of possibilities. Here are some options to get rid of the triangle:
  1. Use Fourier filtering. To do this, subtract the average of the waveform, then take the Fourier transform. Now remove the peaks which correspond to a triangle wave. You can interpolate under them or just zero them, whatever works best for you. Do an inverse transform on the result, then add back the offset you subtracted and you should have your absorption waveform. Note that this works best when you have an integer number of periods of the triangle wave.

  2. If you know that the triangle is a very good triangle, fit the data to a triangle wave using the Levenberg-Marquardt fit VIs, then subtract your fit from the data.

  3. Find the peaks and valleys of the triangle using the peak finder, then piecewise fit lines to each triangle wave segment and subtract them. This can have problems with offsets if your absorption valleys never go back to baseline.

  4. If the absorption peaks are constant and the triangle wave phase keeps shifting, just average a bunch of waveforms. The triangles will mostly average out. You can get rid of the last bit by one of the above three techniques.
Try these in the order listed, as they get harder to implement and less chance of success as you go down.

It was unclear whether or not your absorption peaks are drifting in time or just the triangle wave. If the absorption peaks are shifting, you will need to use the resample VIs. Start with the Align and Resample express VI and convert it to a normal VI if you need to tweak it. Spline or FIR Filter are probably your best methods. Use Spline if you have a large shift (it is very slow, use Linear if you need speed). Note that FIR Filter can leave artifacts at the end of your waveform.
0 Kudos
Message 9 of 20
(3,483 Views)
Can you attach the raw data, excel file, CSV file?? The signal processing toolkit has a detrend and denoise tool that should really help with these signals. Don't worry about posting a hard task, everyone on the list likes a challenge.
0 Kudos
Message 10 of 20
(3,563 Views)