![]() |
Re: New C18 3.0+ Compatible FRC Code
It's the ifi_frc_encoder_beta oput of the box....using the 3.10 compiler and 8.0 MpLab
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
Kevin,
I re-installed 3.10 and it worked just fine! Thanks for all your work! Jon |
Re: New C18 3.0+ Compatible FRC Code
Quote:
I think I might have a simpler solution. I have the ISR that calls on PWM() to set another flag high (not the interrupt flag), and check that flag in the _Spin() functions. As a result, assuming the calculation runs fast enough, I'll be one cycle behind, which would probably be the case either way. Does that sounds like it could work? Thanks. |
Re: New C18 3.0+ Compatible FRC Code
Quote:
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
I really appreciate what you are doing, and i don't mean to ask for more, but would it be possible for you to create diff/patch files when you release a new version, to make updating our code easier? |
Re: New C18 3.0+ Compatible FRC Code
Quote:
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
I can, with 90% certainty, say that this year we will be using both of the GTS's and one quadrature encoder on our bot. Two for the drive, one for the "ball handler". Now, if the budget allows, we may go with three quadratures. (I hope, I hope, I hope :) ) |
Re: New C18 3.0+ Compatible FRC Code
Quote:
if(INTCONbits.TMR0IF) { // Get encoder counts // Calculate position/velocity // Do PID calculations // Update PWM values //reset interrupt flag INTCONbits.TMR0IF = 0; } ...you can implement your 100Hz contol algorithm. -Kevin |
Re: New C18 3.0+ Compatible FRC Code
thank you kevin! i compiled, and everything checks out!
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
EDIT: Actually, I am not sure if it will run any more slowly at all. This looks great. EDIT 2: Timer 0 does not seem to have the support to run to a predetermined value like timers 2,3,4. Should we use timer 2 instead? Another question. None of these timers actually allow us to run a 100hz cycle, even with 1:16 pre- and post-scalers. The slowest we can do is 150hz. Am I missing a way to do it, without using a second flag, or should we just use 150hz (or a double flag)? EDIT 3: I just ran into another potential obstacle. Our calculations say that we will get at most 15 ticks from the encoder per cycle. That does not seem like a very high resolution. We're currently trying to see if this will actually be an issue, and if so, what we could do about it. |
Re: New C18 3.0+ Compatible FRC Code
I see the linker problem when enabling some but not all of the encoders in the 3 to 6 range.
Chad |
Re: New C18 3.0+ Compatible FRC Code
The ISR linker issue occurs if encoders_3 and beyond are enabled because...
ENABLE_INT_3_6 must be defined in ifi_frc.h, in order to use encoders in the range 3_6 This causes 'calls' to the ISR routines from ifi_frc.c lines 326 to 338. But if this code block is enabled, all the interrupt code must exists in encoder.c. That only happens if ENABLE_ENCODER_3 through ENABLE_ENCODER_6 are ALL defined in encoder.h which compiles in ALL the ISRs in encoder.c. The define hierarchy needs to be fixed, or use all of 3_6 ISRs or none of them. Chad |
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
Quote:
First I would like to say, Thank you in advance. Is it possible that once you make this modification to the project files and post them, that you could also list the files that were modified so we would be able to just copy the modified files into our already customized projects and then just rebuild. It would save quite a bit of time if we didn't have to make all the customizations again. If not, no sweat, we could always use the practice. :cool: |
Re: New C18 3.0+ Compatible FRC Code
Does it give anyone heartburn if I just release one build for each of the two compiler versions that has support for the ADC, gyro and encoders already built in? You'd be able to remove funtionality by commenting out a few #defines.
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
I have no problem with that.
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
I don't mind hacking together various functions, in fact, I have learned a lot by doing this in the last couple years. But, if it is together already, it would be VERY convenient! ;) |
Re: New C18 3.0+ Compatible FRC Code
I know this might be kinda random, but does anyone know if we are allowed to use any kind of gps system in our robot sense it's location on the field?
|
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:
BTW, would you think that using 4 interrupts,INT's 3-6, at 128 ints/sec (every ~8ms) would be overstressing the processor? My students want to control our mecanum drive with an encoder on each wheel; I favor the gyro approach. Thanks again for your work for the teams! |
Re: New C18 3.0+ Compatible FRC Code
How are people implementing these updates?
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
Chad |
Re: New C18 3.0+ Compatible FRC Code
We're testing the new gyro code, but it overrides all of our commands and sets our pwm outs to 0. Once we put anything referencing the pwm outs we're using, it messes them up. We searched through the code, but we can't find anything that might be causing this. Has anyone else come across this problem?
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
Quote:
|
Serial Ports
Kevin:
Is there a hard limit at 128 bytes in the Serial Queue's?? RX_1_QUEUE_SIZE 128 // Must be a power of two (i.e.,8,16,32,64,128) |
Re: New C18 3.0+ Compatible FRC Code
(This may be a little bit of a tangent.)
I'd like to report to anyone who's interested that the C18 3.10 compiler works just fine under Wine (on Linux), after fixing one minor issue. I had v 2.4 working under Wine. I ran the upgrade, and then things did not work. I don't remember the exact error, but it did not compile successfully. I copied my mcc18 directory from one machine (where I'd run the upgrade) to a different machine, and it worked fine on the new machine. I then copied my ~/.wine directory from the new machine back to the old machine, and the compiler worked fine. If you plan on using v 3.10 under Wine, my recommendation is to do one of the following: - Run the upgrade on a Windows machine, and then copy over the mcc18 directory to run it under Wine - Make a backup of ~/.wine, then run the upgrade program under Wine, then restore ~/.wine. |
Re: Serial Ports
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
Re: Serial Ports
Quote:
thanks... |
Re: New C18 3.0+ Compatible FRC Code
Quote:
Phil. |
Re: New C18 3.0+ Compatible FRC Code
Kevin,
This is just a thought and should be implemented by teams as they feel their needs require. In the teleop.c file, you currently have the gyro bias calculation process happen in the Teleop function. Code:
void Teleop(void)This may be fine in some instances, but in competition, the robot is powered up in disabled mode, then transitions into autonomous(Hybrid) then back to disabled and finally into teleop. The gyro bias would never be calculated until well after it may be needed. Wouldn't it be better if this code were placed in the disabled.c file in the Disabled function. An additional flag could be set to prevent the bias calc process from running during any additional disabled periods. |
Re: New C18 3.0+ Compatible FRC Code
Quote:
Code:
int limit(int value)Code:
unsigned char limit(int value) |
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
Quote:
Code:
unsigned char limit(int value) |
Re: New C18 3.0+ Compatible FRC Code
Thank you. I thought it was probably something stupid I did.
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
Dave, thanks for catching my gaff <grin>. -Kevin |
Re: New C18 3.0+ Compatible FRC Code
Quote:
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
"Procrastination mode" I wonder if FIRST will use that to replace Hybrid mode next year? |
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:
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 |
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:
Code:
if(j == 300)Code:
if(==35 && i >= 300) |
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
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:
Code:
// #define ENABLE_INT_1 // enable if using encoder channel 1 |
Re: New C18 3.0+ Compatible FRC Code
Quote:
Code:
// Remove the comment slashes from one or more of the following lines to-Kevin |
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.;) |
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?
|
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. |
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
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
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
|
Re: New C18 3.0+ Compatible FRC Code
Ok, I have a question (more of a comment really), but I was hoping someone could either verify my understanding, or explain what I'm missing.
It seems the current gyro code as well as some things others have mentioned depend on putting processing code inside one of the Spin functions. Generally speaking, the spin function will be executed at a very high rate (essentially only processor-limited). However, at roughly 38Hz, the spin function is going to get delayed by however long it takes to run your general execution code, e.g., Teleop(). If this code is simple and runs quickly, this isn't likely to be too much of a problem. However, there is still going to be some delay associated with this code, let's call it T_d. Now, the frequency, 1/T_d is going to be important because it's actually the maximum frequency we can count on our spin function to run at over any arbitrary time interval. Right now it looks like we are processing our Gyro at 50Hz? (800Hz / 16 samples per update). This means we need to make sure that T_d < 20ms or else we will occasionally miss gyro samples. I agree that if T_d is pushing 20ms, you're probably going to have other problems since that's a lot of computation going on. I mostly wanted to clarify this in the case someone was thinking about trying to sample an analog signal at a data rate higher than 1/T_d (probably somewhere in the 800Hz - 6400Hz range), and still do the processing in the spin loop. In this case they might start seeing data go missing every once in a while. I guess my question then is why do we count on the spin code to do our processing since it's timing seems potentially sporadic. Wouldn't it be better to just do the gyro processing in the ISR alongside the analog-to-digital conversion? Then we would have high-frequency reliable processing of the gyro (or whatever other analog sensor we are processing), without having to worry about anything other than keeping our Teleop() execution time a decent amount under the theoretical limit of 26 ms. |
Re: New C18 3.0+ Compatible FRC Code
Quote:
Quote:
Quote:
Quote:
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
Thanks for the response Kevin. Sounds like my fear (and interpretation of the code) was mostly right, but as I was hoping, also completely unjustified :)
This looks like a great set of code and I'm very excited about getting a chance to play with it soon -- things have come a long ways from where they were in 2002... I think we were screwing around with PBASIC back then. I'm missing most of the competition, but I'll be hanging around my old team for their last week and a half or so. Plenty of time for last-minute debugging of the software. Kind of funny... doesn't seem to matter what robotics project I'm helping out with: DARPA Grand Challenge, or FIRST robotics... Kevin Watson manages to be involved and giving advice :) |
Re: New C18 3.0+ Compatible FRC Code
Quote:
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
Kevin,
Upgraded to the final 3.0 version....now I get a RLOD with just 1 encoder enabled.....what can produce this condition? |
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
Quote:
Thanx! |
Re: New C18 3.0+ Compatible FRC Code
Quote:
|
Re: New C18 3.0+ Compatible FRC Code
I must be missing something simple. I am using your code that is a couple of versions back, and when i enable the gyro code, all i get is this:
Gyro Bias=-1 Gyro Rate=0 Gyro Angle=0 after it has initialized I then pulled your most recent code enabled the adc and the gyro in both spin and teleop the code compiles correctly, but soon as i load it, i get a code error. |
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
I got my code to work, there was an ifdef that i had written that blocked out part of the init, but the new code still fails to load.
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
The code that I cannot get to load is the code off of your webpage 1/20/08 both with and without the gyro enabled
My code based off of the older version is working fine. |
Re: New C18 3.0+ Compatible FRC Code
Quote:
Make sure you're performing all the steps documented in readme.txt. -Kevin |
Re: New C18 3.0+ Compatible FRC Code
Red light of death. Code compiles fine. I then go into programming mode open the loader give it the hex file and it attempts of load. The file is loaded in, but the code error light stays solid, reset, same thing. It is not really an issue for me, as I am sticking with the old code (early version of the v3 compiler), but I do not quite get what is going on. Do you want the hex file that i generate?
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Guy Davidson |
Re: New C18 3.0+ Compatible FRC Code
Quote:
|
Re: New C18 3.0+ Compatible FRC Code
Kevin,
Now that I enabled the ISR's (grin) everything works fine. No need to include sonar code this year as the MaxBotix sensors have an analog output. |
Re: New C18 3.0+ Compatible FRC Code
Hmmm i dont know what the issue was, (i did have ISR enabled) I just now recompiled the code and loaded it, no issues. Serial communications issue on the load... I dont know.
|
Re: New C18 3.0+ Compatible FRC Code
Hello, this is my first year doing the programming on my team and we are having a very confusing problem. We are using an unmodified version of Kevin’s 2008 beta code with mplab v8 and c18 v3.1 and the code compiles fine and loads onto the robot fine, and it seems run on the robot, but the robot doesn't react at all. Its equally frustrating because when we load a copy of the 2007 code it works fine. It seems that no one else has had this problem (that I saw), though it seemed that Kevin referenced it in one of his posts.
Quote:
|
Re: New C18 3.0+ Compatible FRC Code
With out any code that is going to be hard to help you with, are you in teleop mode? What code do you have in your teleop function?
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
Code:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
2 Attachment(s)
I'm having a variety of problems, with the new code(http://www.kevin.org/frc/ifi_frc_sensor_30.zip), and the old encoder code (http://www.kevin.org/frc/frc_encoder.zip).
First off, I'll talk about the problems we were having with frc_encoder. When I had MPLAB 7.20 installed and was using v2.4 of the C18 compiler, everything compiled, and the encoders worked great on the robot. Here was the problem... there seemed to be about a 1/2 second delay between the robot receiving data from the OI, so I would move a joystick, then it would take 1/2 a second for the motors to start moving. I would release the joystick, and it would take 1/2 a second to stop (I almost had a bad incident with our new 80lb robot running me over). Okay, now for the 3.0 compatible code. I have MPLAB 8.00 installed and version 3.10 of the C18 compiler. I can compile the code as it is downloaded no problem, but when I try to initialize encoder 1 and encoder 2 using the code where i take out the //, it fails at the link step: MPLINK 4.1, Linker Copyright (c) 2006 Microchip Technology Inc. Error - could not find definition of symbol 'Initialize_Encoder_2' in file 'C:\Robot Code\2008\ifi_frc_sensor_30\teleop.o'. Errors : 1 If I comment out "Initialize_Encoder_2" it will say the same thing about encoder 1. Is my MPLINK out of date, since it says 2006? Here are some snapshots of MPLAB with my horrible hand-eye coordination with my trackpad: :D Attachment 6102 Attachment 6107 The other 4 errors are with this part of code: Code:
// Remove the // below to initialize encoder #1 |
Re: New C18 3.0+ Compatible FRC Code
Quote:
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
Oops, I never saw the pesky README. :D I already see what I did wrong, and I will edit this post a bit later to tell you if I got it working.
Also, the link to the beta4 software doesn't want to work. Thanks for the quick response though... I was hectically trying to get this code working because our programming mentor is about to go to Indonesia on business. EDIT: I got it working! Thanks a bunch! |
Re: New C18 3.0+ Compatible FRC Code
Quote:
Thanks a lot for the code, saves a great deal of time. |
Re: New C18 3.0+ Compatible FRC Code
I think I've found a bug in the Gyro code....
I know... it seems unlikely considering how long it's been in service, but this problem has been bugging me for a while and I finally got the clues I needed to locate it. Here is the function. Quote:
I think the problem is that GYRO_CAL_FACTOR is defined as 1000/1000, but the multiplication is being done AFTER the prior expression is cast to an integer... Therefore if ((((long)gyro_rate * GYRO_SENSITIVITY * 5L) / ADC_RANGE)) calculates to anything above 32 or below -32, then multiplying it by 1000 will cause the number to exceed the valid range of an integer. I think the second to last bracket is misplaced... I think it should be: return((int)((((long)gyro_rate * GYRO_SENSITIVITY * 5L) / ADC_RANGE) * GYRO_CAL_FACTOR)); I'm going to try it tomorrow... I'm just greatful I didn't have to write this code.... Thankyou Kevin... really. Phil. |
Re: New C18 3.0+ Compatible FRC Code
Quote:
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
Kevin,
Would it be too much to ask for an updated library for the EDU-RC? ;) |
Re: New C18 3.0+ Compatible FRC Code
I just discovered something else interesting about the gyro code... specifically the way the angle resolution relates to the analog input scaling.
I detected this as I was logging heading data as I was driving around and around our track. On my system I have 4 Analog inputs, that I'm running 4 amples per update at 1600 Hz... This give me a Gyro update rate of 100 updates per second, and an ADC Range of 2048 and In the Gyro code... for an ADXRS150 I have Quote:
Quote:
Max Long is 2147483648 so if I divide this by 204800 I get 10485 ... Which, in theory is the maximum result I can get... But wait, this is millirads so the maximum angle I can measue is... just over 1.6 full rotations... Oops... Either I did my math wrong, or I have to reduce my update rate. In fact, this does reflect what I see in my log data... after getting to 10485 mRad, the angle starts counting down again... So I need to reduce my ADC range/rate, or reduce my measurement accuracy (like changing to tenth of a degree.) No wonder my bot corrected in the wrong direction on evey second lap :) |
Re: New C18 3.0+ Compatible FRC Code
Quote:
Code:
void Read_Yaw(void) { |
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
Sorry if this has been addressed before I don’t have time to go through all 288 posts but we are having an issue when we compile. Here is what our output looks like, if anyone can help it would be greatly appreciated. Thank you
Code:
Clean: Deleting intermediary and output files. |
Re: New C18 3.0+ Compatible FRC Code
You need to go to the project menu then build options then project
On the directory tab select Header Search Path (i dont have mplab infront of me right now but it is the header one), create a new one that points to the mcc18\include folder where ever that may be, it might be in C:\Program Files\ or just under C:\ Seeing as that variable is off you may also need to set the Library Search Path to mcc18\lib folder |
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:
Code:
Clean: Deleting intermediary and output files. |
Re: New C18 3.0+ Compatible FRC Code
Quote:
The clib.lib error is due to MPLAB not knowing where your compiler libraries are installed: Project > Build Options > Directories tab > Library Search Path -Kevin |
Re: New C18 3.0+ Compatible FRC Code
cool, it all works now, thank you very much :)
|
Re: New C18 3.0+ Compatible FRC Code
Just FYI, I believe that I have a single version of the code that will work with all robot controllers from 2004 on and can be built with C18 2.4 or 3.1. After seeing if I can improve the gyro integration code (per Philbot's posting above), doing some additional testing, and writing a bit more documentation, I should be able to release the code in the next few days.
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
Quote:
You truly are an example that all FIRSTers can look to, including myself. Thank you for your incredible efforts!! |
Re: New C18 3.0+ Compatible FRC Code
I do like the new code layout. I would like to see the code for C18 2.4. We do prototyping on previous years' robots and having both 3.15 and 2.4 on our machines seems a bit difficult to manage.
|
Re: New C18 3.0+ Compatible FRC Code
Kevin,
Now finding that the RC is stuck in Programming Mode at the end of download if adc is initialized.......any suggestions? (I did read the readmes!!!) Jon Mittelman |
Re: New C18 3.0+ Compatible FRC Code
Hi Kevin,
We keep on getting a error that ADC_CH0 is not defined. This happens when we try to use rc_ana_in_01. We looked in all of the header files including the complier file and could not find the definition but it is clearly used in ifi_frc.h.This might be a stupid error but please can someone help us. Thanks, Julan |
| 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