Quadrature Encoder Velocity

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
tabec_2239786
Level 1
Level 1

Noobie to PSoC here,

I have the CY8CKIT-059 PSoC 5LP kit.

Background on what I am trying to accomplish: I am trying to read the velocity of a quadrature encoder which is 256 counts per revolution. I only need to measure the A or B wire because I do not care about direction.

The signal from the encoder is a 50-50 duty cycle square wave. My goal is to find the frequency of this square wave in hz.

I figure that I by measuring the frequency of the ticks of the rotary encoder, I can find the velocity. This sounds simple in my head but I'm having difficulty actually implementing this. Can someone point me in the right direction? (Remember, I'm a noobie)

Thanks,

Tanner Beard

0 Likes
1 Solution
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

Tanner,

I've had experience in a project similar to what you describe.  I used Hall sensors configured as quadrature output on a motor to determine relative speed but more importantly for my application: Position.

If you're not looking for direction, theoretically you only need 'A' input.  Input 'B' only gives you twice as many counts in the same revolution.  If you're looking to use it for positioning data, you will need 'B' to be 2x more precise.

\odissey1 is correct, the link will help to determine frequency fairly accurately.  However, I've never known a motor to be highly stable frequency-wise.  Due to many factors including fluctuating system voltage, over- or under-sensitive motor control circuits and cogging-torque, the movement of the motor (and hence the output of the quadrature outputs) will have a fluctuating frequency.  Therefore having a very accurate frequency measurement will be futile.

If you do need frequency, the easier/quicker method is to create a table (or formula) where the counter ticks between quadrature pulses equal a frequency value.  Using a counter with an input clock at least 10x faster than the maximum pulse frequency will give to a reasonable frequency table.  If more accuracy is needed, you need to increase the counter frequency (and possibly the # of bits of the counter).

If speed of the motor needed, you can create a table (or formula) where the counter ticks between pulses equal a speed value.

Similarly, if positional data is needed, a table or formula with a 0% to 100% travel (assuming a motor is driving a rotational-to-linear mechanism) can be effectively used.  Of course since the quadrature signals are only relative based signals, you will need some reasonable determination of the 0% and 100% reference points to translate the relative sensor to be absolute in your system.

Len

Len
"Engineering is an Art. The Art of Compromise."

View solution in original post

0 Likes
2 Replies
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Tanner,

You can obtain RPM speed by measuring encoder channel A frequency with FreqMeter component, see #28 of the discussion:

Re: HELP, with example of frequency measurement Error

This method is very accurate (~1ppm) and has large dynamic range, but not very fast (as shown, the minimum time base was set to 50ms), which is OK for motor with large inertia. This approach can be expanded further to measure quadrature signals (A+B) if really necessary.

It is sufficient to measure signal from a single channel (A or B) if direction of rotation is always the same, and the encoder has no noise. At 256 counts per revolution, the encoder is likely the optical one with clean output.

/odissey1

0 Likes
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

Tanner,

I've had experience in a project similar to what you describe.  I used Hall sensors configured as quadrature output on a motor to determine relative speed but more importantly for my application: Position.

If you're not looking for direction, theoretically you only need 'A' input.  Input 'B' only gives you twice as many counts in the same revolution.  If you're looking to use it for positioning data, you will need 'B' to be 2x more precise.

\odissey1 is correct, the link will help to determine frequency fairly accurately.  However, I've never known a motor to be highly stable frequency-wise.  Due to many factors including fluctuating system voltage, over- or under-sensitive motor control circuits and cogging-torque, the movement of the motor (and hence the output of the quadrature outputs) will have a fluctuating frequency.  Therefore having a very accurate frequency measurement will be futile.

If you do need frequency, the easier/quicker method is to create a table (or formula) where the counter ticks between quadrature pulses equal a frequency value.  Using a counter with an input clock at least 10x faster than the maximum pulse frequency will give to a reasonable frequency table.  If more accuracy is needed, you need to increase the counter frequency (and possibly the # of bits of the counter).

If speed of the motor needed, you can create a table (or formula) where the counter ticks between pulses equal a speed value.

Similarly, if positional data is needed, a table or formula with a 0% to 100% travel (assuming a motor is driving a rotational-to-linear mechanism) can be effectively used.  Of course since the quadrature signals are only relative based signals, you will need some reasonable determination of the 0% and 100% reference points to translate the relative sensor to be absolute in your system.

Len

Len
"Engineering is an Art. The Art of Compromise."
0 Likes