Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   New C18 3.0+ Compatible FRC Code (http://www.chiefdelphi.com/forums/showthread.php?t=60377)

Kevin Watson 12-01-2008 14:43

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by Kevin Watson (Post 676116)
Replace "ifi_analog_channels" with "ADC_15ANA" and it should compile.

I just tried it here and you probably need to add this line at the top of the file: "#include <adc.h>". You can also just comment out the line and compile. On my to do list is replacement code for this function.

-Kevin

NetElemental 12-01-2008 14:49

Re: New C18 3.0+ Compatible FRC Code
 
Kevin,
Thanks - we already had #include <adc.h>, it seemed to come like that. Our mcc18 adc.h file actually did not have a definition for ADC_15ANA - it had 0-14 and 16. Assuming the intent is to set all the pins to analog, I changed "ifi_analog_channels" to "ADC_16ANA" if it helps.

In our file, we had
Code:

#define ADC_14ANA  0b11110001 // analog: AN0->13  digital: AN14->15
#define ADC_16ANA  0b11110000 // All analog

Weird, eh?

Thanks again,
James

Kevin Watson 12-01-2008 15:09

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by NetElemental (Post 676188)
Kevin,
Thanks - we already had #include <adc.h>, it seemed to come like that. Our mcc18 adc.h file actually did not have a definition for ADC_15ANA - it had 0-14 and 16. Assuming the intent is to set all the pins to analog, I changed "ifi_analog_channels" to "ADC_16ANA" if it helps.

In our file, we had
Code:

#define ADC_14ANA  0b11110001 // analog: AN0->13  digital: AN14->15
#define ADC_16ANA  0b11110000 // All analog

Weird, eh?

Thanks again,
James

Looks like their library documentation is messed-up. Use ADC_16ANA.

-Kevin

Rindill 12-01-2008 15:13

Re: New C18 3.0+ Compatible FRC Code
 
Using new code with Eclipse? How to make the correct makefile? Help?

Ethan Reesor 12-01-2008 15:28

Re: New C18 3.0+ Compatible FRC Code
 
Kevin,
I am currently working with the ADC and Gyro code for the mcc18 v3, using MPLAB IDE v8.0. I realized that I had v2.4 of the compiler, so I downloaded and ran the v3.1 updater. Now, when I compile, the linker tells me I have the wrong (out of date) COFF file format for the object files (*.o). Any ideas?

Here is the error:
Code:

Error - Coff file format for 'C:\Documents and Settings\Ethan\My Documents\Programming\FIRST\Code\ifi_frc_gyro\adc.o' is out of date.
-Ethan

Kevin Watson 12-01-2008 15:57

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by Ethan Reesor (Post 676214)
Kevin,
I am currently working with the ADC and Gyro code for the mcc18 v3, using MPLAB IDE v8.0. I realized that I had v2.4 of the compiler, so I downloaded and ran the v3.1 updater. Now, when I compile, the linker tells me I have the wrong (out of date) COFF file format for the object files (*.o). Any ideas?

Here is the error:
Code:

Error - Coff file format for 'C:\Documents and Settings\Ethan\My Documents\Programming\FIRST\Code\ifi_frc_gyro\adc.o' is out of date.
-Ethan

Try using the "build all" option, which will recompile all source files before linking.

-Kevin

Guy Davidson 12-01-2008 16:07

Re: New C18 3.0+ Compatible FRC Code
 
I am planning on using the custom pwm.c/h code to generate the two pwm signals at 100Hz. I realized that unless I am also providing command and mointoring the system at 100Hz, it won't gain me anything (i.e. if I were to generate pwm commands in the 38Hz loop and update the commands at 100Hz, I don't think I'd gain anything). Hence I am also planning to update encoder-based pid loops at a rate of 100Hz. Not only this will give me a constant interval between updates, making my velocity estimates more reliable, it should make use of the faster update rate by generating commands at that rate.

Will doing something like that impact the performance of the the pwm functions? My PID loop code is not much more than a bunch of logical tests and integer multiplications. I am wondering if I should be okay if I call the PID code from within the Timer ISR that generates the pwm signal, or am I risking a significant drop in performance.

Thanks (and I hope my question is worded clearly enough - if not, please let me know, and I'll try to reword it)

bronxbomber92 12-01-2008 16:08

Re: New C18 3.0+ Compatible FRC Code
 
This is related to the Beta code, but with default code compiled with MPLAB 8.00 and c18 2.40 I get a similar error to Etahn Reesor:
Quote:

error - Coff file format for 'ifi_library.o' is out of date
error - Coud not find member 'ifi_library.o' in library file 'C:\filepathToProject\FRC_library_8722.lib'p
Any idea on how to fix this?

Jon236 12-01-2008 18:31

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by Kevin Watson (Post 673140)
It should be a matter of:
1) Adding encoder.c/.h to the project.
2) Putting #include "encoder.h" at the top of each source file where any encoder functions will be called.
3) Calling the encoder initialization function(s) from teleop.c/Initialization().
4) Enable the individual encoder channels at the top of encoder.h.
5) Assign the encoder phase b signals to digital inputs at the top of encoder.h.
6) Enable the interrupt(s) associated with each enabled encoder channel at the top of ifi_frc.h.
7) Make sure there are no conflicting ISRs enabled at the top of interrupts.h.
8) Compile and test.

