How to use the encoder properly?

I want to use the encoder to design for the autonomous mode or measure the velocity basically. But now I am confused with how to use it properly… I’ve seen many stuff about encoders. Some encoders are installed on the speed controller (ex:Talon SRX). There are also some encoders that are installed directly on the backside of motor (ex: 775 Encoder Mounting Plate). I also have seen some people directly connect “Data Cable for Talon SRX” with Talon SRX. So I wonder if I use the encoder that can be installed at the backside of a motor, I do not need to install another encoder for the speed controller.

I wish someone could clarify how to use the encoder specially!! Mainly for RS775 pro, 775 redline, Talon SRX, SPARK, and CIM motor.
Thank you very much!!!

An encoder is a sensor that measures the speed of a shaft.

The encoders, boards, and wires that are for the Talon SRX allow you to connect the encoder directly to the speed controller. In this way you can offload your control loops that use the encoder to the speed controller’s processor.

There are two “ends” of an encoder–the mechanical input, and the electric output. The motor or gearbox turns the encoder, and the electrical output goes to an electronic device to be used by a program, to control the motor speed, based on what the encoder tells it the motor is doing.

If the encoder is connected to a speed controller, then it is likely that the speed controller is connected to the roborio via a CAN bus.

If the encoder is not electrically connected directly to the speed controller, then you need to connect it to the roborio, instead.

There is a lot to it…once you get the encoder installed to the motor or gearbox, and connected to a speed controller or the roborio, you then need to program it to do something, such as control the motor speed, based on the encoder feedback.

1 Like

Thank you for your reply!
I see what you’re saying. I just find out that, the Encoder Mounting Plate (for 700 series) also needs AM Mag Encoder to work together. So I consider the mounting plate as the sensor that transmit signal to the Mag Encoder which works as a processor, and then the Mag encoder communicates with roboRio. And what exactly Quadrature means? It appears on one port of the Mag encoder. Thanks!!~

No. The mounting plate is literally only a mounting plate - something to allow you to physically affix an encoder (the AM Mag Encoder in this case) to your motor.

Wikipedia can explain this better than I can:

I see your point about wire management of encoders. So I may install the magnetic encoder on the motor and then use the cable to connect the encoder and Talon SRX. I saw some pictures about this. The reboRio could receive the feedback through the CAN wire on Talon SRX right?

Oh thank u. It seems I thought too much…:sweat_smile:

That’s correct.

A quadrature encoder can tell you which direction the motor or shaft is turning. An simple encoder that does not have this feature will only be able to tell you how much it turned, not which direction.

Does anyone know about “VersaPlanetary Integrated Encoder”. I am going to buy the VersaPlanetary Gearbox, so I am thinking I could use the integrated encoder directly. Do you have any suggestions based on this encoder. Honestly I haven’t seen many team use this exact encoder…

We’ve used the integrated encoder in the past with great success, for example we used it in 2018 to control our lift’s height. IMO the most important thing to keep in mind with it is that it will change the external profile of the gearbox by sticking out one of the sides, and it also will make the gb longer because it functions as an extra stage.

This function as an extra stage also means that you can get different values from the encoder when the gearbox has turned the same amount depending on where in the gearbox you place it. For example, let’s assume you have a 20:1 gearbox made of a 5:1 stage and two 2:1 stages (yes I know you wouldn’t actually do this but it’s an analogy). If you were to place the encoder after the 5:1 stage but before the two 2:1 stages, the encoder would see “one turn” after the output shaft has turned 90 degrees, whereas if you place it after the 5:1 stage and a 2:1 stage, the encoder would see “one turn” after the output shaft has completed half a revolution. For this reason, it is very important to know the gearing leading up to your encoder to get accurate distance measurements.

Oh it sounds it’s a great choice to use it. So basically it is better than using a simple encoder on the motor right?

It depends on the application. For example, I personally wouldn’t use this type of encoder on a drivetrain, I would rather use a grayhill 61R, but as a general rule the SRX mag encoder (What you’re referring to as the integrated encoder) is very very good for things like arm and lift motors.

Another thing I forgot to mention is that the farther away in the gearbox from the output shaft you put the encoder (i.e. how many stages between encoder and output), the lower resolution you will get from the encoder. In other words, the more stages between the output shaft and the encoder,the more slop you start to introduce. Due to the fact that humans cannot manufacture completely pefrect parts, gear stages will not alwyas be exactly 2:1, or 5:1, or 4:1, or what have you. They will be closer to 4.001:1, which seems like a small difference, but can add up quickly when you have 4 or 5 stages in your gearbox. This could eventually lead to your mechanism moving too far by something like a 1/4", or even a few inches if it’s the drivetrain.

I see. But I was thinking that putting the encoder at the last stage is the best choice, because with that we do not need to write too many codes calculating the actual distance the robot moves. With your saying, if the encoder is put far away from the output shaft, the less resolution I will get. Why is that?
Thank you!

