Encoder using Analog input

We are trying to get the angle of the encoder using the analog input, but we haven’t been able to find the right function. We used getValue(), but the value didn’t change when the motor was moving. We also tried the GetAccumulatorValue() function, but the value kept on increasing so we didn’t think it was the suitable option. Our mentor hopes to find a function that can get the pulse of the encoder and divide it by 1 pinion rotation(174.9), then multiply it with 360 degrees to get the angle of the encoder. Does anyone have any suggestions?

First, we need to know whether you are using a potentiometer (an absolute encoder) or a Quadrature (relative) encoder.

Next, I would recommend using the either the AnalogPotentiometer WPIlib class if you have a potentiometer.

If you what you have is a relative encoder, and you want an absolute angle (say, relative to the floor) then your job is a lot harder. You’ll need to know what position the motor starts in.

I’m sensing a lot of confusion. A potentiometer is a resistor. As it is turned the resistance varies, and our analog ports can measure that.

An encoder is a digital device that sends digital pulses that the digital i.o. ports on the roborio can understand.

That is not necessarily true. A quadrature encoder sends digital pulses, however analog encoders (such as this one) exist that allow to sense an absolute position (as opposed to the relative encoding of quadrature encoders) through the analog in ports on the RIO.

What is the make, model, and part number of the encoder you are using?

We’re using Bosch Seat Motor (am-3493). Here’s its website:

Thanks for all the help.

Are you using the Bosch DIO kit?
Are you sending the encoder output back to analog or DIO ports?

Note that the levels from the provided encoder are not at an appropriate level to trigger the DIO ports (hence the kit). In principle, you could build a software trigger from the encoder output if you’re connected to an analog port, but I’m not aware of anyone having done this. If you do feed the encoder output to an analog input, the signal is essentially an encoder signal (up and down several times per rotation), NOT a potentiometer style output. See the “Hall Circuit Interface” section of this screensteps page for a bit more info.

Edit/add: One pulse is created for each rotation of the motor; as there is a 174.9:1 gear reduction, you will get a pulse about every two degrees of output rotation. At the motor’s maximum speed of 24rpm, you will get about 24 / 60 * 175 = 70 cycles per second, or a period of about 14ms.