Get Angle from Servo


I am attempting to use a servo mounted on the robot that will spin with the claw so that I can get the correct angle of the claw after calibration.

I understand for writing the Servo angle uses the PWM Outs on the DSC. Is there a PWM channel that can be used to read the value of the servo as well?

Davis C

To be clear, you want to back drive the servo manually to a position to perform a “calibration” of the desired angle?
You can’t read the position back through the PWM channel. You’ll need to add a sensor here to accomplish this.
Describe your calibration process a little more and maybe we can offer some different options.
Also, you want want to make sure the servo is powerful enough to do the job (rotating a claw?). FIRST doesn’t allow very powerful servos as their power supply comes from the DSC.

Sorry for the confusion. My plan was initially to have the claw (powered by 2 window motors) backdrive the servo so I can read the angle.

My calibration was going to be basic, I have a 3:2 gear ratio before the servo so that when the claw spins say 90 degrees, the servo spins 60. Then If I adjust the claw to be horizontal manually (don’t want to have to do this for each match which is why I was thinking of a servo), and then read in the angle, I can do some math to find out which angle is vertical and everything else.
This is why I figured encoders wouldn’t work because they count rotations instead of angle position.

Yes, I now realize I could do a potentiometer and read in the analog value but I was hoping to take advantage of an already existing system. On this note though, is the analog 5V source on the cRIO module regulated enough to do this accurately?

My other thought was use the function on an Arduino and then send the data over to the cRIO via some kind of communication. (I2C appears to be commonly used but I wonder how Ethernet would work, assuming its an Arduino Ethernet).

So I guess my question now is, what is the best way to accomplish something like this?

Like I said in the previous post, you won’t be able to read the position back out of the servo. One option is to drive the servo through a series of known positions, eventually hitting a limit switch or photo eye at the position you want to calibrate to. Now you have a known physical location for a given servo position.

Absolutely! We use analog encoders and potentiometers regularly to detect angle. The analog module provides 10 bit (1024 count) resolution. We haven’t found a job that wasn’t sufficient for.

I’m not familiar with the Arduino implementation for servos, but you need to be careful here. All motors (including servos) must be controlled by the cRIO. So be careful to stay legal if this is the route you take.
And yes, the Arduino can communicate over I2C with the cRIO. There are threads here discussing that very topic.

We use this potentiometer to sense our arm angle.

For reference, in the Arduino environment, a will not read the current location of the servo. It will only return the last value sent to the servo through a servo.write() command.


Create a simple adjustable resistive circuit, run the +5 and ground through the entire circuit, and the signal to the center “adjustable” point. Pick up the voltage drop and in your code write the math algorithm that translates it into the number you want to read. Display the number on a customized version of the dashboard.