View Single Post
  #17   Spotlight this post!  
Unread 06-02-2007, 01:21
radicalnerd radicalnerd is offline
Registered Luser
FRC #0668 (Apes of Wrath)
Team Role: Programmer
 
Join Date: Dec 2005
Location: San Jose, CA
Posts: 12
radicalnerd is an unknown quantity at this point
Send a message via AIM to radicalnerd
Re: Encoders not changing...

There might be a problem with storing a long to an int without typecasting... Kevin's Get_Encoder_n_Count() functions return a long. If you want to store them as ints you should typecast them:
Code:
LeftWheelCount = (int)Get_Encoder_1_Count();
RightWheelCount = (int)Get_Encoder_2_Count();
Otherwise you might get only the most significant bits of the long, which make the int variables 0. In other words, it's counting, but you're not printing them correctly. We had a similar problem with printf displaying longs without typecasting:

Code:
printf("Left encoder count = %d", Get_Encoder_1_Count() );      //incorrect
printf("Left encoder count = %d", (int)Get_Encoder_1_Count() ); //correct
I believe the first one tripped us up because it only printed the highest 16 bits of the long, making it appear like it's not counting.

This might be something you already know, in which case I'm sorry I can't help. But if you have a problem with encoders generating too many counts, BaneBots has an encoder divider board that we're using this year. They have jumpers to select divide by factor: 1, 4, 8, or 16. We have one 128/revolution encoder coupled 2:1 to each CIM motor shaft (that's ~5000 counts/sec at no load speed), divided by 4 so we don't overwhelm the processor with counts.