Shaft encoders

Hey I’m working on shaft encoders to tell the program to forward for this many degrees and turn, and it turns right away and skips the straight part. When I go onto the on line window the values always stay at 0 even if i turn them. I am using easyc if someone could give me like a demo test deal or give me advice on how to do this.


Could you post your code?

Like my whole program?

Just the parts that pertain to this

These pictues are in the wrong order but this should be able to help you understand what I’m talking about.

Im sorry freind i cant help with easy c, if it were in robotc maybe i could help


I had the same problem so i use a switch and vase statement so try that

Here is a screenshot of example you can use to test your encoder. You do need to use the StartQuadEncoder() function to initialize it.

In the Online Window you will only see 1 and 0 when you rotate the encoder. It only reads the signal but the processor performs the tick counting.

void main ( void )
unsigned long encoder = 0;
StartQuadEncoder ( 1 , 2 , 0 ) ;
encoder = GetQuadEncoder ( 1 , 2 ) ;
while ( encoder < 1000 )
SetMotor ( 1 , 60 ) ;
encoder = GetQuadEncoder ( 1 , 2 ) ;
SetMotor ( 1 , 0 ) ; // Stop Motor


K I will let you know if i xan get it to work.

I did that same exact program with my motor number and it wont even move my robot.

try to invert it

That still doesnt work i also tried to just have it drive forward fir 1000 milliseconds and stop and it still wouldn’t move. I’m using a potentiometer to change between programs and every othe program works except this one.