![]() |
Analog-to-Digital Converter Code
For those who might be interested, I've just posted new analog-to-digital converter interface code for IFIs robot controllers. A few advantages of using this software include parallel, non-blocking operation of the ADC hardware, precise control over the sampling period, which is important for signal processing and control applications and the ability to make measurements with greater precision using a technique called oversampling. The code can be found here: http://kevin.org/frc. As always, if you find a bug in the code or a problem with the documentation, please let me know.
-Kevin Here's the readme file: Code:
|
Re: Analog-to-Digital Converter Code
wow thanks allot!
|
Re: Analog-to-Digital Converter Code
I've updated the ADC code to version 0.3. The new version uses the "special event trigger" functionality of the CCP2 module to automatically start an analog to digital conversion without software intervention. This new version generates half of the interrupts/sec of version 0.2. As always, the code can be found here: http://kevin.org/frc
-Kevin |
Re: Analog-to-Digital Converter Code
Well, I finally posted the ADC and Gyro code for the 2006 robot controller. Sorry about the delay, but I ran into a nasty bug that caused me to spend a few days in the fourth and fifth levels of programmer hell. The bug was in the design of the PIC18F8722 (yes, a bug in the sillicon) and I had to figure out what was going on. Anyway, the gyro code works really, really well with the gyro in the kit of parts. The accelerometers also work really well, but I need to do more testing before I unleash that code.
-Kevin |
Re: Analog-to-Digital Converter Code
Let's suppose there are four analog signals being sampled and "buffered" by your code. The gyro is running on ADC_CH0 and the other three channels are for other devices. How do we know when the gyro specifically has new data available? I saw the ~update_count~ variable, but it seemed to just indicate when any new sample is available, not when the sample for a specific channel is. Am I going to have to modify your code (maybe add an array of update_counts, with each index correspondent with the channel's freshness of data?) to allow this functionality, or is it already there and I'm just not seeing it?
|
Re: Analog-to-Digital Converter Code
Quote:
-Kevin |
Re: Analog-to-Digital Converter Code
Hi Kevin...
Excellent code. I'm trying to get some early Auto-Heading code testing done using an existing Robot. I was hoping I could use the team's little 2003 EDU robot as a test platform. I'm an experienced embedded programmer, but new to the IFI hardware. I tried deploying your gyro code on the small EDU controller. I discovered that when I included the new ADC module I got a program run error light, so I dropped back to the standard iti_utilities code for the ADC conversion. (I assumed a basic hardware incompatibility....) My only problem is that now I'm not sure where to put the call to Process_Gyro_Data(). I'd like to put it in User_Routines_Fast.c but I don't have your ADC code installed so I don't know when the converters have got new values. D'oh. Am I flogging a dead horse here, or is there a simple way to use the standard IFI analog utilities to drive your Gyro code? I'm only using a single analog channel (for the Gyro) so that may simplify things. I don't need fully calibrated data for my initial testing... I just need it to basically run. If I can get the calls IN, I can get the rest to work. Thanks for your time. Phil. Quote:
|
Re: Analog-to-Digital Converter Code
Quote:
Gyro code for the EDU-RC can be found on my website. -Kevin |
Re: Analog-to-Digital Converter Code
Oops.
I'm in "drinking from a fire-hose" mode and never seem to look in the right place for information. Just when I think I've downloaded enough... I find more.. After posting, I discovered your adc_readme file which let me go through and add your stuff to our teem's prior EDU-RC code. Now I don't get an error & the gyro seems to be working as with the 2006RC. Now with this new information I can double check against your webiste archives if need be. Thanks. I'll look harder next time. Phil Quote:
|
Re: Analog-to-Digital Converter Code
Hello all,
First off, I want to thank kevin for writing this code. This *should* help us use all those sensors we just looked at and admired last year as rookies. Unfortunately, our team is not gifted with a large number (read - 0) dedicated programmers. So I'm not too far ahead of the kids at this point which disappoints me because I cant really help them the way I should be (when I barely know anything myself). But I did read all the readme.txt files associated with the code Kevin's supplied, and I have 2 main questions which deal with getting the code and hardware on the same page. 1. After I hook up my PWMs to the sensor (take your pick) and plug it into the RC's analog input, how do I make the code know which port I'm looking at? and 2. How do I test / troubleshoot / even see the output from the sensor? Is there some easy way to use a "print to a .txt file" or something? (something I'd try on a PC) Better yet, what is the BEST way to get all the information? I'm seeing outputs in some of these posts mentioning the same kind of scaling that you see when you output to one of the motors. So should I find some way to get the info back to the dashboard (which I still need to set up). Even with that, we need to integrate (for many of the sensors) and seeing the value at any one time wont tell us too much. Hope I'm not being too redundant or posting in the wrong place. If any of my questions indicate that I'm just fundamentally wrong, point that out too, please. It's all for the kids and the future, Aaron |
Re: Analog-to-Digital Converter Code
Quote:
The adc_readme.txt says to remove the call to Set_Number_of_Analog_Channels() in user_routines.c. But the user_routines.c file included in the same zip (frc_adc.zip) still has it in. Same situation in the user_routines.c file in the frc_gyro.zip. So, should the call remain as is, or be commented out? Thanks |
Re: Analog-to-Digital Converter Code
Quote:
-Kevin |
Re: Analog-to-Digital Converter Code
Okay, I know this is getting kind of abstract, and not truly necessary to a "black box" understanding of this code, but how exactly does oversampling work? I looked it up on wikipedia, and all i got was more confused. I understand that is is supposed to give more precision, but I really don't understand how.
Thanks. |
Re: Analog-to-Digital Converter Code
Oversampling is essentially taking a number of samples and averaging them. If you average four samples, you get the equivalent of two more bits of resolution, but it takes four times as long to get the value. It trades time for precision.
|
Re: Analog-to-Digital Converter Code
so then does it take values 4x faster? It seems like taking the average over 4 program cycles would make it less precise.
|
| All times are GMT -5. The time now is 21:14. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi