Is there a reason that shaft encoders would not reset when you say SensorValue[encoderXX] = 0? (in RobotC)
Our auton skills is running into an odd problem. We’ve got a pattern like this:
- drive w/encoder clicks - OK
- turn for xxMsec - OK
- reset encoders; drive w/encoder clicks - PROBLEM
- turn for xxMsec - OK
- reset encoders; drive w/encoder clicks - OK
- turn for xxMsec - OK
- reset encoders; drive w/encoder clicks - OK
We’re using a function to drive w/encoder clicks (therefore it is the same code for steps 1, 3, 5 & 7 with different parameters). The first step in that function is to reset the values to 0 using SensorValue[encoderXX] = 0;.
Clearly it’s working for most cases (steps 1, 5 & 7). What happens with step 3 is that you can hear a tiny pause in the motors after the end of step 2, so I know it’s considering doing step 3, but then skips over the driving and moves on to step 4 (the next turn). The only conclusion I can draw is that it thinks “hey, the encoder count is already over 600 clicks, so I’m going to move on to step 4”. (I can’t think of any other explanation of why it would pause briefly & then go on to step 4.)
In general, is there something special that needs to happen when resetting encoders that we’re not doing? Do we need a teeny wait statement after resetting the encoders? (Sorry, I’m not at a computer now with the precise code, but my question is more general about what needs to happen in order to properly reset encoders to 0 in RobotC.)
Thanks for the advice & knowledge.