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)

ay2b 28-12-2007 03:44

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by Tom Bottiglieri (Post 664507)
I can't decide on whether or not I will split off the teleop, autonomous, and disable functions to their own files. I feel like user_code.c will be a bit cluttered and may be overwhelming for new student programmers.

Personally, I advocate doing this. I think keeping the teleop and autonomous sections separate is beneficial. If you have multiple programmers, it makes it easier for different people to work on different sections.

Additionally, I strongly advocate that everyone add a "robot.c/robot.h" that has all the robot functionality. This should be the only place that directly sets any PWM value. It would have functions like robot_drive(speed, turn_rate, gear) and robot_set_arm_position(height). These functions would be called from both the teleop and autonomous functions. Then, when you change your robot, swap motors around, change a pneumatic gear shifter to a servo gear shifter, bend a pin on the RC, etc, you only have one location where you need to make code changes.

Basically the robot.c/h file presents the robot conceptually to the rest of the code. The autonomous and teleop functions can deal with the logic, like "the robot drives forward X distance, and then turns 90 degrees", and the robot.c/h functions can translate that into "set PWM01=255, and PWM02=0".

Kevin Watson 28-12-2007 13:39

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by Tom Bottiglieri (Post 664507)
I can't decide on whether or not I will split off the teleop, autonomous, and disable functions to their own files. I feel like user_code.c will be a bit cluttered and may be overwhelming for new student programmers.

Thoughts? Kevin, any reason you did not pursue something like this?

Yes, this was considered, but I have a very small bias toward keeping the number of source files down to a minimum. Since most new teams probably won't touch the Autonomous( ) or Disabled( ) functions, adding four more source files would make the learning curve a little more steep. With that said, if we can reach some kind of consensus on this or any other aspect of the code, I'd be more than happy to modify the code to meet the needs of the community (which is one of the reasons I started this conversation).

-Kevin

Tom Bottiglieri 28-12-2007 14:00

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by Kevin Watson (Post 664584)
Yes, this was considered, but I have a very small bias toward keeping the number of source files down to a minimum. Since most new teams probably won't touch the Autonomous( ) or Disabled( ) functions, adding four more source files would make the learning curve a little more steep. With that said, if we can reach some kind of consensus on this or any other aspect of the code, I'd be more than happy to modify the code to meet the needs of the community (which is one of the reasons I started this conversation).
-Kevin

What is your stance on pre compiling your drivers and back end code into a library? The source would be available to read, but you could cut out some of the mess in the source tree.

Although, on second thought, this may be a pain to maintain.

billbo911 28-12-2007 14:07

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by billbo911 (Post 664500)
OK, another noob question.
I installed a clean version of MPLAB the "upgraded" it with the file from the link Kevin provided.
I can't get it to open Kevin's ifi_frc.mcp. So, after using the Project wizard to create a new project, it will compile correctly without errors. Well, that's partially true, I had to comment out a printf statement in user_code.c.
Now the output window keeps spitting this out:
"Error: Bad magic number in COFF file "C:\TEMP\C18 3.0beta\ifi_frc_beta\ifi_code.o".
So, what is that telling me? What is a "magic number"?

Just a bump. Still looking for the answer.

Kevin Watson 28-12-2007 14:24

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by billbo911 (Post 664594)
Just a bump. Still looking for the answer.

What version of MPLAB are you using? If it's anything less than 7.4 (I think), it won't work with the new compiler.

-Kevin

Kevin Watson 28-12-2007 14:38

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by Tom Bottiglieri (Post 664591)
What is your stance on pre compiling your drivers and back end code into a library? The source would be available to read, but you could cut out some of the mess in the source tree.

Although, on second thought, this may be a pain to maintain.

No, it's a good idea and one I'm entertaining (e.g., I already have a version of ifi_frc_xxxx.lib with the serial port code included).

My interest right now is to make sure that the CD programmer community is okay with the architecture and, hopefully, will spend some time finding any bugs I've introduced. Once that's done, I'll have a look at simplifying the source tree.

Speaking of bugs, does anyone have any code which will consistantly cause the 8.3 volt problem? I have a theory I'd like to test out, but haven't been able to reproduce the bug.

-Kevin

billbo911 28-12-2007 15:02

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by Kevin Watson (Post 664603)
What version of MPLAB are you using? If it's anything less than 7.4 (I think), it won't work with the new compiler.

