Go to Post Hi. My name is Rick and I am a Roboholic. - Rick TYler [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 26-09-2007, 17:18
Bryan Herbst's Avatar
Bryan Herbst Bryan Herbst is offline
Registered User
AKA: Bryan
FRC #2052 (KnightKrawler)
Team Role: Mentor
 
Join Date: Sep 2007
Rookie Year: 2007
Location: Minneapolis, Minnesota
Posts: 545
Bryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond repute
Error in code light on, trouble finding error

Hey guys, finally got code to compile (I really hate MPLAB now), and got it to download to the controller, but the OI has the code error, no valid data/radio (blinking red), Program state (blinking orange), and radio modem (blinking red) lights on, and the RC mode light is off. I've been looking through the code, and have no idea whats going on.

User Routine-

Code:
/*******************************************************************************
* FILE NAME: user_routines.c <FRC VERSION>
*
* DESCRIPTION:
*  This file contains the default mappings of inputs  
*  (like switches, joysticks, and buttons) to outputs on the RC.  
*
* USAGE:
*  You can either modify this file to fit your needs, or remove it from your 
*  project and replace it with a modified copy. 
*
*******************************************************************************/


#include <stdio.h>

#include "ifi_aliases.h"
#include "ifi_default.h"
#include "ifi_utilities.h"
#include "user_routines.h"
#include "serial_ports.h"
#include "pwm.h"
#include "camera.h"
#include "camera_menu.h"
#include "tracking.h"
#include "tracking_menu.h"
#include "eeprom.h"
#include "terminal.h"


extern unsigned char aBreakerWasTripped;

int intMax(int x, int y)
{
 int max = x;
 if(y > max)
 {
     max = y;
 }
   return max;
}

int intABS(int i)
{
 if (i < 0)
  return -i;
 else
  return i;
}

     rom const int ctbl[255] = {-127, -124.654754, -122.3407176, -120.0583477,
 -117.8073909, -115.5875939, -113.3987034, -111.2404659,
 -109.1126283, -107.0149371, -104.947139, -102.9089807,
 -100.9002089, -98.92057018, -96.96981128, -95.04767885,
 -93.15391954, -91.28828005, -89.45050702, -87.64034713,
 -85.85754704, -84.10185344, -82.37301297, -80.67077232,
 -78.99487816, -77.34507714, -75.72111594, -74.12274122,
 -72.54969966, -71.00173793, -69.47860269, -67.9800406,
 -66.50579835, -65.05562259, -63.62926, -62.22645725,
 -60.84696099, -59.49051791, -58.15687466, -56.84577793,
 -55.55697437, -54.29021066, -53.04523346, -51.82178944,
 -50.61962527, -49.43848762, -48.27812316, -47.13827855,
 -46.01870047, -44.91913557, -43.83933055, -42.77903204,
 -41.73798674, -40.71594131, -39.71264241, -38.72783671,
 -37.76127088, -36.81269159, -35.88184552, -34.96847932,
 -34.07233966, -33.19317322, -32.33072666, -31.48474665,
 -30.65497986, -29.84117296, -29.04307261, -28.26042549,
 -27.49297827, -26.7404776, -26.00267016, -25.27930263,
 -24.57012165, -23.87487392, -23.19330609, -22.52516483,
 -21.87019681, -21.2281487, -20.59876716, -19.98179888,
 -19.37699051, -18.78408872, -18.20284018, -17.63299156,
 -17.07428953, -16.52648076, -15.98931191, -15.46252965,
 -14.94588066, -14.4391116, -13.94196914, -13.45419994,
 -12.97555068, -12.50576802, -12.04459864, -11.5917892,
 -11.14708637, -10.71023681, -10.28098721, -9.859084213,
 -9.444274504, -9.036304746, -8.634921609, -8.239871761,
 -7.85090187, -7.467758605, -7.090188633, -6.717938625,
 -6.350755247, -5.988385169, -5.630575058, -5.277071584,
 -4.927621415, -4.581971219, -4.239867665, -3.901057421,
 -3.565287155, -3.232303537, -2.901853234, -2.573682915,
 -2.247539249, -1.923168903, -1.600318547, -1.278734848,
 -0.958164476, -0.638354098, -0.319050383, 0,
 0.319050383, 0.638354098, 0.958164476, 1.278734848,
 1.600318547, 1.923168903, 2.247539249, 2.573682915,
 2.901853234, 3.232303537, 3.565287155, 3.901057421,
 4.239867665, 4.581971219, 4.927621415, 5.277071584,
 5.630575058, 5.988385169, 6.350755247, 6.717938625,
 7.090188633, 7.467758605, 7.85090187, 8.239871761,
 8.634921609, 9.036304746, 9.444274504, 9.859084213,
 10.28098721, 10.71023681, 11.14708637, 11.5917892,
 12.04459864, 12.50576802, 12.97555068, 13.45419994,
 13.94196914, 14.4391116, 14.94588066, 15.46252965,
 15.98931191, 16.52648076, 17.07428953, 17.63299156,
 18.20284018, 18.78408872, 19.37699051, 19.98179888,
 20.59876716, 21.2281487, 21.87019681, 22.52516483,
 23.19330609, 23.87487392, 24.57012165, 25.27930263,
 26.00267016, 26.7404776, 27.49297827, 28.26042549,
 29.04307261, 29.84117296, 30.65497986, 31.48474665,
 32.33072666, 33.19317322, 34.07233966, 34.96847932,
 35.88184552, 36.81269159, 37.76127088, 38.72783671,
 39.71264241, 40.71594131, 41.73798674, 42.77903204,
 43.83933055, 44.91913557, 46.01870047, 47.13827855,
 48.27812316, 49.43848762, 50.61962527, 51.82178944,
 53.04523346, 54.29021066, 55.55697437, 56.84577793,
 58.15687466, 59.49051791, 60.84696099, 62.22645725,
 63.62926, 65.05562259, 66.50579835, 67.9800406,
 69.47860269, 71.00173793, 72.54969966, 74.12274122,
 75.72111594, 77.34507714, 78.99487816, 80.67077232,
 82.37301297, 84.10185344, 85.85754704, 87.64034713,
 89.45050702, 91.28828005, 93.15391954, 95.04767885,
 96.96981128, 98.92057018, 100.9002089, 102.9089807,
 104.947139, 107.0149371, 109.1126283, 111.2404659,
 113.3987034, 115.5875939, 117.8073909, 120.0583477,
 122.3407176, 124.654754, 127};


int joysticklimit(int inp)
{
 if(inp < 127)
  {
   inp += 1;
   return inp;
  }
 else if (inp > 127)
  {
   inp -= 1;
   return inp;
  }
 else
  {
   return inp;
  }
}

int count = 0;
int nestedcount = 0;
static int oldcount = 0;
int countvert = 0;
static int oldcountvert = 0;
int countvert2 = 0;
static int oldcountvert2 = 0;
int count3 = 0;
static int oldcount3 = 0;
int rotationfw = 0;
int rotationrv = 0;
int groundlevel = 0;
int toplevel = 0;

/*** DEFINE USER VARIABLES AND INITIALIZE THEM HERE ***/
/* EXAMPLES: (see MPLAB C18 User's Guide, p.9 for all types)
unsigned char wheel_revolutions = 0; (can vary from 0 to 255)
unsigned int  delay_count = 7;       (can vary from 0 to 65,535)
int           angle_deviation = 142; (can vary from -32,768 to 32,767)
unsigned long very_big_counter = 0;  (can vary from 0 to 4,294,967,295)
*/

/*******************************************************************************
* FUNCTION NAME: Limit_Switch_Max
* PURPOSE:       Sets a PWM value to neutral (127) if it exceeds 127 and the
*                limit switch is on.
* CALLED FROM:   this file
* ARGUMENTS:     
*     Argument       Type             IO   Description
*     --------       -------------    --   -----------
*     switch_state   unsigned char    I    limit switch state
*     *input_value   pointer           O   points to PWM byte value to be limited
* RETURNS:       void
*******************************************************************************/
void Limit_Switch_Max(unsigned char switch_state, unsigned char *input_value)
{
  if (switch_state == CLOSED)
  { 
    if(*input_value > 127)
      *input_value = 127;
  }
}


/*******************************************************************************
* FUNCTION NAME: Limit_Switch_Min
* PURPOSE:       Sets a PWM value to neutral (127) if it's less than 127 and the
*                limit switch is on.
* CALLED FROM:   this file
* ARGUMENTS:     
*     Argument       Type             IO   Description
*     --------       -------------    --   -----------
*     switch_state   unsigned char    I    limit switch state
*     *input_value   pointer           O   points to PWM byte value to be limited
* RETURNS:       void
*******************************************************************************/
void Limit_Switch_Min(unsigned char switch_state, unsigned char *input_value)
{
  if (switch_state == CLOSED)
  { 
    if(*input_value < 127)
      *input_value = 127;
  }
}


/*******************************************************************************
* FUNCTION NAME: Limit_Mix
* PURPOSE:       Limits the mixed value for one joystick drive.
* CALLED FROM:   Default_Routine, this file
* ARGUMENTS:     
*     Argument             Type    IO   Description
*     --------             ----    --   -----------
*     intermediate_value    int    I    
* RETURNS:       unsigned char
*******************************************************************************/
unsigned char Limit_Mix (int intermediate_value)
{
  static int limited_value;
  
  if (intermediate_value < 2000)
  {
    limited_value = 2000;
  }
  else if (intermediate_value > 2254)
  {
    limited_value = 2254;
  }
  else
  {
    limited_value = intermediate_value;
  }
  return (unsigned char) (limited_value - 2000);
}


/*******************************************************************************
* FUNCTION NAME: User_Initialization
* PURPOSE:       This routine is called first (and only once) in the Main function.  
*                You may modify and add to this function.
* CALLED FROM:   main.c
* ARGUMENTS:     none
* RETURNS:       void
*******************************************************************************/
void User_Initialization (void)
{
  Set_Number_of_Analog_Channels(SIXTEEN_ANALOG);    /* DO NOT CHANGE! */

/* FIRST: Set up the I/O pins you want to use as digital INPUTS. */
  digital_io_01 = digital_io_02 = digital_io_03 = digital_io_04 = INPUT;

  relay1_fwd = relay1_rev = relay2_fwd = relay2_rev = 0;


/* FOURTH: Set your initial PWM values.  Neutral is 127. */
  pwm01 = pwm02 = pwm03 = pwm04 = pwm05 = pwm06 = pwm07 = pwm08 = 127;
  pwm09 = pwm10 = pwm11 = pwm12 = pwm13 = pwm14 = pwm15 = pwm16 = 127;

/* FIFTH: Set your PWM output types for PWM OUTPUTS 13-16.
  /*   Choose from these parameters for PWM 13-16 respectively:               */
  /*     IFI_PWM  - Standard IFI PWM output generated with Generate_Pwms(...) */
  /*     USER_CCP - User can use PWM pin as digital I/O or CCP pin.           */
//  Setup_PWM_Output_Type(IFI_PWM,IFI_PWM,IFI_PWM,IFI_PWM);

  // changed so PWM() can control PWM outputs 13 through 16
  Setup_PWM_Output_Type(USER_CCP,USER_CCP,USER_CCP,USER_CCP);

  /*
     Example: The following would generate a 40KHz PWM with a 50% duty cycle on the CCP2 pin:

         CCP2CON = 0x3C;
         PR2 = 0xF9;
         CCPR2L = 0x7F;
         T2CON = 0;
         T2CONbits.TMR2ON = 1;

         Setup_PWM_Output_Type(USER_CCP,IFI_PWM,IFI_PWM,IFI_PWM);
  */

  /* Add any other initialization code here. */

  // initialize the CCP PWM hardware
  Initialize_PWM();
 
  // initialize the serial ports
  Init_Serial_Port_One();
  Init_Serial_Port_Two();

  // make sure printf() output goes to the proper port
  #ifdef TERMINAL_SERIAL_PORT_1  
  stdout_serial_port = SERIAL_PORT_ONE;
  #endif

  #ifdef TERMINAL_SERIAL_PORT_2  
  stdout_serial_port = SERIAL_PORT_TWO;
  #endif

  Putdata(&txdata);            /* DO NOT CHANGE! */

  User_Proc_Is_Ready();         /* DO NOT CHANGE! - last line of User_Initialization */
}

/*******************************************************************************
* FUNCTION NAME: Process_Data_From_Master_uP
* PURPOSE:       Executes every 26.2ms when it gets new data from the master 
*                microprocessor.
* CALLED FROM:   main.c
* ARGUMENTS:     none
* RETURNS:       void
*******************************************************************************/
void Process_Data_From_Master_uP(void)
{
  static unsigned char i;

  Getdata(&rxdata);   /* Get fresh data from the master microprocessor. */

  Default_Routine();  /* Optional.  See below. */

  /* Add your own code here. (a printf will not be displayed when connected to the breaker panel unless a Y cable is used) */

  printf("Port1 Y %3d, X %3d, Fire %d, Top %d\r",pwm01,pwm05,p1_sw_trig,p1_sw_top);  /* printf EXAMPLE */

  /* Example code to check if a breaker was ever tripped. */

  Putdata(&txdata);             /* DO NOT CHANGE! */
}

/*******************************************************************************
* FUNCTION NAME: Default_Routine
* PURPOSE:       Performs the default mappings of inputs to outputs for the
*                Robot Controller.
* CALLED FROM:   this file, Process_Data_From_Master_uP routine
* ARGUMENTS:     none
* RETURNS:       void
*******************************************************************************/

 void Default_Routine(void)
{

   signed double wL, wR, velocity, rotation, wMax;
 signed int difference, difference2, difference3, difference4;
 signed int prepwm01, prepwm02;
 static char pwm01_1, pwm02_1;

 /*velocity = (p1_y - 127);
 rotation = (p1_x - 127); */

if (rc_dig_in01 == 1) { //If tank pressure is 120... (Jeff didn't know whether the switch gave a 1 or 0 at 120psi)
relay2_fwd = 0;
relay2_rev = 0;
}
else {
relay2_fwd =1;
relay2_rev = 0;
}

/*
 velocity = deadband(p1_y,127,15);
 rotation = deadband(p1_x,127,15);
 */

 velocity = ctbl[joysticklimit(p1_y)];
 rotation = ctbl[joysticklimit(p1_x)];
 
 wL = velocity - rotation;
 wR = velocity + rotation;


   wMax = intMax(127, intABS(wL));
   wMax = intMax(wMax, intABS(wR));


/*Below check if the wheel output thingamajigger is valid or not (less than 127, great than -127).

If it isn't, it will go on and check the next wheel output, and if it's all good, it'll write it to prepwms

*/


 wL = (wL * 127 / wMax);
 if (-127 > wL || wL > 127)
   printf("Received an unexpected number [wL] /n");
else
 {
  wR = (wR * 127 / wMax);
  if (-127 > wR || wR > 127)
    printf("Received an unexpected number [wR] /n");
 
  else
   {

 prepwm01 = wL + 127;
 prepwm02 = 127 - wR;


  // looking at the wheels counter clockwise is postive
  // 7 is too little,
 
 if ((prepwm01 > 127) && (prepwm01 < 180)) {
  prepwm01 = prepwm01 + 12;
 }

 if ((prepwm02 > 127) && (prepwm02 < 180)) {
  prepwm02 = prepwm02 + 12;
 }


 pwm01 = prepwm01;
 pwm02 = prepwm02;

 /*if (((intABS((char)pwm01 - pwm01_1)) > 0 ) || ((intABS((char)pwm02 - pwm02_1)) > 0 ) || ((intABS((char)pwm03 - pwm03_1)) > 0 ) || ((intABS((char)pwm04 - pwm04_1)) > 0 )) {
  printf(" pwm01: %d , pwm02: %d \r", pwm01, pwm02);
  printf(" Port 1 Y: %d , Port 1 X: %d , Port 2 X: %d \r", p1_y, p1_x, p2_x);
 }

 pwm01_1 = intABS(pwm01 - 127);
 pwm02_1 = intABS(pwm02 - 127);


 /*---------- Buttons to Relays----------------------------------------------
  *--------------------------------------------------------------------------
  *  This default code maps the joystick buttons to specific relay outputs.
  */

relay1_fwd = p1_sw_trig;
relay1_rev = p1_sw_top; //Will kick if trigger is pulled, retract if top button is pushed. No button = no kicker action.
 
  
 /*---------- ROBOT FEEDBACK LEDs------------------------------------------------
  *------------------------------------------------------------------------------
  *   This section drives the "ROBOT FEEDBACK" lights on the Operator Interface.
  *   The lights are green for joystick forward and red for joystick reverse.
  *   Both red and green are on when the joystick is centered.  Use the
  *   trim tabs on the joystick to adjust the center.     
  *   These may be changed for any use that the user desires.                       
  */	
  
  if (user_display_mode == 0) /* User Mode is Off */
    
  { /* Check position of Port 1 Joystick */
    if (p1_y >= 0 && p1_y <= 56)
    {                     /* Joystick is in full reverse position */
      Pwm1_green  = 0;    /* Turn PWM1 green LED - OFF */
      Pwm1_red  = 1;      /* Turn PWM1 red LED   - ON  */
    }
    else if (p1_y >= 125 && p1_y <= 129)
    {                     /* Joystick is in neutral position */
      Pwm1_green  = 1;    /* Turn PWM1 green LED - ON */
      Pwm1_red  = 1;      /* Turn PWM1 red LED   - ON */
    }
    else if (p1_y >= 216 && p1_y <= 255)
    {                     /* Joystick is in full forward position*/
      Pwm1_green  = 1;    /* Turn PWM1 green LED - ON  */
      Pwm1_red  = 0;      /* Turn PWM1 red LED   - OFF */
    }
    else
    {                     /* In either forward or reverse position */
      Pwm1_green  = 0;    /* Turn PWM1 green LED - OFF */
      Pwm1_red  = 0;      /* Turn PWM1 red LED   - OFF */
    }  /*END Check position of Port 1 Joystick
    
    /* Check position of Port 2 Y Joystick 
           (or Port 1 X in Single Joystick Drive Mode) */
    if (p2_y >= 0 && p2_y <= 56)
    {                     /* Joystick is in full reverse position */
      Pwm2_green  = 0;    /* Turn pwm2 green LED - OFF */
      Pwm2_red  = 1;      /* Turn pwm2 red LED   - ON  */
    }
    else if (p2_y >= 125 && p2_y <= 129)
    {                     /* Joystick is in neutral position */
      Pwm2_green  = 1;    /* Turn PWM2 green LED - ON */
      Pwm2_red  = 1;      /* Turn PWM2 red LED   - ON */
    }
    else if (p2_y >= 216 && p2_y <= 255)
    {                     /* Joystick is in full forward position */
      Pwm2_green  = 1;    /* Turn PWM2 green LED - ON  */
      Pwm2_red  = 0;      /* Turn PWM2 red LED   - OFF */
    }
    else
    {                     /* In either forward or reverse position */
      Pwm2_green  = 0;    /* Turn PWM2 green LED - OFF */
      Pwm2_red  = 0;      /* Turn PWM2 red LED   - OFF */
    }  /* END Check position of Port 2 Joystick */
    
    /* This drives the Relay 1 and Relay 2 "Robot Feedback" lights on the OI. */
    Relay1_green = relay1_fwd;    /* LED is ON when Relay 1 is FWD */
    Relay1_red = relay1_rev;      /* LED is ON when Relay 1 is REV */
    Relay2_green = relay2_fwd;    /* LED is ON when Relay 2 is FWD */
    Relay2_red = relay2_rev;      /* LED is ON when Relay 2 is REV */

    Switch1_LED = !(int)rc_dig_in01;
    Switch2_LED = !(int)rc_dig_in02;
    Switch3_LED = !(int)rc_dig_in03;
    
  } /* (user_display_mode = 0) (User Mode is Off) */
  
  else  /* User Mode is On - displays data in OI 4-digit display*/
  {
    User_Mode_byte = backup_voltage*10; /* so that decimal doesn't get truncated. */
  }   
  }
}
}
  #2   Spotlight this post!  
Unread 26-09-2007, 20:38
Kelly Kelly is offline
Registered User
FRC #1418
 
Join Date: Jan 2007
Location: VA
Posts: 78
Kelly has much to be proud ofKelly has much to be proud ofKelly has much to be proud ofKelly has much to be proud ofKelly has much to be proud ofKelly has much to be proud ofKelly has much to be proud ofKelly has much to be proud ofKelly has much to be proud of
Re: Error in code light on, trouble finding error

Try loading the default code and then loading your code. A lot of times weird problems like this aren't problems in the code but weird transmission errors or something.
  #3   Spotlight this post!  
Unread 26-09-2007, 21:18
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Error in code light on, trouble finding error

Quote:
Originally Posted by Tanis View Post
...the OI has the code error,...
The file looks okay at first glance -- no obvious infinite loops or wild pointers.

The first thing I'd check is that you're compiling the project for the proper version of the RC. The 2004 and 2005 systems use a different user PIC than the 2006 and 2007 systems do. What year's RC are you using, and what year's default code did you start with? The newer default code includes a file with instructions for making changes so it can be used with the older hardware.
  #4   Spotlight this post!  
Unread 26-09-2007, 22:33
EHaskins EHaskins is offline
Needs to change his user title.
AKA: Eric Haskins
no team (CARD #6 (SCOE))
Team Role: College Student
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Elkhorn, WI USA
Posts: 998
EHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond repute
Send a message via MSN to EHaskins
Re: Error in code light on, trouble finding error

Make sure your radios are connected properly, and download the default code.
__________________
Eric Haskins KC9JVH
  #5   Spotlight this post!  
Unread 26-09-2007, 22:43
Jim E Jim E is offline
Registered User
FRC #1523 (M.A.R.S.)
Team Role: Mentor
 
Join Date: Jun 2006
Rookie Year: 2005
Location: Lantana, FL
Posts: 188
Jim E has a reputation beyond reputeJim E has a reputation beyond reputeJim E has a reputation beyond reputeJim E has a reputation beyond reputeJim E has a reputation beyond reputeJim E has a reputation beyond reputeJim E has a reputation beyond reputeJim E has a reputation beyond reputeJim E has a reputation beyond reputeJim E has a reputation beyond reputeJim E has a reputation beyond repute
Re: Error in code light on, trouble finding error

I can sympathize with you on MPLAB, it can be a pain to find the run-time errors.

Please remember that most causes of the red light of death are caused by not refreshing within the time limits of the processor, or every 26.3 ms.

That ROM array you are initializing at the start looks pretty big. Do you really need that level of precision? Each character will probably eat up 2 bytes of RAM.
Including the camera code and other functions is probably pushing you to the limits of the processors RAM during run time.

My 2cents.
__________________
Team MARS = 1.523 AU from the SUN!

Jim E.
  #6   Spotlight this post!  
Unread 27-09-2007, 10:00
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Error in code light on, trouble finding error

Quote:
Originally Posted by Jim E View Post
That ROM array you are initializing at the start looks pretty big. Do you really need that level of precision? Each character will probably eat up 2 bytes of RAM.
First of all, characters are, by definition, a single byte. On the other hand, the array is defined as int, so each value indeed takes two bytes. On the gripping hand, putting the array in ROM means it takes no RAM anyway.


Tanis, you're only putting values between -127 and 127 in the array. That will fit in a signed char if you do want to cut the array's size in half.

Quote:
Including the camera code and other functions is probably pushing you to the limits of the processors RAM during run time.
There's essentially no dynamic allocation of memory in the program, so RAM usage issues will make themselves known at compile time.

But I didn't notice the reference to camera and tracking code before. The serial port support that goes along with them requires specific changes to the interrupt service routine. Failing to handle interrupts properly is another way to cause the code error light to come on.

Tanis, are you actually using the camera? If so, make sure you've done the appropriate things to user_routines_fast.c as called out in the camera code documentation, and don't forget to call the camera tracking function in the main loop, probably from Default_Routine(). If not, don't #include the unnecessary files.
  #7   Spotlight this post!  
Unread 28-09-2007, 15:18
Bryan Herbst's Avatar
Bryan Herbst Bryan Herbst is offline
Registered User
AKA: Bryan
FRC #2052 (KnightKrawler)
Team Role: Mentor
 
Join Date: Sep 2007
Rookie Year: 2007
Location: Minneapolis, Minnesota
Posts: 545
Bryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond repute
Re: Error in code light on, trouble finding error

Using the C18 compiler, 2007 RC, and an edited version of the default master code currently available off the IFI site.

I decided to get rid of the table, it was just a test (one of our mentors suggested it), and wouldn't have made much of a difference.

We've tried reloading the code multiple times (also have used the default code a few times), and our code doesn't work. The default code works fine.

We are not using the camera, so I got rid of that too.
__________________
Team 2052- Knightkrawler
Mentor and volunteer
  #8   Spotlight this post!  
Unread 28-09-2007, 17:44
Bomberofdoom's Avatar
Bomberofdoom Bomberofdoom is offline
Biggest FIRST addict in Israel
AKA: Nir Levanon
FRC #2230 (Zcharia's Angels)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Israel
Posts: 471
Bomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond repute
Send a message via MSN to Bomberofdoom
Re: Error in code light on, trouble finding error

Does the code compile?
I mean, were you able to transfer it through IFI_Loader (although the code didn't work on the robot)?
__________________
TEAM 2230 ZECHARIA'S ANGELS

2009 Microsoft Israel FRC Regional Winners!
2009 Microsoft Israel FRC Regional Chairman's Award Winners!!!
---------------------------------
2008 Microsoft Israel FRC Regional semi-finalist.
2008 Microsoft Israel FRC Regional Delphi's "Driving Tommorow's Technology" Award winner.
2008 Robot Driver
---------------------------------
2007 GM/Technion Israel FRC Regional semi-Finalist.
2007 GM/Technion Israel FRC Regional Xerox Creativity Award winner.
2007 Robot Driver.
  #9   Spotlight this post!  
Unread 28-09-2007, 18:08
EHaskins EHaskins is offline
Needs to change his user title.
AKA: Eric Haskins
no team (CARD #6 (SCOE))
Team Role: College Student
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Elkhorn, WI USA
Posts: 998
EHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond repute
Send a message via MSN to EHaskins
Re: Error in code light on, trouble finding error

What is the name of the file you are trying to download to the RC?
__________________
Eric Haskins KC9JVH
  #10   Spotlight this post!  
Unread 30-09-2007, 10:50
Bryan Herbst's Avatar
Bryan Herbst Bryan Herbst is offline
Registered User
AKA: Bryan
FRC #2052 (KnightKrawler)
Team Role: Mentor
 
Join Date: Sep 2007
Rookie Year: 2007
Location: Minneapolis, Minnesota
Posts: 545
Bryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond repute
Re: Error in code light on, trouble finding error

Yes, it compiles, and downloads to the RC.

The file is KickerCode.hex.
__________________
Team 2052- Knightkrawler
Mentor and volunteer
  #11   Spotlight this post!  
Unread 05-10-2007, 16:47
Bryan Herbst's Avatar
Bryan Herbst Bryan Herbst is offline
Registered User
AKA: Bryan
FRC #2052 (KnightKrawler)
Team Role: Mentor
 
Join Date: Sep 2007
Rookie Year: 2007
Location: Minneapolis, Minnesota
Posts: 545
Bryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond repute
Re: Error in code light on, trouble finding error

We've been working on it a bit more, the code we've been working on still doesn't work, and were currently trying to start from scratch. We got to about where we were before and it still wont work... suggestions?
__________________
Team 2052- Knightkrawler
Mentor and volunteer
  #12   Spotlight this post!  
Unread 05-10-2007, 18:40
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Error in code light on, trouble finding error

I can't offer any more suggestions without seeing your code. When you say "start from scratch", what exactly is the "scratch"? Specifically, are you taking the 2007 non-camera default code as a base, or are you beginning with something else? What files are you modifying?
  #13   Spotlight this post!  
Unread 05-10-2007, 19:44
Bryan Herbst's Avatar
Bryan Herbst Bryan Herbst is offline
Registered User
AKA: Bryan
FRC #2052 (KnightKrawler)
Team Role: Mentor
 
Join Date: Sep 2007
Rookie Year: 2007
Location: Minneapolis, Minnesota
Posts: 545
Bryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond repute
Re: Error in code light on, trouble finding error

Plain, non camera code.

Editing User routines, and possibly ifi_aliases.h, depending on if we get our control box built.


Going to add in all the header files in the original code, except tracking.h, tracking_menu.h, camera_menu.h, and camera.h.
__________________
Team 2052- Knightkrawler
Mentor and volunteer
  #14   Spotlight this post!  
Unread 08-10-2007, 11:15
dcbrown dcbrown is offline
Registered User
AKA: Bud
no team
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Hollis,NH
Posts: 236
dcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud of
Re: Error in code light on, trouble finding error

A nit. Some RAM issues are detected/caught at compile time. But resource exhaustion issues are caught at link time.

There are several "standard" methods of helping debug embedded code. The simplest is to use a macro wrapper and use it with each function call. The macro can be used to either output a message via printf or to set a value into an output port that can be measured or displayed via leds.

When done debugging, just redefine the macro to nothing and allow the code to execute without any debug code overhead. For example, something like:


Code:
int myroutine( int a, int b, int c, int d );
#define DEBUG

#ifdef DEBUG
#define _Call( _arg )  (printf( "CALL: %lX[%d]\n", _arg, __LINE__ )==0)?printf("ERROR!\n"):_arg
#define _Trace( _arg ) printf( "TRAK: %s[%d]\n", _arg, __LINE__ )
#define _Return( _return_value ) { printf( "RETN: [%d] %d\n", __LINE__, _return_value ); return( _return_value ); }
#else
#define _Call( _arg ) _arg
#define _Trace( _arg )
#define _Return( _arg ) return( _arg )
#endif

int main()
{
int status;

    status = _Call( myroutine )(1,2,3,4);
    printf( "status = %d\n", status );
    status = _Call( myroutine )(4,3,3,4);
    printf( "status = %d\n", status );
}
int myroutine( int a, int b, int c, int d)
{
    _Trace( "myroutine" );
    /* routine stuff here... */
    _Return(a+b+c+d);
}
The result is something like:
Code:
CALL: 1200012A0[20]
TRAK: myroutine[27]
RETN: [29] 10
status = 10
CALL: 1200012A0[22]
TRAK: myroutine[27]
RETN: [29] 14
status = 14
You can change the printf call to be any user defined routine you need call to help in debugging the program. You'll need the .map output file to determine which function the routine address matches if just using the call macro. You can get fancier too, if desired.

For interrupt routines, don't use printfs! Instead just toggle a pin to show when you enter/leave the interrupt service routine. Use a scope to track.
  #15   Spotlight this post!  
Unread 09-10-2007, 06:01
FoleyEngineer's Avatar
FoleyEngineer FoleyEngineer is offline
Registered User
AKA: John Crombe
FRC #0910 (Foley Freeze)
Team Role: Coach
 
Join Date: Jul 2006
Rookie Year: 2005
Location: Madison Heights, MI
Posts: 108
FoleyEngineer has a reputation beyond reputeFoleyEngineer has a reputation beyond reputeFoleyEngineer has a reputation beyond reputeFoleyEngineer has a reputation beyond reputeFoleyEngineer has a reputation beyond reputeFoleyEngineer has a reputation beyond reputeFoleyEngineer has a reputation beyond reputeFoleyEngineer has a reputation beyond reputeFoleyEngineer has a reputation beyond reputeFoleyEngineer has a reputation beyond reputeFoleyEngineer has a reputation beyond repute
Re: Error in code light on, trouble finding error

If the default code compiles, downloads and runs fine, then you can solve this by trial and error in pretty short order.

Just add in your "new" code one section at a time, compiling and downloading after each new "section". As soon as it quits working you've found a problem. Split that section in half and repeat. Before long you should have it figured out. The whole process really shouldn't take very long.

Good luck!

P.S. I remember not initializing one of the serial ports (as I wasn't using it) and that caused me untold problems (including the red light). I did what I suggest above and tracked it down right to the line at fault. Dividing by 2 makes pretty quick work of a problem when used recursively.
__________________

2014 Buckeye Champions - thanks 846 & 639, Troy Champions - thanks 33 & 5193, Imagery, Entrepreneurship & Industrial Design Awards
2013 Kettering Champions - thanks 70 & 862, Three Imagery Awards
2012 Western Mich Finalist - thanks 1918 & 85
2011 Trav. City Web Site, Troy Xerox, Mich State Semi Finalist & Judges Awards
2010 Kettering Champion - thanks 67 & 70, Kettering Rockwell Innovation 2010 Troy Finalists - thanks 33 & 288, and Rockwell Innovation
2009 Kettering QF, Detroit Finalists Detroit Creativity Award, Troy Semi-Finalists Troy Creativity Award
2008 WMRI Finalists - thanks 1243 and 904, 2008 Kettering Champion - thanks 67, 1075 and 2619
2008 IRI Judges Award Winner, Great Lakes Finalists - thanks 66 & 217, Western Mich
2007 Curie Division Champions - thanks 330 & 1270

Last edited by FoleyEngineer : 09-10-2007 at 06:05.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Coder Error Light paulcd2000 Programming 7 10-02-2007 15:52
180:Error: syntax error help! seanl Programming 8 04-02-2007 11:31
GTS Code Error (the red light of doom!) Denz Programming 9 07-04-2006 17:39
stupid Array error: Error [1300] stack frame too l Validius Programming 7 27-01-2006 10:53
C++ Code Error? Adam Shapiro Programming 9 20-01-2003 13:24


All times are GMT -5. The time now is 13:27.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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