Disclaimer: I am not a programmer and do not know code super well
Putting the encoder as close as possible to the output shaft is going to make it so that you have to code less, as the output shaft rotations and encoder rotations will either be very close to equal, or equal. I think there also may be some confusion as to what the output shaft I am referring to is. In this situation, the output shaft would be the shaft that your wheel, arm, or mechanism is directly attatched to.

As for your resolution question, I’ll bet that someone can answer this better than I, but the way I was taught was the way I described in my last post:

Due to the fact that humans cannot manufacture completely pefrect parts, gear stages will not alwyas be exactly 2:1, or 5:1, or 4:1, or what have you. They will be closer to 4.001:1, which seems like a small difference, but can add up quickly when you have 4 or 5 stages in your gearbox.

Essentially what this means is that in a 16:1 gearbox, rather than having two perfect 4:1 stages that together create a gearing of 16:1, you may have a 4.05:1 and a 4.02:1 stage due to imperfect manufacturing processes. When combined, these stages would create a gearing of 16.281:1, which is a fairly large difference from the perfect 16:1 gearing that your code may assume. Over time, this difference in gearing may lead to a significant difference between the distance your robot has actually moved and the distance your code thinks it has moved.

Again, I am not the be-all-end-all of code things, so if something I wrote is incorrect, someone please correct me for both my reference and Bill_sir’s.

This is not the best way to think about this issue. Let’s assume you had a 4.001:1 gearbox, with a perfect 10 tooth gear and a “40.01 tooth” gear. Then, after 100 turns, the tooth mesh would have migrated by one tooth. That is, after 50 turns, a tooth peak must have matched up with another tooth peak. Obviously, this is not physically possible.

What is actually happening is known as backlash. Because humans can’t manufacture perfect parts, the teeth of a gear do not mesh perfectly. Therefore, every time you turn the first gear in a reduction, there is a moment where the second gear doesn’t turn yet, since the teeth first need to make contact. This is what introduces error, and why it’s best to have the output nearest the output shaft (to the mechanism, such as the drive train, arm, etc.).

5 Likes

Good to know, thanks!

I’ll take a stab at it. And it’s actually not strictly the case about the accuracy of parts, though that will have some effect.

What you’re looking for is “backlash” and “slop”. Due to design and manufacturing, almost all motion systems will have just a little bit of a deadband somewhere in the system. The deadband is where you can change direction of motion and not notice. You might see it within a single gearbox stage, though that does tend to be slight. It’s more noticeable in a chain run, especially a poorly-tensioned one. The problem is when they stack up, it’s VERY noticeable. Take an arm that’s been chain-run and geared, watch the motor shaft closely, and see how far you have to rotate the arm to see the motor move. You’ll probably get at least a couple of degrees. Now do it again, but watch the output shaft. You might get one degree.

So you want the encoder on the arm shaft, where you don’t have to worry about that backlash, or as close as possible (and all the power transmission between the arm and encoder/pot/hall-effect sensor should be as tight as possible).

I will say that for more $$$ than FRC allows, there are gearmotors (motors with an integrated gearbox) that have encoders mounted on the back side of the motor from the gearbox. There are also servomotors that do the same sort of thing. However, these motor types rely on tight and backlashless power transmission to be right–so you want a direct connection wherever possible. Just had a discussion yesterday about that at work, involving the fact that “yes, we can do that, but it’ll be heavy, and no we can’t use aluminum for the shaft because it will deflect and throw us off by a couple of degrees and the steel keeps us under a degree”. Fun times.

For the curious, there is another (impractical to FRC) way that engineers account for backlash in certain situations. In very high precision applications (my experience with this was at a neutron beam in a national lab), the motor can be always driven the same direction last. For example, it would drive normally if the motor was moved counter-clockwise to a certain position. However, if you wanted to move the motor clockwise to a given position, it would over-shoot its goal, then move counter-clockwise back to its goal position. Because the same side of the gear was always used for the precision movement, positional accuracy could be extremely high.

1 Like

Couple of things to consider when picking encoders as a team in China.

It is usually much easier to get VEXpro parts vs AndyMark, VEX have a dedicated website for Chinese sales and the shipping is very cheap and fast from Shenzhen. The product pricing is also only slightly higher than the exchange rate and you do not need to pay expensive international shipping or taxes.

https://vex.hexbugvex.cn or https://www.innovationfirst.cn/ if you haven’t been buying from here already.

AndyMark use distributors in China who significantly markup the items, so it is better to just use VEXpro.

If you want to put an encoder on something which uses a VersaPlanetary Gearbox then use the Integrated Encoder, this works well and is a good encoder, the cables are just a little fragile so be mindful.

For the Data Cable to connect between the Magnetic Encoder and the Talon SRX, you can just buy cable and connectors on TaoBao and make your own which will allow you to reduce cost while being able to choose the length.

If you want an easy way to put encoders on your drivetrain consider using one of the NEO brushless motors with the integrated encoder, I believe REV is able to send these from within China meaning you won’t need to order from the US.

Otherwise there are plenty of decent reliable encoders available on TaoBao, you will be able to attach one of these directly to your axle and then connect it directly to the RoboRio.

If you send me a Private Message, I am happy to send you some links to specific parts or give other Encoder advice via WeChat.

1 Like