Quote:
Originally Posted by Kevin Watson
This is a great question. When I modified the code last Summer to separate the ADC and gyro functionality, I added the ability to sample multiple ADC channels using a simple round-robin algorithm. If you read the pic18f8520 data sheet you'll notice the second paragraph on page 217 which states: "After the A/D module has been configured as desired, the selected channel must be acquired before the conversion is started...To determine acquisition time, see Section19.1 “A/D Acquisition Requirements”. After this acquisition time has elapsed, the A/D conversion can be started."
What this means is that you need to allow sufficient time for the sample-and-hold capacitor to charge between the time you change the channel and can actually start the conversion. Providing this delay within an ISR is, to say the least, un-cool. My solution was to start the conversion using the timer 2 ISR and manage data and change the ADC channel in the ADC ISR. The sample-and-hold capacitor then has ample time to charge between the ADC and timer 2 ISRs. This is how the currently posted code works.
The pic18f8722, used in the current robot controller, has added circuitry to automatically provide the acquisition delay before conversion begins (see page 277 of the p18f8722 data sheet). In the next revision of the ADC code I suspect that I'll be able to do away with the ADC interrupt and do everything in the timer 2 ISR. Perhaps this would be a good programming exercise for you?
-Kevin
|
Hello Kevin
When our team is using your FRC gyro code. there seems to be a problem. The motors are twitching. That is the arm and shoulder motors are coming back but are not staying in there.
Can u please tell us what to do about that. We caliberated the victors and checked the victors and checked the voltages. But when we use the default code without gyros the code works fine.
Please let us know what is happenning.
Thank you
Srinivas