|
Re: Combined Camera and PID/Encoder Code
I wish I'd seen your post earlier, I'm just now figuring this out. I think we're getting interference from our motors on our camera lines making us miss ACKs and then the code runs too long resulting in a code error.
My first suggestion is to make sure you're not calling too many commands that require ACKs during one 26.2ms cycle. This may require breaking up the camera initialization code into several states, each occuring in a separate 26.2ms cycle.
My second suggestion is to only allow one failed ACK per 26.2ms cycle. After seeing one failed ACK you would force all other calls to the wait_for_data() function to immediately return a 0 until the end of the 26.2ms cycle when you would reset the flag. This method basically assumes that if you miss one ACK during a cycle, that any other camera command will likely fail too, you just want to complete the 26.2ms cycle safely so you can retry that state during the next iteration.
I hope that helps. We won't get a chance to test the code until nationals, so if you get a chance to test it and have any success please let me know.
Thanks.
|