Quadrature Encoder Positon Powerup value

Questions about using encoders with the Roboclaw product line
Post Reply
posplayr
Posts: 4
Joined: Mon Oct 10, 2016 10:04 pm
Quadrature Encoder Positon Powerup value

Post by posplayr »

My first post.

I'm pretty familiar with servos and motor control. Have reviewed the RoboClaw manual but have a question because of a difference in a reference to an Encoder Count and an Encoder Register. (not sure these are exactly the same).

The quadrature encoder is a differential encoder (i.e not absolute encoder) so it usually needs to be initialized to some start position at power up. I would just like to confirm that the command to set the initial counts are: Encoder Commands 22/23
and then from then on the positions can be read using Commands 16/17?

That is it; TIA. :P

Commands for reference below:
16 Read Encoder Count/Value for M1.
17 Read Encoder Count/Value for M2.

16 - Read Encoder Count/Value M1
Read M1 encoder count/position.
Send: [Address, 16]
Receive: [Enc1(4 bytes), Status, CRC(2 bytes)]
Quadrature encoders have a range of 0 to 4,294,967,295. Absolute encoder values are converted
from an analog voltage into a value from 0 to 2047 for the full 2v range.

22 Set Encoder 1 Register(Quadrature only).
23 Set Encoder 2 Register(Quadrature only).

22 - Set Quadrature Encoder 1 Value
Set the value of the Encoder 1 register. Useful when homing motor 1. This command applies to
quadrature encoders only.
Last edited by posplayr on Wed Oct 12, 2016 11:46 am, edited 1 time in total.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Quadrature Encoder Positon Powerup value

Post by Basicmicro Support »

Yes, that is one way of doing it. Also you can setup the S4 and S5 pins(for channels 1 and 2 respecively) as Home signal imputs. Then the home signals trigger(eg get pulled low) the respecitive encoder count will be reset to 0. The Home signals will also stop the motors when the motors are moving in the reverse direction(eg toward the home switch).
posplayr
Posts: 4
Joined: Mon Oct 10, 2016 10:04 pm
Re: Quadrature Encoder Positon Powerup value

Post by posplayr »

I gather the home mode is intended to be used with a "zero" limit switch of some sort.
Problem is that requires physically driving to zero to establish absolute reference for the encoder(not feasible in my case). Additionally for my applications a multi turn limit switch would be prohibitive.

1.) Basically I would envision the external controller to maintain absolute position of the quadrature encoder (unless there is a mode in the RoboClaw to do that) from previous power down and use that value to restore the RoboClaw position register to that value at startup. On power up that position is written to the RoboClaw as a zero (starting) position at startup.

2.) I assume if the position command is set the same and the amplifier activated the motor will not move (much)?

3.) Is there another way to maintain absolute reference across power downs with the quadrature encoder?
74 - Set S3, S4 and S5 Modes
Set modes for S3,S4 and S5.

Home(M1 & M2): will trigger the specific motor to stop and the encoder count to reset to 0.
Last edited by posplayr on Wed Oct 12, 2016 11:47 am, edited 1 time in total.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Quadrature Encoder Positon Powerup value

Post by Basicmicro Support »

1. No, the Roboclaw does not keep track of the quadrature count between power cycles. In order for a quadrature encoder to be used as an absolute position sensor you will need to keep the system powered at all times if there is any possibility of external forces moving the encoder. Note the roboclaw have a minimum draw between 20ma and 40ma plus whatever the encoders will draw so this is usually not an option with battery powered systems.

However, If you are using something that cant be back driven(like a linear actuator or high ratio worm drive) then the problem is less difficult. You just need to save the last encoder value in non-volatile memory on your controller before shutting down and then reload the value after powering back up. We dont do this because most systems will backdrive when powered down and you end up losing the position anyway so you will have to implement the save/load in your controller.

2. Yes. Set the encoder position, then send a command to "move" to that position.

