LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Edge detection on Square wave with Carrier Frequency

Hello

I am having programmers block and need some fresh points of view on my current issue. I'll describe my signal, how I am trying to process it and then attach a VI with a sample of what I am CURRENTLY trying to do. Please excuse the code since it is not very finalized.

 

The signal is the output of a laser distance measurement system. I am measuring the copper bars of a commutator along with the insulating slot between them. This can happen anywhere from 1.5 kHz to 4 kHz. Regardless, the wave form I get "high" (high is roughly a value of 70 in this case) for roughly 85% of the time followed by a low of ~-105.

 

One cycle of the above described is ~70 discrete samples (depending on motor speed). The transition from low to high takes ~8 samples. It should also be noted that the high value may slowly change to as high as 85. This is due to the ~1.5kHz signal riding on a ~15 Hz signal. It is probably best to look at the waveform saved in the attached VI at this point.

 

Ultimately I am trying to put all the "highs" into a bin, average it and then compare it to the other "highs" . I want to parse out the low portion and the transition such that it does not influence the average value.

I tried using Scalar Limit Comparison and that proved to be ineffective because of the lower frequency causing the "high" to change and therefore more of the transition ended up being put in the bin.

 

What has quasi worked best has been my own custom brewed edge detection. Basically I take in the array of y values and compare index zero to index 0+y. If I see a small change move to index 1 and check it against 1+y. If it is a large change then collect all the values until you see a big change going down.

The problem is that this only works when the threshold and "y" are just right. it takes a lot of tweaking. I was hoping to come up with something a little more automatic and/or user friendly.

 

I am happy to add any clarifying detail about my signal or end goal.

0 Kudos
Message 1 of 7
(3,532 Views)

So you want to get an average of chunk that is above a threshold? Why would you use a relative threshold (and not an absolute threshold)?

 

Attached VI gives more or less the same results. It could be adapted to work PtByPt.

0 Kudos
Message 2 of 7
(3,493 Views)

Yes I would like an average of a chunk of above a threshold.  The problem I see with an absolute threshold is that it will include some of the measurements in the transition.  If you look at the Average In Jump Sort 3.0 your code generated an average of 71.2148 in index 1.  If you look at the original data set and set and zoom in on the wave form the average of that set of data for the "flat" top should be somewhere in the neighborhood of 73.25.

 

If you continue this line of thought take a look at the original waveform.  The peak in the area of samples 2000 to 3500 occurs close to 84 (for the flat areas).  In the output the averaged the peak only reaches 79.

 

Since writing my original post I sorted the original data to get rid of all -106 values and change them to 0 or something like 70.  This helps eliminate the sensing of a rising edge as -106 changes to 25.

0 Kudos
Message 3 of 7
(3,487 Views)

I had the exact same problem (pulses through fibre optics). Only I had to do it on a FPGA at 8MHz, times 6 channels and after a 13th order 24 bit FIR filter...

 

I (also) solved the ramp problem by a dead time before and after the pulse. Before the pulse isn't that difficult, but after is a bit of a challenge (on an FPGA, but also in normal LabVIEW).

0 Kudos
Message 4 of 7
(3,483 Views)

Seems a little better but take a look at index 8.  The average value is off.

 

When I first started this I never imagined it being that difficult. . . .

0 Kudos
Message 5 of 7
(3,476 Views)

The 8th peak is a bit off. So the average might not be the best function to get results. Or more needs to be cut of from the beginning (and the end).

 

A measures of mean with median input type seems to do a good job.

 

Obviously you need to figure out how, if and why that works, just inserting random functions until it works will bite you after a while.

 

I've added the graphs in one XY plot. That (the way it's done) is a quick hack, but it does the trick.

0 Kudos
Message 6 of 7
(3,468 Views)

Brilliant.

 

That is exactly what I was looking for.  I kept going down to the rabbit hole of taking the average.  The Median combined with a window around it should give me exactly what I am looking for.

 

I am going to go check out your code right now.

 

I thank you fine Sir or M'aam

0 Kudos
Message 7 of 7
(3,462 Views)