In the program file attached, you can gradually increase launch speed by using +=10 and it recommends putting an if statement to limit the max to 127. I am new to programming. Can anybody tell me where I would place the if statement? We are having trouble with motors stalling and the competition is saturday. I would be grateful for any help!

One way of ramping up the motor speed would be to use a for statement a bit like this:

``````int desiredSpeed = 127

for(int i = 0; i > desiredSpeed; i++)
{
motor[motor1] =  i;
wait1Msec(30)
}
``````

In the code you provided you could do it like this:

``````int desiredSpeed = 127
while(true)
{
motor[port3] = launchspeed;
if(vexRT[Btn5D] == 1)
{
launchspeed += 1
wait1Msec(30);
if(desiredSpeed < launchspeed)
{
launchspeed = desiredSpeed;
}
}
}
``````

in this example if the launchspeed (or the speed being sent to the motors) is higher than the speed you want the flywheel to spin at, it sets the launchspeed to be the desired speed. You could also implement it like this:

``````int desiredSpeed = 127
while(true)
{
motor[port3] = launchspeed;
if(vexRT[Btn5D] == 1 && desiredspeed != launchspeed)
{
launchspeed += 1
wait1Msec(30);
}
}
``````

In this example the speed will only increase if the desired speed is not equal to the launchspeed. Which should be sufficient in this case (to ramp up motors).

Not entirely what you asked, but to the same effect. Hopefully this should help you understand it a little better though

One thing to be careful of is your term “Speed”. You are not controlling speed, you are increasing power. This may confuse things later when you really do try to control speed.

Thanks so much for your help! THis is a big learning curve!

If I am using 4 motors, can I set each motor to be “launchspeed”. For example, can I say:
motor[port3] = launchspeed
motor[port4] = launchspeed
motor[port 6] = launchspeed
and then launchspeed would take into account all of these motors?

Sooo, I have the code here and it seems to be working. There is one major problem. After I use button 6u or 6d to gradually ramp up the motors, the motors start randomly jerking after i release the buttons and they won’t stop. Is there something wrong with the code? I think I properly defined the integers??? Here is the code. Thank you so much for all of your help. I am very new to this. This is my first time coding.

#pragma config(Motor, port1, Front_Right_Dr, tmotorVex393_HBridge, openLoop, driveRight)
#pragma config(Motor, port2, Front_Left_Dr, tmotorVex393_MC29, openLoop, reversed, driveLeft)
#pragma config(Motor, port3, Wheel_Entry_1, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port4, Left_Top_Lch, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port5, Right_Top_Lch, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port6, Left_Bottom_Lch, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port7, Right_Bottom_Lch, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port8, Flappy_Thing, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port9, Back_Left_Dr, tmotorVex393_MC29, openLoop, driveLeft)
#pragma config(Motor, port10, Back_Right_Dr, tmotorVex393_HBridge, openLoop, reversed, driveRight)

int desiredspeed = 127;
int launchspeed = 0;
int reversedesiredspeed = -127;
{
while (true)
{
motor[Left_Bottom_Lch] = launchspeed;
motor[Left_Top_Lch] = launchspeed;
motor[Right_Bottom_Lch] = launchspeed;
motor[Right_Top_Lch] = launchspeed;

`````` 	if(vexRT[Btn6U] == 1 && desiredspeed !=launchspeed)
{
launchspeed += 10;
wait1Msec(30);
}
else if(vexRT[Btn6D] == 1 && reversedesiredspeed !=launchspeed)
{
launchspeed += -10;
wait1Msec(30);
}
else
{
motor[Left_Bottom_Lch] = 0;
motor[Left_Top_Lch] = 0;
motor[Right_Bottom_Lch] = 0;
motor[Right_Top_Lch] = 0;
}

motor[Front_Right_Dr] = vexRT[Ch2];
motor[Back_Right_Dr] = vexRT[Ch2];
motor[Front_Left_Dr] = vexRT[Ch3];
motor[Back_Left_Dr] = vexRT[Ch3];

if(vexRT[Btn8L] == 1)
{
motor[Left_Bottom_Lch] = 65;
motor[Left_Top_Lch] = 65;
motor[Right_Bottom_Lch] = 65;
motor[Right_Top_Lch] = 65;
}
else if(vexRT[Btn8D] == 1)
{
motor[Left_Bottom_Lch] = -65;
motor[Left_Top_Lch] = -65;
motor[Right_Bottom_Lch] = -65;
motor[Right_Top_Lch] = -65;
}
else
{
motor[Left_Bottom_Lch] = 0;
motor[Left_Top_Lch] = 0;
motor[Right_Bottom_Lch] = 0;
motor[Right_Top_Lch] = 0;

if(vexRT[Btn5D] == 1)
{
motor[Flappy_Thing] = 127;
motor[Wheel_Entry_1] = 127;
}
else if(vexRT[Btn5U] == 1)
{
motor[Flappy_Thing] = -127;
motor[Wheel_Entry_1] = -127;
}
else
{
motor[Flappy_Thing] = 0;
motor[Wheel_Entry_1] = 0;
}
}
}
``````

}

I think I figured out why the random jerking! Instead of naming all motors in the else statement for stop, I used launchspeed. Could that have been it?