Electronic – Measuring phase difference between digital signals

encodermeasurementoscilloscope

I have been struggling for some time to come up with a meaningful way to test the phase difference between two quadrature channels of an encoder. I have access to a DPO 2014B Tektronix scope and have been trying to come up with a way to make it do what I want, but have had no such luck.

An ideal quadrature encoder should have 90 electrical degrees of separation between any of its subsequent quadrature edges (A high to B high, B high to A low, A low to B low, or B low to A high). Ch. 1 is A and Ch. 2 is B in this case (see below).

EncoderSignals

As we all know, the ideal case typically isn't the observed case. The encoder under scrutiny has a specified edge separation that it must meet and I am interested in measuring the smallest of those to ensure it meets the specification set forth. The encoder has 1024 cycles (so 4096 edges) per mechanical revolution. The third channel contains the index pulse which occurs once per mechanical revolution.

That being said, first let me explain the two methods I have tried so far:

  1. Configure the cursors to the known value for the specification that must be met and physically check each set of edges. This method works, but with so many edges to check is highly impractical.

  2. Use the phase difference measurement of the scope. I had high hopes for this one, but after some back and forth with the support team at Tektronix, found that this actually only measures the average phase difference between the first two pulses on the screen. This is signified in the picture by the two sets of vertical lines to the left of the screen.

I would be fine with not measuring the ABSOLUTE smallest edge separation between all of the edges, but I at least need something that could either come up with an average value, or can sample randomly across the entire waveform.

Does anyone have any ideas? Thanks in advance!

Best Answer

If this is a one-off evaluation, then manually is probably the least worst way to do it. But you could use the scope better to help you. The eye is very good at seeing texture. I suggest changing the display so that a failing edge seperation looks like a change of texture, that your eye can pick out easily from 100 good ones, rather than having to scan vertically between two very offset traces.

Does the scope have a deep memory? It's a Tek, so I imagine it would. Record a whole cycle as a single shot. Then expand the trace and use the time offset control to scroll through it.

Adjust the vertical offset to mostly overlay the traces, then your eye has to do less visual interpolation.

Adjust the horizontal gain so that there is some, but minimal, ideally one pixel, black space between the verticals of the traces. If this space disappears, it should be very apparent as a break in the regularity, a change in the texture, of the pattern.

If it needs to be done more than once, then you must automate. Drive the encoder shaft with a motor.

Off the shelf scopes are all well and good, but you are limited in what they can compute. I suggest using Python on a PC, with matplotlib for graph plotting to see what's happening, to examine the spaces between transitions pulse by pulse. Get your data either with a dump from your existing scope, or use the two channels of a sound card for the two encoder channels, with pyAudio to interface to it. When I needed a phase meter with 0.01 degree resolution for work, I couldn't buy or hire one, so wrote one with Python and a standard sound card on my work PC.