Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


low-speed quadrature algorithm

low-speed quadrature algorithm

low-speed quadrature algorithm

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?


RE: low-speed quadrature algorithm

I think you may have misunderstood something. I can always read the quadrature count, the problem that occurs with the low-speed algorithm is when the machine is in neutral (ie, bottom of the CVT speed range) or the transmission is disengaged. The vibration of the motor causes the count to wobble +1, -1, +1, -1 and this triggers the timer used in low-speed calculation, which then calculates to a speed that is not actually occuring (because it isn't actually going anywhere).

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

"cause one of the quadrature signals to oscillate and the other to stay still"

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


FAQ731-376: Eng-Tips.com Forum Policies

RE: low-speed quadrature algorithm

That is correct, the shaft is not turning, it is just vibrating so only one part of the quadrature is oscillating. The problem that this causes for the low-speed algorithm is that the counter repeatedly resets and causes a falsely-low time reading which creates a falsely-high speed reading - hense, when the machine is in neutral it is reading a bouncing speed on the screen (and in the control algo).

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

RE: low-speed quadrature algorithm

My "possible" solution has created a massive improvement in the low-speed control. 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).

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.


RE: low-speed quadrature algorithm

Is there no "edit" function on this board?

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

Sadly no - there is no editing facility..

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

Good thought, but I need to monitor the counts in neutral because half of this machines operation is someone manually turning the shaft.

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close