The problem is that one of the two joysticks is controlling all three motors at the same time. We have verified that all three motors are plugged into and configured in different ports on the brain. When the robot is powered up, the Axis 3 movement is running all three motors. I am not sure why this is happening. Thank you for your help.
vex coding studio has been discontinued for a very long time now, you should use vexcode instead, which has been the currently updated and supported program for over a year now. It will make programming and seeking help much easier.
Those two lines look OK to me, could you post the complete program? Maybe there is some code somewhere else that is controlling all the motors based on the value of axis 3.
If you’re looking for support for an unsupported product, it seems you will be frustrated.
Posting the full code would help; there is nothing in the 2 lines you posted that would indicate the problem you describe. However, the rest of the program would be informative.
No, they aren’t. Those two lines do not constitute a valid C++ program. If the code is compiling there is most definitely more code to see.
I also want to reiterate what has already been stated: VCS has not received an update in over 2 years, and is no longer supported. I highly suggest you migrate to VEXCode V5 or VEXCode Pro, both of which have the same syntax and API as VCS, but also include support for new features and sensors, and include a variety of improvements that make it much easier to write code in them. You can even import your old VCS project files.
#include "robot-config.h"
/*---------------------------------------------------------------------------*/
/* */
/* Description: Competition template for VCS VEX V5 */
/* */
/*---------------------------------------------------------------------------*/
//Creates a competition object that allows access to Competition methods.
vex::competition Competition;
/*---------------------------------------------------------------------------*/
/* Pre-Autonomous Functions */
/* */
/* You may want to perform some actions before the competition starts. */
/* Do them in the following function. You must return from this function */
/* or the autonomous and usercontrol tasks will not be started. This */
/* function is only called once after the cortex has been powered on and */
/* not every time that the robot is disabled. */
/*---------------------------------------------------------------------------*/
void pre_auton( void ) {
// 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. */
/*---------------------------------------------------------------------------*/
void autonomous( void ) {
// ..........................................................................
// Insert autonomous user code here.
// ..........................................................................
}
/*----------------------------------------------------------------------------*/
/* */
/* 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. */
/*----------------------------------------------------------------------------*/
void usercontrol( void ) {
while (1)
{
LeftMotor.spin(vex::directionType::fwd, Controller1.Axis3.value(), vex::velocityUnits::pct);
RightMotor.spin(vex::directionType::fwd, Controller1.Axis2.value(), vex::velocityUnits::pct);
vex::task::sleep(200);
}
}
int main() {
//Run the pre-autonomous function.
pre_auton();
//Set up callbacks for autonomous and driver control periods.
Competition.autonomous( autonomous );
Competition.drivercontrol( usercontrol );
//Prevent main from exiting with an infinite loop.
while(1) {
vex::task::sleep(100);//Sleep the task for a short amount of time to prevent wasted resources.
}
}
First things first, the command vex::task::sleep(200) is a bit long. I typically use about 20ms delay in a while loop. I don’t see anything here which would cause three motors to operate in this program. I might recommend checking to see which program you are running. You might try redownloading.
I agree with @OscarMNOVA12; are you sure they are running the right program? I don’t see anything in that code that would be causing 3 motors to move.
While I’m at it, I might put out my shameless plug to get off Vex Coding Studio (VCS). Having used this software, vexcode text or pro is much easier to develop than with VCS. A few reasons from experience to change, reliable code saving, search features, and better advanced features to grow into.
Your students really don’t need to change how they code. VCS and VexCode use the same command set, commonly called an API. It also adds some new coding features such as drivetrains and motor groups.
Did you check that your student’s are running their program and not the “drive” program. The default drive program has bamboozled me more than I like to admit.