|
|
|
#1
|
|||
|
|||
|
Re: New C18 3.0+ Compatible FRC Code
Kevin:
An idea... A quick and dirty utilizations counter... Add a global long integer to you project called "cycle". At the end of the while(TRUE) in main.c, do a cycle++ to build a loop counter, this will tell you how many time you have been in the while(TRUE) loop. In the 26.4ms loop, read the cycle counter, clear it and divide by (264k clock cycles, the number of clock cycles in 26.4ms - the number of cycles used in the while(TRUE) ) This will give you a crude % utilization of the CPU that the teams can use to check on there code efficiency... also, the counter could be scaled so that one could use an unsigned int Last edited by Lafleur : 11-01-2008 at 18:50. |
|
#2
|
||||
|
||||
|
Re: New C18 3.0+ Compatible FRC Code
how exactically are we supposed to build in 7.21 with the c18 3.10 and now i can't just push F10 to build.
edit: also when I open it it does not open correctly when I try to open the project files. Last edited by Loki1989 : 11-01-2008 at 19:44. Reason: found new issues |
|
#3
|
|||
|
|||
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
an error in my logic.... you also need to take the number of loops and multiply by the number of cycles in the loop and use this to subtract from the total number of cycles in the 26ms... tom lafleur This is the code I did in a TEST module with only the ATD and Serial ports, I have a timer that interrupts me ever 100ms. I disable all interrupts and use the MPLAB simulator to measure the number of cycles in the main loop. In my case it was 42 cycles. Note, division is only by 10,000 and not 1,000,000 to give a % with out the need to multiply by 100, saving some cycles. int util; long int cycle = 0; is a global in the code, it needs to be long because of the multiplication need a long in the main loop I have a cycle++; // here we will calculate the % of the CPU we are using // we are here every 100ms, that 1,000,000 cycles of the processor at 40MHz // utilization = the number of times in the do nothing loop, * the number of cycles in // the main loop. 42 is current number of cycles in main loop util = 100 - ((cycle * 42)/10000); cycle = 0; Last edited by Lafleur : 12-01-2008 at 13:01. Reason: Update |
|
#4
|
||||
|
||||
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
|
#5
|
||||
|
||||
|
A Makefile (forced to call it Makefile.txt to upload) for Linux in included. I'm using cxoffice (a canned wine setup) but it can be easily altered to work with plain old wine or to run under Windoze. This compiled Kevin's latest stuff with no errors but with a bunch of signed/unsigned warnings. I have not run the code on the robot yet!
Enjoy |
|
#6
|
|||
|
|||
|
Re: New C18 3.0+ Compatible FRC Code
Hi,
EDIT - We've got a working install of mplab 8.00, but we can't seem to get 3.00 installed. We run through the installer fine, but it doesn't seem to actually install.. MPLAB is still using 2.40, and we can't find the installation directory of 3.00 - only 2.40. I'm trying to install mplab 8.00 and the 3.0 compiler, I downloaded the software on the first post, and the tried running it over the install of mplab 7.20. It seemed to install, but now when ever we open mplab it says 8.00 is not enabled, but we can still use 7.20. How is the best way to install it and the compiler with pre-existing versions all ready installed? Last edited by bronxbomber92 : 12-01-2008 at 11:17. |
|
#7
|
|||
|
|||
|
Re: New C18 3.0+ Compatible FRC Code
CPU Utilization
In a quick test I did today, using a ATD sample rate of 200Hz, I had 19% utilizations of the processor. Changing only the ATD sample rate to 6400Hz, utilization went to 43%. |
|
#8
|
|||
|
|||
|
Re: New C18 3.0+ Compatible FRC Code
Using new code with Eclipse? How to make the correct makefile? Help?
|
|
#9
|
|||
|
|||
|
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) |
|
#10
|
||||
|
||||
|
Re: Serial Ports
Quote:
-Kevin |
|
#11
|
|||
|
|||
|
Re: Serial Ports
Quote:
thanks... |
|
#12
|
||||
|
||||
|
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)
{
static unsigned int i = 0;
static unsigned int j = 0;
int temp_gyro_rate;
long temp_gyro_angle;
int temp_gyro_bias;
i++;
j++; // this will rollover every ~1000 seconds
if(j == 10)
{
printf("\rCalculating Gyro Bias...");
}
if(j == 60)
{
// start a gyro bias calculation
Start_Gyro_Bias_Calc();
}
if(j == 300)
{
// terminate the gyro bias calculation
Stop_Gyro_Bias_Calc();
// reset the gyro heading angle
Reset_Gyro_Angle();
printf("Done\r");
}
if(i >= 30 && j >= 300)
{
temp_gyro_bias = Get_Gyro_Bias();
temp_gyro_rate = Get_Gyro_Rate();
temp_gyro_angle = Get_Gyro_Angle();
printf(" Gyro Bias=%d\r\n", temp_gyro_bias);
printf(" Gyro Rate=%d\r\n", temp_gyro_rate);
printf("Gyro Angle=%d\r\n\r\n", (int)temp_gyro_angle);
i = 0;
}
Update_OI_LEDs(); // located in ifi_code.c
}
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. |
|
#13
|
||||
|
||||
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
|
#14
|
||||
|
||||
|
Quote:
"Procrastination mode" I wonder if FIRST will use that to replace Hybrid mode next year? |
|
#15
|
||||
|
||||
|
Re: New C18 3.0+ Compatible FRC Code
Well, in the past, the difference wouldn't be very noticeable...
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Does the camera code suits to all versions of MPLAB and C18? | razer | Programming | 3 | 04-01-2007 14:50 |
| Trying to follow C18 interrupt context code... | dcbrown | Programming | 5 | 21-12-2006 09:01 |
| Error w/ FRC code | JamesBrown | Programming | 2 | 08-01-2005 16:17 |
| Programming code Fix FRC | Ferazel2001 | Programming | 6 | 08-02-2004 02:46 |
| FRC default code | hedgehogger | Programming | 2 | 21-01-2004 18:41 |