Quick question on encoders and sensor from a mentor new to the encoder and sensor world.
We have an actuator arm that moves plus or minus 90 degrees. Our current set up from last season’s game has a small encoder, I am guessing a US Digital MA3, mounted in the end of the hex shaft that rotates the actuator arm. The end of the hex shaft was drilled to accept the shaft from the encoder. During most of the year we seemed to battle the actuator arm not holding values, likely due to the encoder not being secured in its bracket, or slipping in relation to the hex shaft. As a last resort, everything was epoxied in place to try and maintain position. Unfortunately, things are still moving, so now is a good time to try something different.
If you had a hex shaft that was rotating an arm approximately 90 degrees, what would you recommend for an encoder or sensor, and how would you recommend attaching the encoder or sensor to the end of the hex shaft?
Any suggestions or recommendations are appreciated. Again, just trying to get up to speed as kids have graduated, and some mentors have moved along.
I’m a big fan of a 10-32 tapped hole in the end of the shaft, a 10-32 screw with loc-tite (or a lock nut) in it, and surgical tubing stretched over the screw on one end and the encoder on the other. If the encoder is mounted properly and not damaged, it should spin very freely and the surgical tubing grip is more than enough to ensure 1:1 rotation on the arm. The tubing also allows for some axial misalignment which is common on FRC robots.
For something moving less than a full rotation, I would use a potentiometer. It has the advantage of giving an absolute measurement. You still have the issue of having to lock the shaft and securely mounting the potentiometer body.
If it’s only going to be moving 90 degrees, a potentiometer would probably work better for your purpose. You would also probably need to make an adapter of some sort to connect the potentiometer shaft to your arm, since they typically come with a round shaft with a flat slot.
Would a potentiometer have the same programming as the encoder? Would it always know where say zero degrees is and where 90 degrees is, and everything in between? Or, would we have to set zero each time?
I thought I heard something about that with different types of sensors???
You’ll read the position of the potentiometer (pot) using the analog in. The output is 0-5 Volts (assuming you use the 5V source on the roborio). You’d have to calibrate it yourself for 0 degrees but after that it shouldn’t change.
for that use, I prefer a potentiometer, as it’s the easiest for getting an absolute position reading out of. And if you set it up correctly, you can get it mounted without too much difficulty.
The key for mounting is planning ahead. You really just need to ensure that the hole in your mounting plate is aligned with the shaft. There are several ways to do this, depending on the exact situation, but I find it’s easiest to get everything set up and then drill through everything all at once with a pilot hole, then use that as your center to enlarge everything to the sizes you need for shaft, bearing, potentiometer, etc.
After that, you just need to put a hole in the middle of the shaft with a lathe, if you have one. If not, surgical tubing does work great for joining those together!
May potentiometers also have a flat on one side of their shafts - this is a great place to locate a set screw, ensuring the shaft and potentiometer rotate together.
Many potentiometers are also designed for easy stable mounting, by having a small raised peg to one side of the shaft - you just need to drill a small through-hole for that, and the potentiometer won’t move once it’s mounted!
Whenever possible, I like to add limit switches to both extremes as well. It’ll help make sure your arm doesn’t tear itself apart if the potentiometer fails!
programming is different. A potentiometer is an analog device. As you rotate the shaft, the voltage of the output changes incrementally. WPILib actually has a rather nice class (AnalogPotentiometer) that can be used for this - when you create the instance, you can specify the range of the potentiometer (They’re sold as 270 degree, 360 degree, 3600 degree, etc) and an offset for where you want 0 to be. That way when reading values you’ll get them right in degrees, positive or negative.
Oh, and another benefit to potentiometers… being analog devices, they’re really easy to verify functionality with a multimeter!
That’s an interesting question. The easiest way is to have your programmers write a little test program (or debug code in your real program) that spits out what angle it thinks the arm is at. Rotate the arm to one extreme and record the value somewhere, then rotate it to the other and record it. That gives you values for 2 fixed, known points of reference. Then drive around, play the game a while until you think things are off, and repeat the test. Are the values the same (or at least very close to the same), or are are they different?
Do that several times and you might notice a pattern that shows slippage in the system.
If, on the other hand, the values at the extremes stay the same but you notice the arm is “drooping” from where it should be, or oscillating around where it should be, that would indicate an issue with your feedback loop in maintaining the proper position, not an issue with the sensor.
I prefer the 360 to the 270 degree potentiometers. The 270 ones have a hard stop that can break in your mechanical guys are careless on the installation. On the 360 ones you have to be sure that the usable range doesn’t include the 0 to 360 cross over. The other thing to watch for is the two types of potentiometer: linear and logarithmic. You want a linear one for positioning.