Quote:
|
Originally Posted by stephenthe1
can you look at this and tell me if you see any errors.
Code:
//the encoder is at 50 resolution
//the arm motor is attatched to pwm_02
//the encoder is attatched to rc_dig_in06
unsigned int encoder;
if (p2_sw_trig == 1)
pwm_02 = 220;
if (rc_dig_in06 == 1)
encoder = encoder + 1;
if (encoder == 11)
pwm_02 = 128;
|
Couple of problems, such as,
"encoder" needs to be static or a global, so it retains it's value from call to call.
The check on rc_dig_in06 will increment "encoder" more often than every "tick"
"encoder" might shoot right past 11 and keep going.
But first what model encoder are you using?