-Kevin

Kevin,

I keep getting a link error
Error - could not find definition of symbol 'Int_6_ISR' in file 'C:\dev\ifi_frc_gyro\ifi_frc.o'.
even when I enabled interrupts 3-6 in ifi_frc.h

Thoughts?

Kevin Watson 12-01-2008 21:09

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by Jon236 (Post 676342)
Kevin,

I keep getting a link error
Error - could not find definition of symbol 'Int_6_ISR' in file 'C:\dev\ifi_frc_gyro\ifi_frc.o'.
even when I enabled interrupts 3-6 in ifi_frc.h

Thoughts?

The linker can't find the Int_6_ISR() function in your source files. You need to perform step #4 in the list and enable encoder #6. If this doesn't solve your problem, can you send me your code (I hope I haven't done something knuckle headed)?

-Kevin

Kevin Watson 12-01-2008 21:21

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by sumadin (Post 676243)
I am wondering if I should be okay if I call the PID code from within the Timer ISR that generates the pwm signal, or am I risking a significant drop in performance.

Sounds like a fun project. I would not do my PID calculations in a ISR. Instead, I would set up a timer to fire off at 100Hz and then wait for the timer interrupt flag to go high and then do your PID calculations. The ideal place for this code is Teleop_Spin() and/or Autonomous_Spin(). Let me know if you have any problems.

-Kevin

Jon236 12-01-2008 21:48

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by Kevin Watson (Post 676470)
The linker can't find the Int_6_ISR() function in your source files. You need to perform step #4 in the list and enable encoder #6. If this doesn't solve your problem, can you send me your code (I hope I haven't done something knuckle headed)?

-Kevin

All my problems went away when I downloaded you encoder_beta version.

comphappy 13-01-2008 00:13

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by billbo911 (Post 675117)
I have used this method in the past on my Vex bot. It works fairly well but is not perfect. For use in straight line driving, as in Hybrid mode, it should be sufficient. BTW, make sure you account for the dead-band associated with the Victor.

Yes, I am aware of that, but in this case the PWM is being driven with out any user input, should be ether 0 or 255, nothing in the middle.

billbo911 13-01-2008 13:18

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by comphappy (Post 676665)
Yes, I am aware of that, but in this case the PWM is being driven with out any user input, should be ether 0 or 255, nothing in the middle.

I'm not sure I am following what the question is. If you have a PWM value that is going to be only one of two states, 0 or 255, then just test for one state. For example:

Code:

if (pwm03 > 127)
    {
      accumulator ++;
    }
else
    {
    accumulator --;
    }

I chose 127 just for simplicity.

Just as easily, you could test for the actual value.

Code:

if (pwm03 == 255)
    {
      accumulator ++;
    }
else
    {
    accumulator --;
    }


paulcd2000 13-01-2008 15:12

Re: New C18 3.0+ Compatible FRC Code
 
It has been explained how to add encoders to the gyro code, how about the reverse?


All times are GMT -5. The time now is 14:27.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi