View unanswered posts | View active topics It is currently Mon Sep 22, 2014 12:45 am






Reply to topic  [ 6 posts ] 
Program Glitches 
Author Message
Rookie

Joined: Mon Jan 20, 2014 4:34 pm
Posts: 5
Post Program Glitches
My team has a state competition this weekend and we are having some major issues with our program. We run the autonomous and sometimes it works, but sometimes it glitches and either skips over a portion of the program or it stops halfway through and starts the program over, making it difficult to test our program. These issues happen in the same exact spots every time they happen. Any help would be greatly appreciated.


Mon Jan 20, 2014 4:50 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 578
Post Re: Program Glitches
Please post the code (including the lines where it crashes or restarts from) using the [code] tags and we will be more than happy to help debug the issue for you. Also, the more detailed information you are able to provide on the issue, the better we will be able to assist you!

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody


Mon Jan 20, 2014 4:58 pm
Profile
Rookie

Joined: Mon Jan 20, 2014 4:34 pm
Posts: 5
Post Re: Program Glitches
Code:
#pragma config(I2C_Usage, I2C1, i2cSensors)
#pragma config(Sensor, in1,    potR,           sensorPotentiometer)
#pragma config(Sensor, in2,    autopot,        sensorPotentiometer)
#pragma config(Sensor, in3,    acc1,           sensorAccelerometer)
#pragma config(Sensor, in4,    acc2,           sensorAccelerometer)
#pragma config(Sensor, in7,    gyro,           sensorGyro)
#pragma config(Sensor, in8,    potL,           sensorPotentiometer)
#pragma config(Sensor, dgtl7,  Rsonar,         sensorSONAR_inch)
#pragma config(Sensor, dgtl11, Lsonar,         sensorSONAR_inch)
#pragma config(Sensor, I2C_1,  enc,            sensorQuadEncoderOnI2CPort,    , AutoAssign)
#pragma config(Sensor, I2C_2,  enc2,           sensorQuadEncoderOnI2CPort,    , AutoAssign)
#pragma config(Motor,  port1,           Flip,          tmotorVex393_HBridge, openLoop)
#pragma config(Motor,  port2,           RF,            tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor,  port3,           RR,            tmotorVex393_MC29, openLoop, reversed, encoderPort, I2C_1)
#pragma config(Motor,  port4,           Lift,          tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port5,           Swerve,        tmotorVex393HighSpeed_MC29, openLoop, reversed)
#pragma config(Motor,  port6,           Scorer,        tmotorVex393HighSpeed_MC29, openLoop, reversed)
#pragma config(Motor,  port7,           Lift2,         tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor,  port8,           LR,            tmotorVex393_MC29, openLoop, encoderPort, I2C_2)
#pragma config(Motor,  port9,           LF,            tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port10,          Flip2,         tmotorVex393_HBridge, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#pragma platform(VEX)

//Competition Control and Duration Settings
#pragma competitionControl(Competition)
#pragma autonomousDuration(20)
#pragma userControlDuration(120)

#include "Vex_Competition_Includes.c"   //Main competition background code...do not modify!
/////////////////////////////////////////////////////////////////////////////////////////
//variables here
float joy_x = 0;
float joy_y = 0;
int gyrohold = 0;
/////////////////////////////////////////////////////////////////////////////////////////
//Functions here
void updatejoy()
{
   joy_x = vexRT[Ch1];
   joy_y = vexRT[Ch2];
}

