@jpearman Our robot is having issues with the variable motor speed and we would like to know how to make it work. We want to have a button to increase the motor speed, and a button to decrease the motor speed. Below is the code that we are currently using, but we are having buggy motor issues. It looks as if the motors are receiving two different signals and if we press the button during when the flywheel is running I just cuts out. Do you have any ideas why this could be happening and how to fix it.
#pragma config(I2C_Usage, I2C1, i2cSensors)
#pragma config(Sensor, dgtl1, , sensorQuadEncoder)
#pragma config(Sensor, I2C_1, , sensorQuadEncoderOnI2CPort, , AutoAssign)
#pragma config(Motor, port1, liftRight, tmotorVex393_HBridge, openLoop, reversed)
#pragma config(Motor, port2, frontLeft, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port3, frontRight, tmotorVex393HighSpeed_MC29, openLoop, reversed)
#pragma config(Motor, port4, backLeft, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port5, backRight, tmotorVex393HighSpeed_MC29, openLoop, reversed)
#pragma config(Motor, port6, shootLeft, tmotorVex393TurboSpeed_MC29, openLoop)
#pragma config(Motor, port7, shootRight, tmotorVex393TurboSpeed_MC29, openLoop, encoderPort, I2C_1)
#pragma config(Motor, port8, shootLeftTwo, tmotorVex393TurboSpeed_MC29, openLoop, reversed)
#pragma config(Motor, port9, shootRightTwo, tmotorVex393TurboSpeed_MC29, openLoop, reversed)
#pragma config(Motor, port10, liftLeft, tmotorVex393_HBridge, 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"
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;
slaveMotor(port6, port7);
slaveMotor(port9, port7);
slaveMotor(port8, port7);
resetMotorEncoder(shootRight);
}
task autonomous()
{
wait1Msec(500);//wait .5 seconds
motor[shootRight] = 110;
wait1Msec (5000);//wait 5 seconds
motor[liftLeft] = -100;
motor[liftRight] = -100;
wait1Msec(9000);//wait 9 seconds
}
int MotorSpeed = 127;
int MotorSpeedl = 110;
int MotorSpeedle = 95;
int MotorSpeedles = 80;
int MotorSpeedless = 60;
int parthanax = 0;
int parthanax2 = 0;
task usercontrol()
{
while (true)
{
motor[frontRight] = vexRT[Ch3] - vexRT[Ch1] - vexRT[Ch4];
motor[backRight] = vexRT[Ch3] - vexRT[Ch1] + vexRT[Ch4];
motor[frontLeft] = vexRT[Ch3] + vexRT[Ch1] + vexRT[Ch4];
motor[backLeft] = vexRT[Ch3] + vexRT[Ch1] - vexRT[Ch4];
//partner control shooter basic
if(vexRT[Btn7DXmtr2] == 1 || vexRT[Btn7UXmtr2] == 1)
{
parthanax = 1;
parthanax2 = parthanax2 +1;
}
if((parthanax == 1) && (parthanax2 == 1))
{
if(vexRT[Btn7DXmtr2] == 1)
{
MotorSpeed = MotorSpeed -3;
MotorSpeedl = MotorSpeedl -3;
MotorSpeedle = MotorSpeedle -3;
MotorSpeedles = MotorSpeedles -3;
MotorSpeedless = MotorSpeedless -3;
}
else //(vexRT[Btn7UXmtr2] == 1)
{
if (vexRT[Btn7UXmtr2] == 1)
{
MotorSpeed = MotorSpeed +3;
MotorSpeedl = MotorSpeedl +3;
MotorSpeedle = MotorSpeedle +3;
MotorSpeedles = MotorSpeedles +3;
MotorSpeedless = MotorSpeedless +3;
}
}
parthanax = 0;
parthanax2 = 1;
} // end of (parthanax == 1) && (parthanax2 == 1))
else
{
if(vexRT[Btn7LXmtr2] == 1)
{
parthanax2 = 0;
parthanax = 0;
if(vexRT[Btn7RXmtr2] == 1)
{
MotorSpeed = 127;
MotorSpeedl = 110;
MotorSpeedle = 95;
MotorSpeedles = 80;
MotorSpeedless = 60;
}
}
}// end of else (parthanax == 1) && (parthanax2 == 1))
if(MotorSpeed < 0)
{
MotorSpeed = 0;
}
if(MotorSpeed > 127)
{
MotorSpeed = 127;
}
else if(vexRT[Btn6UXmtr2] == 1)
{
motor[liftLeft] = -127;
motor[liftRight] = -127;
motor[shootRight] = MotorSpeed;
}
else if(vexRT[Btn5DXmtr2] == 1)
{
motor[liftLeft] = 127;
motor[liftRight] = 127;
}
else if(vexRT[Btn5UXmtr2] == 1)
{
motor[liftLeft] = -127;
motor[liftRight] = -127;
}
else if(vexRT[Btn6DXmtr2] == 1)
{
motor[shootRight] = MotorSpeed;
}
else if(vexRT[Btn8UXmtr2] == 1)
{
motor[shootRight] = MotorSpeedl;
}
else if(vexRT[Btn8RXmtr2] == 1)
{
motor[shootRight] = MotorSpeedle;
}
else if(vexRT[Btn8DXmtr2] == 1)
{
motor[shootRight] = MotorSpeedles;
}
else if(vexRT[Btn8LXmtr2] == 1)
{
motor[shootRight] = MotorSpeedless;
}
else
{
motor[shootRight] = 0;
motor[liftLeft] = 0;
motor[liftRight] = 0;
}
}
}