## low-speed quadrature algorithm

## low-speed quadrature algorithm

(OP)

Hello all,

I am using a quadrature sensor on a motor-driven piece of farm equipment that spins at a wide range of speeds under normal use (uses a hydraulic CVT). The quadrature signal may be in the low kHz range down to a complete stop or 0.5Hz.

At present I am using two speed algorithms. One works great and the other not so much...

High-speed algorithm: Delta-quadrature per time

The quadrature value is sampled about every 100ms and a rolling buffer of about 2.5 seconds of data is collected. The sum of the buffer is directly proportional to speed and is converted with a multiplier to the required units of measure.

Low-Speed algorithm: Delta-time per quadrature step.

An 8MHz clock counts the time between quadrature signals.

The sampled value will be either the last completed time segment or the current time count if it is greater than the last completed one.

This value is inversely proportional to speed and is converted with a multiplier to the required units of measure.

A measurement over a given threshold is indicated as zero speed.

The decision of which algorithm to used is based on the sum of the high-speed buffer. If it is great enough that we are within our resolution tolerance (+1 or -1 count in the sum is still a small enough step in the final answer to be useful) otherwise, we use the low-speed algorithm.

Okay, this has been really long-winded so far, sorry...

First and most basic question - is there simply a more standard, known, works-great algorithm for doing what I'm doing here? This would be great.

Second question - the lowspeed algorithm suffers a terrible flaw. If the engine on the machine is running but the shaft is not turning it will vibrate and cause one of the quadrature signals to oscillate and the other to stay still. The count stays the same so the sum is low and it uses the low-speed algo which sees the quadrature count changing and triggers the timer - the display shows the speed bouncing all over the place.

er... help?

THANKS!!!

Matt

I am using a quadrature sensor on a motor-driven piece of farm equipment that spins at a wide range of speeds under normal use (uses a hydraulic CVT). The quadrature signal may be in the low kHz range down to a complete stop or 0.5Hz.

At present I am using two speed algorithms. One works great and the other not so much...

High-speed algorithm: Delta-quadrature per time

The quadrature value is sampled about every 100ms and a rolling buffer of about 2.5 seconds of data is collected. The sum of the buffer is directly proportional to speed and is converted with a multiplier to the required units of measure.

Low-Speed algorithm: Delta-time per quadrature step.

An 8MHz clock counts the time between quadrature signals.

The sampled value will be either the last completed time segment or the current time count if it is greater than the last completed one.

This value is inversely proportional to speed and is converted with a multiplier to the required units of measure.

A measurement over a given threshold is indicated as zero speed.

The decision of which algorithm to used is based on the sum of the high-speed buffer. If it is great enough that we are within our resolution tolerance (+1 or -1 count in the sum is still a small enough step in the final answer to be useful) otherwise, we use the low-speed algorithm.

Okay, this has been really long-winded so far, sorry...

First and most basic question - is there simply a more standard, known, works-great algorithm for doing what I'm doing here? This would be great.

Second question - the lowspeed algorithm suffers a terrible flaw. If the engine on the machine is running but the shaft is not turning it will vibrate and cause one of the quadrature signals to oscillate and the other to stay still. The count stays the same so the sum is low and it uses the low-speed algo which sees the quadrature count changing and triggers the timer - the display shows the speed bouncing all over the place.

er... help?

THANKS!!!

Matt

## RE: low-speed quadrature algorithm

TTFN

FAQ731-376: Eng-Tips.com Forum Policies

## RE: low-speed quadrature algorithm

Is nobody aware of any standard way to measure speed via quadrature that accepts very low input speed with resistance to this sort of oscillation?

## RE: low-speed quadrature algorithm

That's your posting that I "misunderstood." If one is toggling, and the other is not, then it's either broken or not moving.

TTFN

FAQ731-376: Eng-Tips.com Forum Policies

## RE: low-speed quadrature algorithm

I have come up with a possible solution. I will post it if this works.

## RE: low-speed quadrature algorithm

I made the low-speed algorithm have two counters. One for up and one for down. The last direction that has been moved twice consecutively determines which counter to use, and the counter is not reset until there are two consecutive moves in one direction.

So as the shaft turns slowly there will be noise around the transitions, but only the counts in one direction at a time will be observed.

However, it appears that when the machine is in neutral or the transmission is disengaged the vibration of the motor seems to be able to cause the quadrature count to make two steps and there is some speed reading making it through the filter.

So I tried making it take 3 steps in a given direction before it begins to use that counter, but I did not force it to make 3 consecutive steps before resettting... this still let the noise through. I need to take care of the latter part.

I don't believe that I need any more help, I just figured I'd post this for searchability for the next guy dealing with this.

-Matt

## RE: low-speed quadrature algorithm

Anyway, my second sentance reads:

I dare say it is perfect when moving very VERY slowly, but it is still jumpy (about 1/10th the magnitude and 1/10th the regularity).

but was supposed to read:

I dare say it is perfect when moving very VERY slowly, but it is still jumpy (about 1/10th the magnitude and 1/10th the regularity) when in neutral or disengaged.

## RE: low-speed quadrature algorithm

Can you get out of the box on this one? If you are in "neutral" why not just block any signal or disable the drive and continue monitoring the counts.

Keith Cress

kcress - http://www.flaminsystems.com

## RE: low-speed quadrature algorithm

The machine is a hose reel. The operator puts the machine in neutral to pull out the hose with a tractor, then the engine is used to reel it back up again (big, long hose with a sprinkler head at the end. Speed control is to determine how deep the water is accumulated from the sprinkler.)

With the improvement that I have made the product should be acceptable (not exactly a high-precision instrument) so we're leaving it as is for now to tackle bigger issues.

Thanks for you input.