void forwardtimeout(int distanceforward, int timeout)
{
   nMotorEncoder[RR] = 0;
   clearTimer(T1);
   while(nMotorEncoder[RR] < distanceforward && time1[T1] < timeout)
   {
      motor[RF] = 127;
      motor[RR] = 127;
      motor[LF] = 127;
      motor[LR] = 127;
   }
   motor[RF] = 0;
   motor[RR] = 0;
   motor[LF] = 0;
   motor[LR] = 0;
}
void backwardtimeout(int distancebackward, int timeoutb)
{
   nMotorEncoder[RR] = 0;
   clearTimer(T1);
   while(nMotorEncoder[RR] > -distancebackward && time1[T1] < timeoutb)
   {
      motor[RF] = -80;
      motor[RR] = -80;
      motor[LF] = -80;
      motor[LR] = -80;
   }
   motor[RF] = 0;
   motor[RR] = 0;
   motor[LF] = 0;
   motor[LR] = 0;
}
void basestop()
{
   motor[RF] = 0;
   motor[RR] = 0;
   motor[LF] = 0;
   motor[LR] = 0;
}
void gyroright(int degreesright)
{
   SensorValue[gyro] = 0;
   while(SensorValue[gyro] < degreesright)
   {
      motor[RF] = -50;
      motor[RR] = -50;
      motor[LF] = 50;
      motor[LR] = 50;
   }
   motor[RF] = 0;
   motor[RR] = 0;
   motor[LF] = 0;
   motor[LR] = 0;
}
void gyroleft(int degreesleft)
{
   SensorValue[gyro] = 0;
   while(SensorValue[gyro] > -degreesleft)
   {
      motor[RF] = 50;
      motor[RR] = 50;
      motor[LF] = -50;
      motor[LR] = -50;
   }
   motor[RF] = 0;
   motor[RR] = 0;
   motor[LF] = 0;
   motor[LR] = 0;
}

void liftup(int LUwait)
{
   motor[Lift] = 127;
   motor[Lift2] = 127;
   wait1Msec(LUwait);
   motor[Lift] = 0;
   motor[Lift2] = 0;
}
void liftdown(int LDwait)
{
   motor[Lift] = -127;
   motor[Lift2] = -127;
   wait1Msec(LDwait);
   motor[Lift] = 0;
   motor[Lift2] = 0;
}

void flipup(int FUwait)
{
   motor[Flip] = 127;
   motor[Flip2] = 127;
   wait1Msec(FUwait);
   motor[Flip] = 0;
   motor[Flip2] = 0;
}
void flipdown(int FDwait)
{
   motor[Flip] = -127;
   motor[Flip2] = -127;
   wait1Msec(FDwait);
   motor[Flip] = 0;
   motor[Flip2] = 0;
}
void flipbeachball()
{
   motor[Flip] = 100;
   motor[Flip2] = 100;
   wait1Msec(1000);
   motor[Flip] = 0;
   motor[Flip2] = 0;
}

void score()
{
   motor[Scorer] = 127;
   wait1Msec(800);
   motor[Scorer] = -127;
   wait1Msec(450);
   motor[Scorer] = 0;
}

