Alex Rivera | Logout

Algorithm to determine the effective "phase difference" between two signals with different frequencies?

Asked 2009-07-21T07:36:09.297
9

The quick version:

What algorithm could I use to determine the "phase difference" between two square wave signals with different frequencies, if the only information that I have is the time at which each rising edge occurs?

The detailed version:

I'm working on an embedded software project, and I have run across an interesting problem. I am collecting data from two hall-effect speed sensors, which are each aimed at one of two meshed gears, as shown in the following diagram:

meshed gears and pulse signals

note:
As Jaime pointed out, the signals in this diagram would actually have identical frequencies. The real hardware has several more gearing stages between the two target gears, some of which are connected by shafts instead of meshed teeth, so I do end up with two square waves that have different frequencies, and the ratio between them is still a constant. I wanted to simplify the diagram to get to the meat of the matter, but it looks like I simplified it too much!
/note

The speed sensors output a square wave signal whose frequency is directly proportional to the rotational speed of each gear. The rising (and falling) edges of the square wave occur when the leading (and trailing) edges of a single gear tooth pass by the sensor.

I know how many teeth are on each gear, and based on this information I am able to accurately measure the rotational speed of each gear based on the frequency of the square wave signals.

To measure the frequencies, I have each speed sensor signal connected to a high-speed capture timer pin on t

Edit
Report

1 Answer

2

The overall signal, i.e. the signal that you get when you add the red and the blue, has a phase length of 16 times the blue and 9 times the red signal. You could measure the time difference between every 16th blue and every 9th red rising flank.

I guess that what you want to measure is the wear on the gears. I think that this measurement might be influenced (introducing noise) by the gears' tolerance, if there is no uniform traction.

answered 2009-07-21T08:14:49.720

Your Answer