![]() |
Re: New C18 3.0+ Compatible FRC Code
Quote:
The analog inputs are not instantaneous. You have to start them, then wait a certain amount of time and then read them. The code in adc.c will do that for you and uses a timer to wait. Calls to Get_ADC_Result will simply fetch the result that the library has already captured for you. The function Get_Analog_value does the start/wait/read operation in-place and takes longer and consumes valuable cycles that could be put to better use doing something else. |
Re: New C18 3.0+ Compatible FRC Code
Kevin, I have question about adc.c.
In Timer_4_ISR you have two for loops that cover the same range of indexes. Code:
if(samples >= adc_samples_per_update)Code:
if(samples >= adc_samples_per_update) |
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:
-Kevin |
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 |
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. |
Re: New C18 3.0+ Compatible FRC Code
Quote:
|
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; |
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
Re: New C18 3.0+ Compatible FRC Code
1 Attachment(s)
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 |
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? |
Re: New C18 3.0+ Compatible FRC Code
Kevin, First of all thanks, this will be a great help.
Our team has a 2005 robot controller and operator interface mounted to a board for testing purposes when it is not practical to use the current robot controller (e.g., the current controller is on the robot, and the robot is being built or modified). We swapped out the libraries and linker files for the ones corresponding to the PIC18F8520, changed the target to the 8520, and tried to compile. We got this error(in your ifi_frc_gyro code, if it's relevant): Code:
C:\Users\NetElemental\Documents\Code\ifi_frc_gyro\ifi_code.c:33:Error [1105] symbol 'ifi_analog_channels' has not been definedThe line code corresponds to Code:
29 #if defined(__18F8722)Thanks, James |
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%. |
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
| 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