/////////////////////////////////////////////////////////////////////////////////////////
void pre_auton()
{
   bStopTasksBetweenModes = true;
   nMotorEncoder(RR) = 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
task autonomous()
{
   nMotorEncoder[RR] = 0;
   nMotorEncoder[LR] = 0;
   SensorValue[gyro] = 0;
   clearTimer(T1);

   flipdown(1000);

   nMotorEncoder[RR] = 0;
   nMotorEncoder[LR] = 0;
   while(nMotorEncoder[RR] < 270 || nMotorEncoder[LR] < 270)//forward to pick up buckies on wall
   {
      motor[RF] = 50;
      motor[RR] = 50;
      motor[LF] = 50;
      motor[LR] = 50;
   }
   motor[RF] = 0;
   motor[RR] = 0;
   motor[LF] = 0;
   motor[LR] = 0;

   flipup(1500);//pick up buckies on wall
   backwardtimeout(300, 440);//into bump
   liftup(400);
   backwardtimeout(850, 970);//backward over bump

   wait1Msec(700);//reposition
   liftdown(300);
   flipdown(300);

   backwardtimeout(1400, 2000);//under barrier

   motor[Lift] = 127;
   motor[Lift2] = 127;
   backwardtimeout(450, 650);//back into goal
   wait1Msec(1380);//lift height
   motor[Lift] = 0;
   motor[Lift2] = 0;

   motor[Scorer] = 55;//score 3 buckies in goal
   wait1Msec(900);
   motor[Scorer] = -127;
   wait1Msec(450);
   motor[Scorer] = 0;

   liftdown(1250);//set to go under barrier

   forwardtimeout(1200,1700);//under barrier
   flipup(700);
   forwardtimeout(400, 570);
   liftup(400);
   wait1Msec(400);

   forwardtimeout(750, 900);//forward over bump
   liftdown(300);

   wait1Msec(1200);//reposition

   flipdown(1000);//start old program

   forwardtimeout(270, 500);//pick up ball 1
   wait1Msec(150);

   flipbeachball();
   wait1Msec(150);
   flipdown(500);

   forwardtimeout(470, 550);// pick up ball 2
   wait1Msec(100);

   motor[Flip] = 90;
   motor[Flip2] = 90;
   wait1Msec(450);
   motor[Flip] = 25;
   motor[Flip2] = 25;

   backwardtimeout(150, 400);//back up in line with buckies
   gyroright(770);//rotate facing front wall
   liftup(600);

   nMotorEncoder[RR] = 0;
   nMotorEncoder[LR] = 0;
   while(nMotorEncoder[RR] > -300 || nMotorEncoder[LR] > -300)//back up into ball 3
   {
      motor[RF] = -127;
      motor[RR] = -127;
      motor[LF] = -127;
      motor[LR] = -127;
   }
   basestop();
   wait1Msec(300);
   nMotorEncoder[RR] = 0;
   nMotorEncoder[LR] = 0;
   while(nMotorEncoder[RR] > -1200 || nMotorEncoder[LR] > -1200)//back up into ball 3
   {
      motor[RF] = -127;
      motor[RR] = -127;
      motor[LF] = -127;
      motor[LR] = -127;
   }
   basestop();

   liftdown(400);
   score();
   flipup(350);
   score();

   gyroright(850);
   forwardtimeout(650, 800);//forward to ball 4
   gyroright(750);//insurance
   forwardtimeout(200, 300);

   backwardtimeout(600, 720);//backward to bump
   liftup(400);
   wait1Msec(500);

   nMotorEncoder[RR] = 0;
   nMotorEncoder[LR] = 0;

   backwardtimeout(750,900);//backward over bump

   liftdown(300);
   wait1Msec(1000);//reposition
   flipdown(700);

   forwardtimeout(1650, 2000);//forward to blue side

   flipbeachball();//pick up blue ball 1
   wait1Msec(150);
   flipdown(600);
   forwardtimeout(870, 1000);//pick up blue ball 2

   motor[Flip] = 90;
   motor[Flip2] = 90;
   wait1Msec(450);
   motor[Flip] = 25;
   motor[Flip2] = 25;
   wait1Msec(300);

   backwardtimeout(620, 800);//back up in line with blue ball 3
   gyroright(740);//rotate towards barrier
   liftup(600);

   nMotorEncoder[RR] = 0;
   nMotorEncoder[LR] = 0;
   while(nMotorEncoder[RR] > -300 || nMotorEncoder[LR] > -300)//knock buckies off bump
   {
      motor[RF] = -127;
      motor[RR] = -127;
      motor[LF] = -127;
      motor[LR] = -127;
   }
   basestop();
   wait1Msec(300);
   SensorValue[gyro] = 0;
   nMotorEncoder[RR] = 0;
   nMotorEncoder[LR] = 0;
   while(nMotorEncoder[RR] > -1200 || nMotorEncoder[LR] > -1200)//back up into blue ball 3
   {
      motor[RF] = -127;
      motor[RR] = -127;
      motor[LF] = -127;
      motor[LR] = -127;
   }
   basestop();

   liftdown(400);
   score();
   flipup(350);
   gyrohold = SensorValue[gyro];
   score();

   gyroleft(850+gyrohold);//compensate for issues
   forwardtimeout(650, 800);//forward to ball 4
   gyroleft(665);//insurance
   forwardtimeout(200, 300);

   backwardtimeout(400, 570);//reset to stash beach ball
   flipdown(400);
   forwardtimeout(1400, 1850);//pick up ball
   flipbeachball();

   gyroright(1370);//angle toward goal
   backwardtimeout(325, 500);

   liftup(1600);
   motor[Scorer] = 60;
   wait1Msec(810);
   motor[Scorer] = 0;

   forwardtimeout(300, 500);

   nMotorEncoder[RR] = 0;
   nMotorEncoder[LR] = 0;
}

task usercontrol()
{
   while (true)
   {
      updatejoy();
      motor[RF] = vexRT[Ch3] - vexRT[Ch4];
      motor[RR] = vexRT[Ch3] - vexRT[Ch4];
      motor[LF] = vexRT[Ch3] + vexRT[Ch4];
      motor[LR] = vexRT[Ch3] + vexRT[Ch4];

      if(joy_y > 117)//swerve auto
      {
         if(SensorValue[potL]>SensorValue[potR])
         {
            motor[Swerve] = ((SensorValue[potL] - SensorValue[potR]) / 5.93);//center from left
         }
         if(SensorValue[potR]>SensorValue[potL])
         {
            motor[Swerve] = ((SensorValue[potR] - SensorValue[potL]) / -4.77);//center from right
         }
      }
      else//swerve manual
      {
         if(joy_x > 0 && SensorValue[potL] < 445 || joy_x < 0 && SensorValue[potR] < 550)//potL=r90, potR=l90
         {
            motor[Swerve] = 0;
         }
         else
         {
            motor[Swerve] = vexRT[Ch1];
         }
      }
      if(vexRT[Btn5D] == 1)//lift down
      {
         motor[Lift]  = -127;
         motor[Lift2] = -127;
      }
      else if(vexRT[Btn5U] == 1)//lift up
      {
         motor[Lift]  = 127;
         motor[Lift2] = 127;
      }
      else//lift stop
      {
         motor[Lift]  = 0;
         motor[Lift2] = 0;
      }

      if(vexRT[Btn6D] == 1)//flipper down
      {
         motor[Flip]  = -127;
         motor[Flip2] = -127;
      }
      else if(vexRT[Btn6U] == 1)//flipper up
      {
         motor[Flip]  = 127;
         motor[Flip2] = 127;
      }
      else if (vexRT[Btn8R] == 1)//hold beach ball in flipper
      {
         motor[Flip]  = 40;
         motor[Flip2] = 40;
      }
      else//flipper stop
      {
         motor[Flip]  = 0;
         motor[Flip2] = 0;
      }

      if(vexRT[Btn8D] == 1)
      {
         motor[Scorer] = -127;
      }
      else if(vexRT[Btn8U] == 1)//scorer up
      {
         motor[Scorer] = 127;
      }
      else//scorer stop
      {
         motor[Scorer] = 0;
      }

   }
}


Mon Jan 20, 2014 5:12 pm
Profile
Rookie

Joined: Mon Jan 20, 2014 4:34 pm
Posts: 5
Post Re: Program Glitches
We have updated our program since my last post (I posted the new code above) and some issues have been fixed, but we are still experiencing one of the same issues. Often times when we run our autonomous, the program stops partway through and after waiting for about 2 seconds it starts the autonomous from the beginning. This used to happen occasionally, but recently it has been almost every run that we experience this issue. Is anyone else having this problem? Any help would be appreciated.
-822 Geared Up!


Thu Feb 27, 2014 9:12 am
Profile
Rookie

Joined: Thu Dec 01, 2011 12:07 am
Posts: 34
Post Re: Program Glitches
Have you ruled out an intermittent battery connection?


Thu Feb 27, 2014 1:33 pm
Profile
Rookie

Joined: Mon Jan 20, 2014 4:34 pm
Posts: 5
Post Re: Program Glitches
here is what we have tried:
-switch out cortex
-switch out controller
-test with backup battery both plugged in and unplugged
-add a power expander (in case we were experiencing processor brown outs)
-update to RobotC v4.06
-test with new vexnet 1.0 keys
-upgrade to vexnet 2.0 keys


Thu Feb 27, 2014 7:26 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.