-Kevin

From my original post,

Quote:

Originally Posted by billbo911 (Post 664500)
OK, another noob question.
I installed a clean version of MPLAB then "upgraded" it with the file from the link Kevin provided.I can't get it to open Kevin's ifi_frc.mcp....Now the output window keeps spitting this out:
"Error: Bad magic number in COFF file "C:\TEMP\C18 3.0beta\ifi_frc_beta\ifi_code.o".
So, what is that telling me? What is a "magic number"?


So, I thought it was 8.10, but now that I think about it, I originally installed 7.4 and the upgrade is only for C18, so I might still be at MPLAB 7.4, and C18 is 3.1. I'll verify when I return home this evening. Thanks Kevin! :)

Kevin Watson 28-12-2007 15:54

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by billbo911 (Post 664613)
So, I thought it was 8.10, but now that I think about it, I originally installed 7.4 and the upgrade is only for C18, so I might still be at MPLAB 7.4, and C18 is 3.1. I'll verify when I return home this evening. Thanks Kevin! :)

From the C18 3.10 release notes: "MPLAB C18 v3.00 and later will not be compatible with versions of the MPLAB IDE prior to v7.21".

-Kevin

billbo911 28-12-2007 20:10

Re: New C18 3.0+ Compatible FRC Code
 
Yep, you nailed it Kevin.

I had installed MPLAB 7.20, added C18 2.x then upgraded C18 to 3.10.

So, now that I have reinstalled MPLAB 8.0 with C18 3.10, it works like a champ! It loads and builds your project first time, every time.

Now I'm off to try and see if I can actually do something with it. :ahh:

Binome 28-12-2007 20:31

Re: New C18 3.0+ Compatible FRC Code
 
Thanks immensely. I use C18 3.10 all the time, and its a pain to have to maintain two seperate development toolchains for general purpose and FRC specific code. It's great not having to go searching for that ancient C-BOT compiler disk whenever I need to set up a box for FRC code, when I can get the most recent MPLAB IDE and C18 from the microchip website.

eugenebrooks 28-12-2007 23:05

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by Kevin Watson (Post 664608)

Speaking of bugs, does anyone have any code which will consistantly cause the 8.3 volt problem? I have a theory I'd like to test out, but haven't been able to reproduce the bug.

-Kevin

We don't have a program that could run on a bare controller, but I believe that we still have our 2006 robot fully together (currently with a 2005 controller) and could put the 2006 controller and program back in it without much effort. I would not say that it "consistently" hit the the 8.3 volt bug, but it most certainly hit the problem frequently. If you have a patch in mind we would be willing to try it out during the build period. It would be really nice to fix that bug. We have sworn off using interrupts (in our own code) on the 8722 based controllers until the problem is addressed.

Eugene

Kevin Watson 29-12-2007 00:57

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by eugenebrooks (Post 664836)
We don't have a program that could run on a bare controller, but I believe that we still have our 2006 robot fully together (currently with a 2005 controller) and could put the 2006 controller and program back in it without much effort. I would not say that it "consistently" hit the the 8.3 volt bug, but it most certainly hit the problem frequently. If you have a patch in mind we would be willing to try it out during the build period. It would be really nice to fix that bug. We have sworn off using interrupts (in our own code) on the 8722 based controllers until the problem is addressed.

Eugene

Thanks. I'd be happy if I could just get a .map or .lst file of a build that exhibited the problem.

-Kevin

eugenebrooks 29-12-2007 01:33

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by Kevin Watson (Post 664860)
Thanks. I'd be happy if I could just get a .map or .lst file of a build that exhibited the problem.

-Kevin

Kevin,

I have sent you a web link to download a zipped example via a private message.

Eugene

Kevin Watson 29-12-2007 04:15

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by eugenebrooks (Post 664866)
Kevin,

I have sent you a web link to download a zipped example via a private message.

Eugene

I got the code. Thanks.

-Kevin

Lafleur 29-12-2007 18:03

Re: New C18 3.0+ Compatible FRC Code
 
I noticed that you did not add the:

#pragma tmpdata low_isr_tmpdata

#pragma tmpdata

in the serial interrupts handlers?? but you did so in the timer.c and interrupts.c handlers??

is this an oversight??

thanks...


All times are GMT -5. The time now is 22:34.

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