![]() |
New C18 3.0+ Compatible FRC Code
I've created C18 3.0+ compatible code and libraries for the IFI FRC robot controller. At this point the code is pretty solid and free of bugs. If interested, the code can be found here:
http://kevin.org/frc Remember this is experimental code, so please do me (and everyone else who might use this code) a favor and let me know if you run into any bugs. Thanks. 1/6/08 Edit: You need MPLAB 7.21 or greater to use the 3.0+ compiler. You can download the latest version here: http://www.microchip.com/stellent/id...&part=SW007002 The student and upgrade versions of C18 3.10 (don't use 3.15) are here: http://www.microchip.com/stellent/id...&part=SW006011 -Kevin |
Re: New C18 3.0+ Compatible FRC Code
Kevin,
I like the layout....a lot cleaner than the present code template. Had a little problem compiling: Executing: "C:\mcc18\bin\mcc18.exe" -p=18F8722 "ifi_frc.c" -fo="ifi_frc.o" -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa- C:\dev\ifi_frc_beta\ifi_frc.c:249:Warning [2002] unknown pragma 'tmpdata' C:\dev\ifi_frc_beta\ifi_frc.c:250:Error [1020] unexpected input following 'interrupt' C:\dev\ifi_frc_beta\ifi_frc.c:357:Warning [2002] unknown pragma 'tmpdata' Suggestions? |
Re: New C18 3.0+ Compatible FRC Code
I do like the layout better than the code from years past. A little less cryptic in function definitions, and file names. Although I do not know what the Disable_spin(), Autonomous_Spin(), and Teleop_Spin() are and what they would be used for.
Are their equivalents be Process_Data_From_Local_IO() just split up into different places?? Also I do like the addition of the check of the state to reset the outputs. Shouldn't this stop situations where you can only get one autonomous run from each hard reset? I cannot confirm or deny any bugs on a compile. I have neither mplab nor mcc18 and only have a mac ;) |
Re: New C18 3.0+ Compatible FRC Code
Quote:
http://ww1.microchip.com/downloads/e...-doc-v3_10.exe -Kevin |
Re: New C18 3.0+ Compatible FRC Code
Quote:
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
Is there any advantage to using the 3.0+ compiler?
|
Re: New C18 3.0+ Compatible FRC Code
Kevin,
I really like the structure of this code. It is MUCH cleaner and easier to follow. It will definitely help in teaching our newer programmers how to code specifically for FRC. I really like the use of the *_Spin functions. They make following and understanding the code and how it operates much easier, not only for new programmers, but also for relative Noobs to coding, like myself. I see you are also taking advantage of the 3.0+ interrupt optimization capabilities. As we write ISR's will it be necessary to modify the way you are excluding the ".tmpdata" Code:
"#pragma tmpdata low_isr_tmpdataPS. I am really interested in making this code work with Vex if possible. I know this is a ways down the road, but it looks like it may just work. I'll keep you posted. I will wait to start down that road until the issues you pointed out are cleaned up first. |
Re: New C18 3.0+ Compatible FRC Code
Thanks Kevin! The code is much cleaner and better documented than what ifi gives. The interrupts setup will be a great help to a lot of teams I am sure.
BTW, I have an updated version of my makefile to build this code if anyone is interested. http://team997.org/files/software/Makefile_ifi_frc |
Re: New C18 3.0+ Compatible FRC Code
Overall I really like to layout of the code. It looks a lot more intuitive than the IFI stuff.
I really like that the serial port, interrupts, timers, and PWMs, are already intgrated. That should save some time during the season. The only issue I've got is the x_Spin functions. It seems to me that most of the code that I would run there would be the same regardless of the current mode. I believe that I would modify it to call just one function, and use the mode flags to change the few things that are different. EDIT: I haven't compiled it yet, since I don't want to mess up my main dev box. Tonight I'm going to setup a VM with c18 3.15. I'll post if I have any issues then. |
Re: New C18 3.0+ Compatible FRC Code
The more I read this code, the better I like it. I see you have included many of your "updated" functions as part of the base code. Thank you!!
I did note a couple things that may be a problem, but I am not certain because I am no expert when it comes to coding. I noticed a couple "#include" statement for files that do not exist. For example, in "ifi_code.c" is a call to include "adc.h" and <delay.h>. I'm not clear on the differences when the "<xxxx>" is used, but it sure would be nice to have your "adc" code included.:) Just my $.02 |
Re: New C18 3.0+ Compatible FRC Code
The layout looks a lot more straightforward than the standard IFI. To address the concerns of those who would rather have a single Spin function, you always have the option of defining your own Default_Spin() function and calling it from each of the other Spin functions. I really think that choice comes down to six of one and a half dozen of the other. If you'd rather have a single spin function and switch inside of it on flags, you're duplicating the mode determining logic already defined in the main loop for the privilege of shoving all your spinning code into one large function. I don't think saving a function call to a Default_Spin() routine is really worth that hassle.
|
Re: New C18 3.0+ Compatible FRC Code
I'm sure I'm just being stupid or something like that, but whenever I try to open the workspace I get a "Unable to open the workspace because the format of the workspace file has changed" error followed by "A lock violation has occurred". I can open the individual *.c and *.h files just fine.
Anyway, I've only just started looking through this and it already looks awesome! I really like the timer setup and interrupt handling setup. Last year I did some interrupt and timer stuff and it could get rather confusing; this will be great for our new, inexperienced programmers to get into interrupts without quite as much trouble. It is almost like if you took the logical layout and ease of coding interrupts from WPIlib and combined them with the lower level control of IFI's code. Great work, Kevin! |
Re: New C18 3.0+ Compatible FRC Code
1 Attachment(s)
I just setup a clean virtual machine with Windows XP Professional sp2. I ran Windows Update, installed MPLab 8.0, and installed C18 3.15 Student Edition.
Here are the errors I'm getting: MPLAB C18 v3.15 (demo) Copyright 1999-2005 Microchip Technology Inc. Days remaining until demo becomes feature limited: 60 C:\Documents and Settings\Eric Haskins\Desktop\ifi_frc_beta\ifi_frc_beta\ifi_code .c:31:Error [1105] symbol 'ADC_VREFPLUS_VDD' has not been defined C:\Documents and Settings\Eric Haskins\Desktop\ifi_frc_beta\ifi_frc_beta\ifi_code .c:31:Error [1105] symbol 'ADC_VREFMINUS_VSS' has not been defined Halting build on first failure as requested. BUILD FAILED: Wed Dec 26 19:25:06 2007 What did I forget? EDIT: I moved it to a shallower directory, but it still returns that error. EDIT: I uploaded a file with the output from the compiler. |
Re: New C18 3.0+ Compatible FRC Code
Quote:
Honestly, I don't think you did anything wrong. I believe a file or two were left out of the zip. If you'll notice, at the top of ifi_code.c is a "#include adc.h", that file is not included in the .zip. |
Re: New C18 3.0+ Compatible FRC Code
Quote:
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
C:MCC18\h for Include Path C:MCC18\lib for Library Path |
Re: New C18 3.0+ Compatible FRC Code
Quote:
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
Microchip messed up the adc.h file in the latest release. Either fall back to 3.10 (using the handy link I provided above) or just comment out the offending code as it is not needed and I will be replacing it in the near future anyway. -Kevin |
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
Quote:
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
Quote:
Well, as long as I keep learning, I don't mind hanging it out there. At least now I know more than I did this morning.:D Quote:
Quote:
I am looking forward to the new builds that include your: ADC, gyro, encoder, PWM etc. I have learned a lot this summer by working with those versions from previous years and getting them to work with my Vex. As of right now, I can fairly confidently say, we will use your code this year as long as the programmers don't decide to go with EasyC Pro. I need to let them make the choice. |
Re: New C18 3.0+ Compatible FRC Code
This is great! I like the new architecture for the main loop - it matches what I've been advocating to teams for years. One additional change I'd recommend is to have a "Teleop_Init()", "Autonomous_Init()" and "Disabled_Init()" that gets called as soon as the new mode is entered.
I've been going through and comparing the old to the new, but perhaps you can give a more detailed explanation of the changes. Some parts I've gone through line-by-line, other parts I haven't had the time to do so yet. Here's what I've identified: In _startup() you have some assembly labeled "initialize all memory to zero", whereas in the old code, there was a function Clear_Memory(), which presumably does the same. All the other startup & initialization routines appear to be identical. The main() function is now better organized, so that it calls a separate "slow loop" and a "fast loop" function for each of the three modes - autonomous, disabled and teleop. The "fast loop" functions are *_Spin(). I might suggest having a suffix for the "slow loop" functions too, so you have Autonomous_Slow_Loop() rather than just Autonomous(), but that's just my style. The serial_ports.[ch] code appears to be the same. The comments in pwm.[ch] lead me to believe it is all new, but I do not have an old version around to compare. Historically, I've ignored the CCP pins and spent my time working on other programming problems. The timer code is basically the same code (because it only takes a few lines to set up a timer), but is a bit better organized. My main recommendation here would be to use the provide OpenTimer and WriteTimer macros, where applicable, rather than setting the magic variables directly. Even with all the comments, I think those macros make it easier for people new to the PIC to understand what's going on. The interrupt code is also better organized than before, though I haven't yet gone through it line-by-line. What sort of changes were needed to make it work with version 3.1? I have not yet read C18_ISR.pdf, which may answer this question for me. My impression from the comments here so far is that the main difference is in the way the interrupt handlers are set up, so I want to make sure I really take my time going through the new interrupt.[ch] files. Overall, I'm happy with the changes made. The overall architecture now more closely matches the overall architecture I've been using for my team, which means that when I find myself at an event helping some random with their code, based on this, I will have an easier job. |
Re: New C18 3.0+ Compatible FRC Code
Quote:
Quote:
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
Quote:
EHaskins: The student version 3.15 can also be used if you fix the 3.15 version of the adc.h system file. There is a missing "#endif" at line 536. It does a series of PIC architecture checks and they forgot to close one conditional #if, thereby wiping out all the subsequent statements. (I'm traveling in Va this week, so I won't be much help. I touch base (CD) when I can, which is actually more often than I expected to.) |
Re: New C18 3.0+ Compatible FRC Code
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"? |
Re: New C18 3.0+ Compatible FRC Code
Definitely very cool. Finally we're up to the times and there will be no need to dig up one of the old kickoff CDs every time we want or need to be able to compile code on a new computer. I'll definitely check it out soon.
|
Re: New C18 3.0+ Compatible FRC Code
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? |
Re: New C18 3.0+ Compatible FRC Code
Quote:
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". |
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
Quote:
Although, on second thought, this may be a pain to maintain. |
Re: New C18 3.0+ Compatible FRC Code
Quote:
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
Quote:
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 |
Re: New C18 3.0+ Compatible FRC Code
Quote:
Quote:
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! :) |
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
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: |
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.
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
Eugene |
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
Quote:
I have sent you a web link to download a zipped example via a private message. Eugene |
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
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... |
Re: New C18 3.0+ Compatible FRC Code
I wonder if Kevin's release of this updated code (albeit a beta version) implies that the IFI default code will also be heavily revised for 2008. If nothing else, I think it strongly implies that the canonical IFI RC/OI package will be in the KOP this year, even if it is the last time.
Alex |
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
Kevin,
I noticed this file does not include any encoder-related files. Are you planning to add support to encoders to this code? Thanks. |
Re: New C18 3.0+ Compatible FRC Code
Quote:
You could basically copy and paste the code from the encoder driver's ISRs into the ISRs in this version (or put them in another file and call them from the ISRs, which would probably be more readable) and add the Get_Encoder_x_Count() function. Actually, if you just didn't call the initialization functions, you could probably use the current encoder code verbatim (well, for encoders one and two anyway, for 3-6 you'd probably just want to reuse the code from encoder 1-2 instead of the encoder driver's functions for encoders 3-6). I would say that it would probably be less than 20mins to code. |
Re: New C18 3.0+ Compatible FRC Code
Great design. Just a word about words.
The *_Spin() functions are great -- it's just that in my little robot namespace world "spin" refers to when the robot turns around its axis. (We set up the joystick so one of the buttons calls the spin() routine that makes the robot turn on a dime.) When I saw "spin" that's what I thought it meant; I had to study the code to see what it really meant. Is "spin" so standard in the embedded world that I should invent a new term for "turning on a dime"? (Diming? What if you only turn 90 degrees? Is that Quartering?) Or can we name the _Spin() functions something else? _WhileWeAreWaitingForNewData()? _StudyHall()? _Loitering()? Sorry for the bad jokes, but I'm seriously concerned about overloading the term "spin"... It just me? |
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
I noted that when I look at the .map file there is no reference to the low.isr.tmpdata in the map file ?? why is this?? I wanted to see how much space the compiler is giving to this... .tmpdata is there...
thanks... |
Re: New C18 3.0+ Compatible FRC Code
Quote:
int a = 2; int b = 3; int c = 4; int d; d = (a + b + c) - (c + a); Compile and then look at the .map file. -Kevin |
Re: New C18 3.0+ Compatible FRC Code
Quote:
Alex |
Re: New C18 3.0+ Compatible FRC Code
Kevin,
If you're looking for a head count for your template, count the TechnoTicks (236) in! |
Re: New C18 3.0+ Compatible FRC Code
You could also probably count us (8) in too.
I have a somewhat related question that stems from encoders. How fast to digital inputs update? Is it the 26.6ms loop? Faster? I'm asking because I'm wondering about updating the encoder B channel. If it doesn't update fast enough, aren't we risking using an old value and so getting the wrong direction? |
Re: New C18 3.0+ Compatible FRC Code
Quote:
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
|
Re: New C18 3.0+ Compatible FRC Code
We(1103) willl be using this code. So far it looks good.
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
Well in ver 3.10 of the compiler the .map file will NOT show an entry if there is no storage needed, but 3.15 will show a null entry. (as it should) |
Re: New C18 3.0+ Compatible FRC Code
Hi Kevin.
Your new structure makes a lot more sense. I never liked the way the old code fell into the "autonomous" pit and never came out. I installed MPLAB8 and upgraded to cc18 3.1. Other than the typical include/lib path issues asociated with any upgrade, your new code built just fine. My own personal preference is to use more, smaller files, so my vote would be to split the auto and disabled modes out into sepparate files. I beleive that this would actually make it easier for teams not addressing these modes because they wouldn't have to keep scrolling arround the empty functions. If you are lucky to have more than one programmer on the team, it does enable the "Autonomous" mode programmer to work somewhat independantly of the "teleop" programmer. Last year I also had c&h files for each of the four subsystems: UserIF, Drive, Manipulator and Vision, and assigned each subsystem to a student. It kept them out of each other's hair, and made it easier to see what had changed from version to version. Not much downside to extra files. To Fill up the new files a bit, I would also vote for including the init_ functions. So, each of the mode files would have an init, spin and run function. I also agree with the recomendation for teams to have a robot.h and robot.c file. It's the first thing I add to the standard ifi code. In my case this is where I put all my #defines for translating the cryptic I/O port names to robot functions, and code for enforcing various robot safety limits. Team 1629 will definately be using your new code so I'm eager to see you fold all your other cool functions into this structure. Phil. A happy camper:D |
Re: New C18 3.0+ Compatible FRC Code
Wow Kevin! I love it already. Everything is so well organized and everything is incorporated. This will be a really good tool for rookies as well as veteran teams :). I will definitely be using this on our 2008 robot :D
|
Re: New C18 3.0+ Compatible FRC Code
Just noticed this:
In your pwm_readme.txt file, you still reference Process_Data_From_Master_uP() I guess this would now be: Teleop() and Autonomous(), although I see you make the call after these functions. Phil. |
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
Quote:
Good question! One way to look at it is: During Competition, the systems boot up in Disabled mode. It wouldn't be a bad place to do some of the system initializations, Pre-calibrations and OI input gathering. Gyros would love the fact that the bot is not moving and compressors aren't running. On the other hand, it is a bit redundant considering the Initialize () routine already exists in user_code.c. Honestly, I say, give it the boot. (Yes, pun intended:ahh: ) |
Re: New C18 3.0+ Compatible FRC Code
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
[*] actually we called ours Disabled_Fast_Loop(); and the run function was Disabled_Slow_Loop(), but I think I like _Spin() and _Run() better. |
Re: New C18 3.0+ Compatible FRC Code
Quote:
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
Quote:
Just my opinion. |
Re: New C18 3.0+ Compatible FRC Code
Quote:
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
We put in the delay because we didn't know if the system transitioned through Disabled between auto and teleop. Based on your post, I'm glad we took that precaution. We also did it for code symetry more than anything else.... Yes, I also indent all my "=" signs the same amount. Just call me anal. I think the Disabled_Init() is most usefull once before the match begins, so that would mean that you wouldn't really want it called between Auto and teleop. I thought that it might also be good to call it on the transition from Teleop back into Disabled (to indicate that there might have been a field reset situation after a bad start) but the bot is in an unknown state at that time anyway (maybe on it's side) so you wouldn't necessarily want to make any callibration assumptions. In the end I guess this function would only be called after reset, so it is a bit redundant with Initialize(). Although, if the function is resetting variables that only get used in disabled mode, then my anal side says that that's where they should be declared and initialized :) This is also what we did with our UserIF, Drive, Manipulator and VisionSystem variables. Declared and initialized in subsystem modules. Thanks for even considering it :rolleyes: Phil. |
Re: New C18 3.0+ Compatible FRC Code
Quote:
trivial note: I don't know whether you update your comments along the way, or once the build has stabilized, but I just wanted to mention that the ifi_frc.c file still has all the old reference to user_code.c in it's comments. Another thing I realized when I loaded this project was that your development environment and mine don't match, so it caused a hickup that may trip up first time users (me two years back:) You have the CC18 environment loaded under the MPLAB program folder, wheras mine is loaded under the c:/ root. I have no idea if this was a decision of mine, or the compiler default (i think so), or a consequence of me simply "upgrading" last year's install, but it means that when I load your project, two things happen: 1) MPLabs prompts me as to whether I want to keep my old CC18 compiler and Linker folders or use the ones in the project (I say keep the old one) 2) I get a linker error because MPLAB can't find the clib library. I need to go to Build-Options/Directories/Library, and set the path from c:/program files/mplab/cc18/lib to c:/cc18/lib My only reason for bringing this up is to determine what you, and the likely "critical mass" of users will be using. If CC18 should be loaded under MPLAB then I'll move mine. If this is contrary to the install default, then a "pre-install" readme would be a good idea to prevent (minimize) the initial confusion of new users. Thanks for all the time you put in. Phil. |
Re: New C18 3.0+ Compatible FRC Code
Quote:
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
How about gyros? I noticed that your gyro code from last year uses both gyro.c/h and adc.c/h. I copied both of thme, and I've been fumbling for a while with integrating them and timers.c. I have not been able to do that yet, generating a red-light-of-doom in the process. Any ideas or advice? EDIT: Kevin, I believe I may have found a problem. Interrupts.h uses #define ENABLE_INT_# (for # being 1,2,...), while ifi_frc.c checks #ifdef ENABLE_INTR_# when checking for the ISR. That is an oversight, right? I searched the rest of the files and could not find another reference to ENABLE_INTR_#. |
Re: New C18 3.0+ Compatible FRC Code
Quote:
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
I'll also port the ADC code too at some point (I need to find a better way of installing ISRs). I'll look into the INTR vs. INT issue this evening. It's probably just some knuckle-headedness on my part. Thanks for catching it. -Kevin |
Re: New C18 3.0+ Compatible FRC Code
How do you get a version 8 MPLAB? The disks that we've received from FIRST were all version 7.20. IFIRobotics' web site still claims that they only work with 7.20. I didn't notice the MPLAB requirement and now I have a hybred system that won't compile my 2.4 code nore will it open Kevin's new workspace.
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
It's free |
Re: New C18 3.0+ Compatible FRC Code
Quote:
I have had no issues running c18 v2.4 or v3.10 with MPLab v8. Your 2.4 code will not compile with c18 v3, and the MPLab v8 workspaces will not open in older versions of MPLab. If you want to be able to compile your 2.4 code, you'll need to copy the mcc18 folder from a computer with 2.4 installed, and change the header, linker, and library serch folders of you 2.4 projects to point to the 2.4 folders. |
Re: New C18 3.0+ Compatible FRC Code
Last year we got an updated adc code which only used 1 interrupt per sample, instead of 2. Is this already implemented in the new adc code? Also last year we had to use a new processor .h file for the encoders. I see the encoder work is in progress, so this will also disappear, I hope?
Isn't it new to be able to program for the disabled mode? Is there a hint there? |
Re: New C18 3.0+ Compatible FRC Code
Quote:
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
My team, and probably several others (I know Chief Delphi does it or at least did it at one point), implemented mode determination to help prevent integrator wind up in PID loops. |
Re: New C18 3.0+ Compatible FRC Code
Quote:
|
Re: New C18 3.0+ Compatible FRC Code
Looking back at other posts, I see that now. It is nice for newer teams to see that they could initialize the gyro while siting and waiting for the match to begin. Now that is explicit. This newer code does look straight forward.
I won't get a chance to actually download this into a CD prior to kick off, but will spend my lunches studying it. Thanks to all of you already solving problems! |
Re: New C18 3.0+ Compatible FRC Code
I see there is a .lkr file 18f8520, does that mean I can play with it on a VEX bot?
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
|
Re: New C18 3.0+ Compatible FRC Code
Kevin,
While we're looking at the new code, what is the difference between interrupts 1,2 and 3-6? I read the encoders readme, and I understand how they differ. However, I haven't seen any documentation about the interrupts themselves. Could you please explain me how (if it all) they differ? |
Re: New C18 3.0+ Compatible FRC Code
Quote:
Digital inputs 3-6 all go together to a third interrupt circuit, and automatically cause an interrupt on any input transition. There's only one flag to say that "something changed" on those pins. In order to determine which of the four inputs is responsible, the software has to do its own bookkeeping to compare the previous input state against the present one. That's a simple explanation. There's more detail in the PIC manual if you want it. |
Re: New C18 3.0+ Compatible FRC Code
Quote:
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
Thanks for the link to Microchip. I went there three times and couldn't find it. The page looked like a sales page so I didn't scroll down and see the download links. Oh well. I've got it now.
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
Thank you Kevin for all of your hard work! I like what I see so far and I can assure you that team 34 will put this to good use. |
Re: New C18 3.0+ Compatible FRC Code
Kevin:
Here are some change that I made to your serial routine to set the baudrate correctly for any processor speed. in serial_port.c #ifdef ENABLE_SERIAL_PORT_ONE void Init_Serial_Port_One(void) { // Start by initializing the serial port with code // common to receive and transmit functions // SPBRG = BAUD_38400 ; // baud rate generator register [251] SPBRG = SPBRG_VAL_1; // defined in hardware.h // #ifdef USART1_USE_BRGH_LOW TXSTAbits.BRGH = 0; // high baud rate select bit (asynchronous mode only) [248] #else // 0: low speed TXSTAbits.BRGH = 1; // high baud rate select bit (asynchronous mode only) [248] // 1: high speed #endif // 1: high speed .................................................. .................................................. .................................................. ...... #ifdef ENABLE_SERIAL_PORT_TWO void Init_Serial_Port_Two(void) { // Start by initializing the serial port with code // common to receive and transmit functions // SPBRG2 = BAUD_9600; // baud rate generator register [251] SPBRG2 = SPBRG_VAL_2; // defined in hardware.h // #ifdef USART2_USE_BRGH_LOW TXSTA2bits.BRGH = 0; // high baud rate select bit (asynchronous mode only) [248] #else // 0: low speed TXSTA2bits.BRGH = 1; // high baud rate select bit (asynchronous mode only) [248] // 1: high speed #endif // 1: high speed ------------------------------------------------------------------------------------------------------------------------------------------------------------ in the hardware set up routines... // Define system xtal/clock frequency // #define CLOCK_FREQ (40000000) // Frequency in Hz #if defined(__18CXX) // All PIC18 processors #include <p18cxxx.h> #define INSTR_FREQ (CLOCK_FREQ/4) // PIC18 clock divider #else #error Unknown processor or processor not defined #endif // Set up serial port(s) baud rate // #define BAUD_RATE_1 (38400) // Serial port 1, bps #define BAUD_RATE_2 (38400) // Serial Port 2, bps // set as needed... //#define USART1_USE_BRGH_LOW // for most lower baud rates //#define USART2_USE_BRGH_LOW // for most lower baud rates #if defined(USART1_USE_BRGH_LOW) #define SPBRG_VAL_1 ( ((CLOCK_FREQ/BAUD_RATE_1)/64) - 1) #else #define SPBRG_VAL_1 ( ((CLOCK_FREQ/BAUD_RATE_1)/16) - 1) #endif #if defined(USART2_USE_BRGH_LOW) #define SPBRG_VAL_2 ( ((CLOCK_FREQ/BAUD_RATE_2)/64) - 1) #else #define SPBRG_VAL_2 ( ((CLOCK_FREQ/BAUD_RATE_2)/16) - 1) #endif #if ((SPBRG_VAL_1 > 255) || (SPBRG_VAL_2 > 255)) #error "Calculated SPBRG value is out of range for current CLOCK_FREQ." #endif |
Re: New C18 3.0+ Compatible FRC Code
To be clear, without Kevin this would be miserable. Team 1622 is massively
in your debt. Thank you. For those who have not already installed the MCC upgrade, make sure you put it in the same directory with the upgraded MPLAB 8.0. Otherwise the linker can't find the libraries. I know by the trying it the wrong way. |
Re: New C18 3.0+ Compatible FRC Code
Rookie team 2605 will be using your code, it is structured in a way that makes more sense, I have not gone through it all the way yet, but so far so good. BTW is there a better search tool in mplab than the just straight basic find? For my embedded systems work I am always using grep and regexps, so far mplab has been really disappointing.
|
Re: New C18 3.0+ Compatible FRC Code
Comphappy,
The answer maybe Yes! Try under the Project Menu > Find in Project Files. Once you enter your keyword you'll be able to see the results in the output window under the find in files tab. Double click on whatever you want to see and a new window will open with a pointer to your chosen element. I hope this answers your question, as I'm not really sure as to what grep would deliver as a result. |
| 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