V5 Struggle

So, the mechanical guy is trying to do some basic V5 Text coding- some success, lots of frustration. In the tele-op file below I have successfully programmed the drive motors to the joysticks and another motor to run at reduced speed as commanded by buttons L1 and L2. So far so good. Progress stalled when I tried to command a fourth motor to a fixed number of rotations and a fith motor to limited torque. I’m obviously missing something. Help!
/----------------------------------------------------------------------------/
/* /
/
Module: main.cpp /
/
Author: C:\Users\Tom /
/
Created: Tue Dec 31 2019 /
/
Description: V5 project /
/
/
/
----------------------------------------------------------------------------*/

// ---- START VEXCODE CONFIGURED DEVICES ----
// Robot Configuration:
// [Name] [Type] [Port(s)]
// Motor5Arm motor 5
// Motor6Claw motor 6
// Controller1 controller
// Motor3Feeder motor 3
// Motor4Launcher motor 4
// Motor1Left motor 1
// Motor2Right motor 2
// ---- END VEXCODE CONFIGURED DEVICES ----

#include “vex.h”

using namespace vex;

int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
while(1==1){
//Everything between these curly braces will run in a continuous loop

//The following section controls drive motors via the joysticks
Motor1Left.setVelocity(Controller1.Axis3.value(), velocityUnits::pct);
Motor2Right.setVelocity(Controller1.Axis2.value(), velocityUnits::pct);
Motor1Left.spin(forward);//Set drive motor spin direction, one side will be reversed
Motor2Right.spin(forward);//Must be “forward”, changing to “reverse” makes motor quiver

//The following will run Motor3 at 1/4 speed controlled by shoulder buttons L1 & L2
//Maximum motor torque is still available
if(Controller1.ButtonL1.pressing() == true)
{Motor3Feeder.setVelocity(15, percent);}
else if(Controller1.ButtonL2.pressing() == true)
{Motor3Feeder.setVelocity(-15, percent);}
else
{Motor3Feeder.stop();}

//THIS COMMAND DOES NOT YET WORK; MOTOR RUNS AT HALF SPEED
//HALF SPEED MOTOR OPERATION IS THE DEFAULT WITH ONLY MOTOR & CONTROLLER CONFIGURING
//THE BRAIN IS APPARENTLY IGNORING THE CODE SHOWN
//This section commands the motor to turn +/-2 turns per Buttons R1 & R2
// Set the current position of the Launcher at zero
//Motor4Launcher.spin(forward);
//Motor4Launcher.setPosition(0, degrees);
if(Controller1.ButtonR1.pressing() == true)
{Motor4Launcher.spinFor(forward, 2, turns);}
else if(Controller1.ButtonR2.pressing() == true)
{Motor4Launcher.spinFor(reverse, 2, turns);}
else
{Motor4Launcher.stop();}

//THIS COMMAND DOES NOT YET WORK; MOTOR RUNS AT HALF SPEED
//HALF SPEED MOTOR OPERATION IS THE DEFAULT WITH ONLY MOTOR & CONTROLLER CONFIGURING
//THE BRAIN IS APPARENTLY IGNORING THE CODE SHOWN
//This section commands the motor to turn at a low torque
if(Controller1.ButtonX.pressing() == true)
{Motor5Arm.setMaxTorque(10, percent);}
if(Controller1.ButtonB.pressing() == true)
{Motor5Arm.setMaxTorque(10, percent);}
else
{Motor5Arm.stop();}
}
}

I did not notice issues with the 4th motor, but that’s probably because I missed something when reading. However, for the fifth motor, there is no command for it to spin, but there is only a command to set the maximum torque. I added 2 lines to make it spin.

if(Controller1.ButtonX.pressing() == true)
{Motor5Arm.setMaxTorque(10, percent);
Motor5Arm.spin(forward, 100, percent);}
if(Controller1.ButtonB.pressing() == true)
{Motor5Arm.setMaxTorque(10, percent);
Motor5Arm.spin(reverse, 100, percent);}
else
{Motor5Arm.stop();}
1 Like

Thanks for the response. Your sugestion has been implemented as shown below but problems still exist. ButtonX now does nothing and ButtonB causes the motor to run at what seems like full speed and torque. With a small shaft in the motor I could not stop it from turning between my fingers even though max torque should be 10%. I made sure that the button directions in the code matched those of the Controller configuration.

if(Controller1.ButtonX.pressing() == true)

{Motor5Arm.setMaxTorque(10, percent);

Motor5Arm.spin(forward, 100, percent);}

if(Controller1.ButtonB.pressing() == true)

{Motor5Arm.setMaxTorque(10, percent);

Motor5Arm.spin(reverse, 100, percent);}

else

{Motor5Arm.stop();}