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)

kaszeta 17-01-2008 20:26

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by Kevin Watson (Post 680281)
I had a look at your code and it looks like the problem is your limit() function, which is returning a 16-bit integer when it should return an unsigned 8-bit byte.

This is probably one of the big things to watch for, even for experienced programmers. The MPLAB/PIC18 platform (and embedded platforms in general) are a lot less tolerant of type mismatches than your usual programming.

billbo911 17-01-2008 21:46

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by Kevin Watson (Post 680288)
You're waiting because I'm deep in procrastination mode and haven't finished the first cut of the documentation yet <grin>.
-Kevin

I think someone needs to pull a high priority interrupt and put everything else you are doing on hold! This should be your top priority, cuz I said so.:p

"Procrastination mode" I wonder if FIRST will use that to replace Hybrid mode next year?

lukevanoort 17-01-2008 22:28

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by billbo911 (Post 680467)
"Procrastination mode" I wonder if FIRST will use that to replace Hybrid mode next year?

Well, in the past, the difference wouldn't be very noticeable...

Kevin Watson 17-01-2008 23:46

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by Jon236 (Post 678856)
BTW, would you think that using 4 interrupts,INT's 3-6, at 128 ints/sec (every ~8ms) would be overstressing the processor?

I depends on what else is executing on the processor, but in general you shouldn't have a problem.

-Kevin

Kevin Watson 18-01-2008 01:55

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by billbo911 (Post 680467)
I think someone needs to pull a high priority interrupt and put everything else you are doing on hold! This should be your top priority, cuz I said so.:p

Okay, here is a snapshot of the current build that includes support for encoders and gyro:

http://kevin.org/frc/ifi_frc_beta_4.zip

*Please* help me out and have a look at the code and documentation (start with readme.txt) and provide feedback before I go public with the code on my website, which I'd like to do on Friday or early Saturday. If you can, follow the directions in readme.txt to build the code and test with your encoder(s) and/or gyro and report any problems here. Thanks.

-Kevin


Edit: Code has been released and is available here: http://kevin.org/frc.

-Kevin

Mike Mahar 18-01-2008 11:05

Re: New C18 3.0+ Compatible FRC Code
 
Kevin,
In your gyro initialization code in teleop.c, you have two static ints that you use as counters. (i, j) You increment both every time through the function. When you wish to print out the gyro you have the following:
Code:

       
if(i == 35 && j >= 300)

Since i has been incrementing all along, it will be equal to j. The next time i == 35 j will also be equal to 35. Putting i = 0 into the
Code:

if(j == 300)
body should fix that. You also need to put i = 0 into the body of the
Code:

if(==35 && i >= 300)
statement if you aren't using the encoder code.

Kevin Watson 18-01-2008 11:58

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by Mike Mahar (Post 680768)
Kevin,
In your gyro initialization code in teleop.c, you have two static ints that you use as counters. (i, j) You increment both every time through the function. When you wish to print out the gyro you have the following:
Code:

   
if(i == 35 && j >= 300)

Since i has been incrementing all along, it will be equal to j. The next time i == 35 j will also be equal to 35. Putting i = 0 into the
Code:

if(j == 300)
body should fix that. You also need to put i = 0 into the body of the
Code:

if(==35 && i >= 300)
statement if you aren't using the encoder code.

Thanks, I'll have a look to see if I can clean it up a bit.

-Kevin

billbo911 18-01-2008 16:07

Re: New C18 3.0+ Compatible FRC Code
 
In the README.TXT, in the section to enable the ISR's in ifi_frc.h, (bullet # 3)the description is misleading, or the file is incorrect.

Quote:

3) Enable the interrupt service routines associated with each encoder
channel at the top of ifi_frc.h.
When looking at the file, the lines do not indicate that you are enabling an ISR.
Code:

// #define ENABLE_INT_1                        // enable if using encoder channel 1
// #define ENABLE_INT_2                        // enable if using encoder channel 2
// #define ENABLE_INT_3                        // enable if using encoder channel 3...

Documentation error, code error, reader misunderstanding error???

Kevin Watson 18-01-2008 16:34

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by billbo911 (Post 680953)
Documentation error, code error, reader misunderstanding error???

Given the comments above and alongside those #defines, I don't see how a user wouldn't be able to figure it out:

Code:

// Remove the comment slashes from one or more of the following lines to
// enable the respective external interrupt(s) and/or timer(s). By doing
// so, you only enable the code within ifi_frc to become part of your
// software build.
// #define ENABLE_INT_1 // enable if using encoder channel 1
// #define ENABLE_INT_2 // enable if using encoder channel 2
// #define ENABLE_INT_3 // enable if using encoder channel 3
// #define ENABLE_INT_4 // enable if using encoder channel 4
// #define ENABLE_INT_5 // enable if using encoder channel 5
// #define ENABLE_INT_6 // enable if using encoder channel 6

I'd be happy to change it, but I don't fully understand the problem...

-Kevin

billbo911 18-01-2008 16:46

Re: New C18 3.0+ Compatible FRC Code
 
I just saw the answer in encoder.c.
Sorry for the confusion. My bad.:mad:
I hate it when I misinterpret instructions like that. Oh well, blame it on sleep deprivation.;)

bronxbomber92 18-01-2008 16:48

Re: New C18 3.0+ Compatible FRC Code
 
Is it recommended to use this code over the default, or should teams wait to use until it's out of its beta stages?

Jon236 18-01-2008 17:57

Re: New C18 3.0+ Compatible FRC Code
 
Kevin,

what changes should be made to the Vex C templates to run under 3.10? I'm getting library errors.

Kevin Watson 18-01-2008 18:41

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by Jon236 (Post 681024)
Kevin,

what changes should be made to the Vex C templates to run under 3.10? I'm getting library errors.

The library needs to be built with the new compiler. Until then we're stuck with C18 2.4.

-Kevin

Loki1989 19-01-2008 14:23

Re: New C18 3.0+ Compatible FRC Code
 
Can we use MPlab 8.0 to use 3.10 to compile? I need to know Because I cant find 7.21

kaszeta 19-01-2008 14:44

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by Loki1989 (Post 681556)
Can we use MPlab 8.0 to use 3.10 to compile? I need to know Because I cant find 7.21

Yes. That's the exact setup I'm using.


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