3. See 1.
posplayr
Posts: 4
Joined: Mon Oct 10, 2016 10:04 pm
Re: Quadrature Encoder Positon Powerup value

Post by posplayr »

Thanks for the additional details. In my case yes the actuator cant' be back driven and further the actuator will be set to an initial known condition prior to each in flight power up.

On a related topic: Quadrature Encoder resolution.

I plan to produce a simple multi detector Quadrature encoder PCB to mount to the output of a multi turn actuator.(it is cheapest).

Does RoboClaw register an encoder count (either increment or decrement) on each positive or negative "edge" of either encoder signal? If so then that would mean there are 4 counts per cycle of either Quadrature wave forms on EN1 or EN2.

If not 4 encoder counts per Quadrature wave cycle, what is it?


EDIT: I found the following under
Velocity Calibration Procedure.
1. Determine the quadrature pulses per second(QPPS) value for your motor. The simplest
method to do this is to run the Motor at 100% duty using IonMotion and read back the speed
value from the encoder attached to the motor. If you are unable to run the motor like this due to
physical constraints you will need to estimate the maximum speed in encoder counts the motor
can produce.
Is QPPS the number of pulses on either quadrature signal?

What I'm trying to determine is Register Counts per Quad Pulse.

Basically I'm trying to calculate distance resolution of the encoder I'm planning to design (i.e. inches/count)
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Quadrature Encoder Positon Powerup value

Post by Basicmicro Support »

Roboclaw counts each edge of each quadrature pulse on each signal line so 4 counts per period.

QPPS is the maximum speed of the encoder/motor in counts per second.
posplayr
Posts: 4
Joined: Mon Oct 10, 2016 10:04 pm
Re: Quadrature Encoder Positon Powerup value

Post by posplayr »

acidtech wrote:Roboclaw counts each edge of each quadrature pulse on each signal line so 4 counts per period.

QPPS is the maximum speed of the encoder/motor in counts per second.
Glad I asked about QPPS. That acronym/name is definitely misleading.

Sounds like anyplace I see QPPS/QP I can replace counts/sec and counts respectively.

For anybody else this means:

Given K pulses per Revolution (from either quadrature encoder signal),

There are always 4 encoder counts per pulse

Counts per Revolution = 4 * K

Obviously to convert revolutions to linear distance given a Diameter D

distance per count = (distance per revolution) / (counts per revolution) = ( PI * D ) / (4 * K)




Thanks for the clear responses.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Quadrature Encoder Positon Powerup value

Post by Basicmicro Support »

Correct. QPPS is a hold over from a long time ago. I prefer to think of it as counts of the edges of the quadrature pulses.
jorchard
Posts: 6
Joined: Fri Mar 10, 2017 7:51 am
Re: Quadrature Encoder Positon Powerup value

Post by jorchard »

posplayr wrote:
acidtech wrote:
....
For anybody else this means:

Given K pulses per Revolution (from either quadrature encoder signal),
There are always 4 encoder counts per pulse
Counts per Revolution = 4 * K
Obviously to convert revolutions to linear distance given a Diameter D
distance per count = (distance per revolution) / (counts per revolution) = ( PI * D ) / (4 * K)


Thanks for the clear responses.

Reading this has been helpful, but I am yet to crack how to get a useful reading from the Encoder.

I've managed to tune for velocity and position, i.e. PID parameters as guided in the manual, however I need further guidance on how to map the encoder count to rotation in degrees, then map that degrees to the PWM I'm using to control the motor.

I'm using RC and control is done from an Arduino, where I'd like to capture the encoder counts also. Could you please explain how I can get this to work? Thanks
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Quadrature Encoder Positon Powerup value

Post by Basicmicro Support »

The simplest option is to turn the output shaft one rotation while the motor is off and read the total counts. Then divide the counts by 360 to get counts per degree.

You cant read the encoder counts while using RC control mode. If you are using an arduino you should use packet serial instead so you can control the motor and read back the encoder positions.

Post Reply