|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#16
|
||||
|
||||
|
Re: Analog-to-Digital Converter Code
Yes, it samples faster than the rate the data is being sent.
I have another question for Kevin (of course, I'm trying to optimize everything, but I don't want to make a bad move while doing this): Is there a specific reason for switching from doing both the initiation of and saving of an ADC sample in the timer interrupt? I remember in last year's gyro code that both functions were done in the same place, whereas now you are using both the timer interrupt, and the ADC interrupt to take the samples. Is it safe to kinda shift the ADC functionality to the timer interrupt and reduce the extra overhead by removing the ADC interrupt altogether? Or do the two of them together execute faster, somehow, than the single timer? Before you: - Started the initial A/D conversion in Initialize_XXXX() - Saved the value at the start of the timer2 interrupt - Did the if/else/etc to put the value in the right place - Started another A/D conversion by setting the GO bit. - Exited the timer2 interrupt. And if I get the go ahead, I'll just do this again. |
|
#17
|
||||||
|
||||||
|
Re: Analog-to-Digital Converter Code
Quote:
|
|
#18
|
|||
|
|||
|
Re: Analog-to-Digital Converter Code
Quote:
When I copy the FRC_Library into my 2006 project code (to update from the 8250 (2005) to the 8722 (2006) controller, I am getting a link error saying that symbol ifi_packet_num1 has multiple definitions. I was able to determine that there is a copy of ifi_utilities.o (where ifi_packet_num1 is defined) in the FRC_Library (that wasn't there in 2005). I was able to work around the problem by removing ifi_utilites.c from the project, and it linked fine. My question is: Is there some setting I am missing in my project that would allow the linker to use the first instance of the object file it comes across versus including all versions. I see ifi_utilities.c in the frc_gyro (gyro.mcp) project, and the link works correctly. Since I don't modify ifi_utilities.c my work around shouldn't be a problem, but I would like to know why one project will link correctly, while another one won't. Thanks, Mark |
|
#19
|
||||
|
||||
|
Re: Analog-to-Digital Converter Code
Quote:
|
|
#20
|
||||
|
||||
|
Re: Analog-to-Digital Converter Code
Quote:
I also see the following: Quote:
I'll wait for your feedback before continuing. Last edited by Joel J : 23-01-2006 at 23:28. |
|
#21
|
||||
|
||||
|
Re: Analog-to-Digital Converter Code
Quote:
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 |
|
#22
|
||||
|
||||
|
Re: Analog-to-Digital Converter Code
ok, great!
I'll modify your code for use now, and then I'll swap in your next revision when you make it gold. Thanks for the feedback. |
|
#23
|
||||
|
||||
|
Re: Analog-to-Digital Converter Code
For some reason our team is having great difficulty in getting the analog inputs to work, no matter what we plug into the inputs or print. We have initialized them and receive no errors yet no inputs are received. We have attempted testing a gyro, accelerometer, ultrasonic sensor, and variable resistor (potentiometer) but none have made a difference.
|
|
#24
|
||||
|
||||
|
Re: Analog-to-Digital Converter Code
Quote:
Last edited by lukevanoort : 08-02-2008 at 19:41. |
|
#25
|
||||
|
||||
|
Re: Analog-to-Digital Converter Code
Actually that wasn't the problem, but we seem to have fixed it. Our problem actually was that the interrupt Timer_4_ISR was defined in both adc.c, adc.h and timers.c and .h. No errors appeared but it didnt allow inputs.
|
|
#26
|
||||
|
||||
|
Re: Analog-to-Digital Converter Code
Quote:
Quote:
|
|
#27
|
|||
|
|||
|
Re: Analog-to-Digital Converter Code
Hi Kevin, We have recently come to realize that the p1_y and p1_x ADCs are somewhat noisy. The output value varies randomly maybe about +/-10 of 127 when the joystick is connected, but not touched. Does your code address this problem? We were trying to work around the problem using a comb digital filter.
Thanks, Windell |
|
#28
|
||||
|
||||
|
Re: Analog-to-Digital Converter Code
Quote:
-Kevin |
|
#29
|
|||
|
|||
|
Re: Analog-to-Digital Converter Code
Quote:
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 |
|
#30
|
||||||
|
||||||
|
Re: Analog-to-Digital Converter Code
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Out of the Box Camera Code | russell | Programming | 9 | 21-10-2009 05:28 |
| Updated: Example Gyro Interface Code | Kevin Watson | Programming | 2 | 28-03-2005 04:36 |
| Example gyro code released. | Kevin Watson | Programming | 60 | 17-03-2005 18:32 |
| Team THRUST - Kevin's Code and Camera Code Combine | Chris_Elston | Programming | 3 | 31-01-2005 22:28 |
| heres the code. y this not working | omega | Programming | 16 | 31-03-2004 15:18 |