how to multiply motor power

I have some code and would like to times the motor power of back drive and right drive by 2 so iI tried
if(vexRT(Ch1) > 20 || (vexRT(Ch1) < -20))
{
motor[backdrive] = vexRT(Ch1);
motor[fordrive] = vexRT(Ch1);
motor[leftdrive] = vexRT(Ch1);
motor[rightdrive] = vexRT(Ch1);
}

 	if(vexRT(Ch1) > 20 || (vexRT(Ch1) < -20))
 	{
 motor[backdrive] = vexRT(Ch1*2);
	motor[fordrive] = vexRT(Ch1);
	motor[leftdrive] = vexRT(Ch1);
 motor[rightdrive] = vexRT(Ch1*2);
 }

and other varients of this with the * and 2 in different postions but could not make it work some help please

Well it’s important to keep in mind that the motors’ max speed is 127 - setting them to anything higher than that won’t make them go any faster. However, you could accomplish what you want to do like this:


motor[rightdrive] = vexRT[Ch1] * 2;

Just put this code (changing the motor and channel, of course) wherever you want, and it should work.

If you have space somewhere else on your bot you can also use gears, chains, and some other pieces to your advantage to have more than one motor powering a single shaft. It’s a bit out of the way, but if it is really that important it is well worth it.

Also, your first if statement is the same as your second, so anything you do in the first will be overwritten in the second.

Technically this will work as written. However, in reality you’ll just reduce the precision of your movements, since with this code, moving the joystick to half as far as it can go sends full motor power. To make your robot faster, you’d need to add some sort of gearing to your drivetrain like @Deicer explained.

Are you trying to increase one side of the drive to help it straighten out? If that’s the case then you would need to something like


VexRT[ch1] + 2

Rather than multiplying it by two. If this isn’t the case then like Bobtheblob said, you should format it something like this:

motor[backdrive] = vexRT(Ch1)*2;
motor[fordrive] = vexRT(Ch1);
motor[leftdrive] = vexRT(Ch1);
motor[rightdrive] = vexRT(Ch1)*2;

Sorry if none of this was needed. The thread said it hasn’t been answered yet so I thought I may try and help if the question hadn’t been answered yet :stuck_out_tongue: