Encoder Troubles

So the other day at my competition, I showed up and went to test my autonomous (note: I haven’t tested it up until this point). Before we had used time to run our autonomous, which was fine for regular competition, just get a 20 pt mobile goal and thats it. However, for skills we thought it would be a good idea to use encoders; but when I tested it, the robot never stopped, so I asked my brother why it didn’t stop. He looked at my code, and didn’t see a problem with it. so we ran a debugger and the encoders never gained in value even when turning, then we got different encoders and they didn’t gain value either. so what could be wrong with the encoders/cortex/robot. Please help and thank you.

Before we start discussing, what programming language are you using? I’m assuming ROBOTC?

What kind of encoders are we talking about here? IMEs (the ones that go on the motor) or shaft encoders (the big red ones)?

@[TVA]Connor Yes I am using RobotC

Shaft Encoders

The ones with two 3-wire cables each?
How do you have them configured? Can you post the relevant section of RobotC sensor setup?

#pragma config(Sensor, dgtl1, rightEncoder, sensorQuadEncoder)
#pragma config(Sensor, dgtl3, leftEncoder, sensorQuadEncoder)

This looks good for the modern, double-cable Quad encoder.
Have you tried the sensor view and manually rotating them?

Most likely you are testing for a positive encoder count, and the encoder is returning negative numbers. use fabs(SensorValue[encodername]) to return a value without sign when assessing that value in your code.

so what you’re saying is that the debugger window doesn’t show negative values, and it was giving off negative values? if so that can’t be true because I turned the wheel the encoder was on and it gave a value of 1 but I kept spinning it but that was it. but maybe I don’t completely understand what you’re saying

I guess I did not read your post carefully enough. I know there is an issue with ports 4 and 10 that might give you problems. Have you tried other ports for the encoder?

no, I’ll try that though.

Try switching the two wires of the encoder.

I tried that and there wasn’t any change

Where have you placed each optical shaft encoder’s second wire? You’ve shown you’re using two encoders and where you’ve assigned the first digital ports, but you haven’t specified for us where the second wire of each encoder is actually plugged in. I don’t use RobotC, but when I look at the pdf it shows a spot in the motor/sensor setup where you have to specify where the second wire is located. Do those match where you have placed the second wires?