View unanswered posts | View active topics It is currently Thu Apr 24, 2014 2:41 pm






Reply to topic  [ 2 posts ] 
Programming Issue 
Author Message
Rookie

Joined: Mon Feb 04, 2013 5:05 pm
Posts: 1
Post Programming Issue
Below is the code on a student's robot. Nothing is working. I have a similar code on another robot, just with 393 motors instead of 269. I have tried with the motor controllers and without and it is still not working. Any ideas?

Code:
#pragma config(Motor,  port2,           rightmotor,    tmotorVex269, openLoop)
#pragma config(Motor,  port3,           leftmotor,     tmotorVex269, openLoop)
//*!!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!

/////////////////////////////////////////////////////////////////////////////////////////
//
//                          Pre-Autonomous Functions
//
// You may want to perform some actions before the competition starts. Do them in the
// following function.
//
/////////////////////////////////////////////////////////////////////////////////////////

void pre_auton()
{
  // Set bStopTasksBetweenModes to false if you want to keep user created tasks running between
  // Autonomous and Tele-Op modes. You will need to manage all user created tasks if set to false.
  bStopTasksBetweenModes = true;

   // All activities that occur before the competition starts
   // Example: clearing encoders, setting servo positions, ...
}

/////////////////////////////////////////////////////////////////////////////////////////
//
//                                 Autonomous Task
//
// This task is used to control your robot during the autonomous phase of a VEX Competition.
// You must modify the code to add your own robot specific commands here.
//
/////////////////////////////////////////////////////////////////////////////////////////

task autonomous()
{
  // .....................................................................................
  // Insert user code here.
  // .....................................................................................

   AutonomousCodePlaceholderForTesting();  // Remove this function call once you have "real" code.
}

/////////////////////////////////////////////////////////////////////////////////////////
//
//                                 User Control Task
//
// This task is used to control your robot during the user control phase of a VEX Competition.
// You must modify the code to add your own robot specific commands here.
//
/////////////////////////////////////////////////////////////////////////////////////////

task usercontrol()
{
   // User control code here, inside the loop

   while (true)
   {
  // Joystick Control:
  motor[port2] = vexRT[Ch2]; //Motor port 2 speed is determined by Ch2 on the VEXnet Transmitter
  motor[port3] = vexRT[Ch3]; //Motor port 3 speed is determined by Ch3 on the VEXnet Transmitter
     // This is the main execution loop for the user control program. Each time through the loop
     // your program should update motor + servo values based on feedback from the joysticks.

     // .....................................................................................
     // Insert user code here. This is where you use the joystick values to update your motors, etc.
     // .....................................................................................

     UserControlCodePlaceholderForTesting(); // Remove this function call once you have "real" code.
   }
}


Mon Feb 04, 2013 5:07 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 537
Post Re: Programming Issue
There are a couple of things I would try right off of the bat. First, I would suggest removing the following two lines from the autonomous and usercontrol functions, respectively:

Code:
AutonomousCodePlaceholderForTesting();  // Remove this function call once you have "real" code.
UserControlCodePlaceholderForTesting(); // Remove this function call once you have "real" code.


These two function calls are simply placeholders in the template until user-defined code is put in; the AutonomousCodePlaceholderForTesting(); for instance will call to a function that has this code in it:

Code:
   while (true)
   {
     displayStatusAndTime();
      wait1Msec(100);
      ++nTimeXX;
   }


If this function is called first in autonomous before any other code is run, it will 'lock down' the robot in autonomous until autonomous ends. The UserControlCodePlaceholderForTesting(); function isn't as controlling, but it does have a 100 millisecond wait period in it:

Code:
displayStatusAndTime();
   wait1Msec(100);
   ++nTimeXX;


I would suggest getting rid of these two lines first just to see, and if that doesn't work, double check that you have VEXNet connected properly, the Compiler Target is set to Physical Robot, and that the Cortex can communicate with the Joystick Controller; we have a full setup guide on our wiki you may want to look at.

_________________
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


Tue Feb 05, 2013 2:32 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


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:  



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