ROBOTC.net forums
http://www.robotc.net/forums/

RobotC crashing on compilation
http://www.robotc.net/forums/viewtopic.php?f=1&t=4199
Page 1 of 1

Author:  enauman [ Fri Feb 03, 2012 11:16 pm ]
Post subject:  RobotC crashing on compilation

Does anyone notice anything in this program that would cause RobotC 2.01 to crash when it compiles? The laptop it crashes on is Win XP SP2 or SP3. The program compiles fine on my Win 7 laptop. It's for a joystick controlled robotic arm. I tried replacing the JoystickDriver.c file thinking maybe it was corrupt. My students are competing tomorrow and a bit desperate.
Thanks,
Erik
Code:
#pragma config(Hubs,  S1, HTMotor,  HTServo,  none,     none)
#pragma config(Motor,  mtr_S1_C1_1, motorD, tmotorNormal, openLoop)
#pragma config(Servo,  srvo_S1_C2_1, servo1, tServoNormal)
#pragma config(Servo,  srvo_S1_C2_2, servo2, tServoNormal)
#pragma config(Servo,  srvo_S1_C2_3, servo3, tServoNormal)

#include "JoystickDriver.c"
void swivelArm();
void joint1up();
void joint1down();
void joint2up();
void joint2down();
void joint3open();
void joint3close();
int servo1Pos = ServoValue(servo1);
int servo2Pos = ServoValue(servo2);
int servo3Pos = ServoValue(servo3);

task main()
{
  while(true)
  {
    getJoystickSettings(joystick);

    swivelArm();

    if(joy1Btn(5))
    {
   joint1up();
   wait1Msec(10);
   }
    if(joy1Btn(6))
    {
   joint1down();
   wait1Msec(10);
    }
  if(joy1Btn(7))
    {
   joint2up();
   wait1Msec(10);
   }
    if(joy1Btn(8))
    {
   joint2down();
   wait1Msec(10);
    }
  if(joy1Btn(9))
    {
   joint3open();
   wait1Msec(10);
   }
    if(joy1Btn(10))
    {
   joint3close();
   wait1Msec(10);
    }
  }
}

void swivelArm()
{
  motor[motorD] = joystick.joy1_x1/20;
  }

void joint1up()
{
   if(servo1Pos < 100)
   {
      servo[servo1] = servo1Pos++; 
   }
}

void joint1down()
{
    if(servo1Pos > 0)
    {
       servo[servo1] = servo1Pos--; 
    }
}
void joint2up()
{
   if(servo2Pos > 1)
   {
      servo[servo2] = servo2Pos--; 
   }
}

void joint2down()
{
    if(servo2Pos < 187)
    {
       servo[servo2] = servo2Pos++; 
    }
}

void joint3open()
{
   if(servo3Pos > 1)
   {
      servo[servo3] = servo3Pos--; 
   }
}

void joint3close()
{
    if(servo3Pos < 100)
    {
       servo[servo3] = servo3Pos++; 
  }
}


Author:  sumasmreq [ Sat Feb 04, 2012 12:00 am ]
Post subject:  Re: RobotC crashing on compilation

Try downloading a demo of ROBOTC 3.05; it should last you at least 30 days, and can run side by side with ROBOTC 2.0 I believe. Just don't forget to change the mastercode on your joysticks and cortex.

Author:  mightor [ Sat Feb 04, 2012 2:12 am ]
Post subject:  Re: RobotC crashing on compilation

If you're not keen on buying ROBOTC 3.x (you'll need a license after 30 days), I would recommend switching to 2.26. You can download it here: http://www.robotc.net/files/ROBOTCforMi ... 1_BETA.exe

Don't let the BETA part scare you.

- Xander

Author:  enauman [ Mon Mar 05, 2012 12:25 am ]
Post subject:  Re: RobotC crashing on compilation

I had the students try v2.26 and it still crashes on compilation of the above code. I noticed something. The JoystickDriver.c file appears to have a typo on line 20. Should #elif be #elseif? Just after this section on line 24 is
#pragma systemFile // this eliminates warning for "unreferenced" functions
Maybe that is preventing the program from throwing an error when it should be? Of course I will have them edit that when I see them next and see if that helps.
Thanks, Erik
Code:
#if defined(NXT) || defined(TETRIX)
   #pragma autoStartTasks        // Automatically start this task when the main user program starts.
#elif defined(VEX)
   #pragma platform(VEX, FRC)
#endif

Author:  enauman [ Tue Mar 06, 2012 7:14 am ]
Post subject:  Re: RobotC crashing on compilation

Well editing that line to #elseif made things worse, #elseif was caught as an undefined exception. My own laptop, Win 7, was starting to crash on the program compiling but what fixed that was uninstalling 2.26 and reinstalling 2.02, compiling the joystick sample program, then compiling the robot arm program made by the students. I still don't know what caused the problem...

Author:  MHTS [ Tue Mar 06, 2012 3:56 pm ]
Post subject:  Re: RobotC crashing on compilation

"#elif" is a legitimate pre-processor keyword. There is no typo.

Author:  enauman [ Tue Mar 06, 2012 4:04 pm ]
Post subject:  Re: RobotC crashing on compilation

Thanks I can see that now. What seems to be helping is when the crashing starts happening on a students computer we compile the joystick sample program and then it's usually able to compile their own program after that, in both v2.02 and 2.26.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/