This year we’ve finally got enough people interested in programming to have 2 subteams programming this year, and we’re all stoked. One team is currently going to town on the camera and autonomous code with this year’s 2007 controller, and the other team is learning how to program almost from the ground up on a 2004 controller. We don’t have the old version of MPLAB or the C18 compiler to use with the 2004 controller, but the new versions of the software can compile for the old controller.
This is all fine and dandy, but we cannot find one source code package for the 2004 and/or 2005 controllers that actually compiles straight out of the box. The 2004 and 2005 default code won’t compile because they’re missing the adc code, and Kevin’s 2005 code with adc improvements doesn’t compile because it’s missing a bunch of files too. We combined Kevin’s 2005 adc code (just copied the adc modules, hooked in the interrupt handler, etc…) into the 2005 default code and was finally able to make a version of the code that compiles and runs. However, the values we get back from the analog inputs are really noisy, meaning if we get back a 10-bit number like “842” from an analog input, it is sometimes “84” and sometimes “8” instead of getting the full number “842”. At first I thought it was a printing issue (error in flushing the buffer and such) but it’s got to be a data stomping issue in the interrupt handler because the values really are getting whacked.
Is there any code out there that is “default code” that includes all of the files necessary to actually compile it (with adc modules for analog input) for the 2004 or 2005 controllers? We ran the default 2007 code with some mods on the 2007 controllers and everything works really nice and smooth, but for the life of us we cannot get anything going on the 2004 controller with any code from 2004 or 2005.
For the default code. To get an analog input from that:
Get_Analog_Input(rc_ana_in01);
That should give you the 10 bit analog value for what ever you have hooked up to analog input 1.
That code should compile straight out of the box (zip) with mplab 7.20 and 2.4 (i think) compiler
I just re-read you message and had a look at the 2005 ADC code. It looks like your problem is that build still uses the old non-buffered IFI serial port code. Try dropping in my serial port code and it should work just fine. If you run into problems send me your code and I’ll have a look.
Nope. There are several files included in ifi_utilities.c that aren’t provided, including the “adc.h” file. That’s a common problem with all the default code from 2004 and 2005, they don’t contain everything necessary to compile with. I’m sure somebody got it to work at some time, the way the code is written suggests it was bundled with the compiler?
Oh wow, I just looked and, your right they dont include a ADC file… interesting. It always compiles fine for me i just have never used analog inputs on the 04…
All files required are included in the IFI zip file. The file adc.h is a Microchip file located at C:\mcc18\h\adc.h (it has always been that way).
Also, take a look at Kevin’s 2006/7 camera code. he has a readme which is called “Using_Last_Years_FRC.txt”. You can use his method to alter and compile IFI’s 2007 default code for the 2004/2005 controller.
Yeah, after making my last post in this thread I looked at the include directory of the c18 compiler, and sure enough it was there. The compiler options were set to look there for header files, but for some reason it didn’t. Once I reset the directory by browsing to it again (I didn’t really change the path) the compiler picked it up and we compiled Kevin’s serial modification version as-is with ease. <shakes head>
We’re up and running now smoothly, thanks everyone!
-Danny