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

Problem with this code
http://www.robotc.net/forums/viewtopic.php?f=11&t=19534
Page 1 of 1

Author:  Korndog [ Thu Oct 20, 2016 2:37 pm ]
Post subject:  Problem with this code

I have been having my students really get into the programming with RobotC for the VEX. I like to make up challenges which reinforce a particular concept. The current challenge is for students to move toward a mostly empty water bottle, pick it up and place them on top of a 2x4. Four 2x4's enclose the arena area in the shape of a square. Some of the problems we have been having focuses around a robot running a piece of code correctly until a certain point. When a piece of code doesn't work, it isn't making sense as to why. We don't receive any error codes when downloading and usually the piece of code worked earlier in the entire program

I have pasted this code and will point out where the robot doesn't work.

#pragma config(Motor, port1, rightMotor, tmotorVex393_HBridge, openLoop, reversed)
#pragma config(Motor, port6, claw, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port7, arm, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port10, leftMotor, tmotorVex393_HBridge, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//


task main()
{


motor[claw] = 80; // the claw is opening
wait1Msec(500);

motor[leftMotor] = 75; // motor moving forward
motor[rightMotor] = 58;
wait1Msec(700);

motor[rightMotor]= 0;
motor[leftMotor]=0;

motor[claw]=-15; //the claw is closing
wait1Msec(1000);

motor[arm]= -40; // the elbow is moving up// ***Here is were the code works properly****
wait1Msec(1000);

motor[rightMotor]=50; //motor moving forward
motor[leftMotor]=55;
wait1Msec(425);

motor[rightMotor]= 0;
motor[leftMotor]=0;

motor[arm] = 25; //the elbow is moving down
wait1Msec(500);

motor[arm]=0;
wait1Msec(2000);

motor[claw]=80;//claw is opening
wait1Msec(500);

motor[leftMotor] = 0;
motor[rightMotor] = 0;

motor[leftMotor] = -75; //backing up
motor[rightMotor] = -58;
wait1Msec(1175);

motor[rightMotor]= 55; //swing turn towrds 2nd bottle
motor[leftMotor]=-55;
wait1Msec(520);

motor[rightMotor]=50;
motor[leftMotor]=55;
wait1Msec(475);

motor[rightMotor]=0;
motor[leftMotor]=0;

motor[claw]= -80;
wait1Msec(2500);

motor[claw] = 0;

motor[rightMotor]=40;
motor[leftMotor]=45;
wait1Msec(1000);

motor[arm]= 40; // the elbow is moving up// ***This piece of code only moves the arm upward for about 1/10th of a second.**
wait1Msec(2000);

}

Thank you.

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