Reducing joystick drive speed with RobotC

We are trying to reduce the speed of out motors on the drive. We have high speed 393’s. My question is how do we reduce the power output to the motors when they are being controlled by joystick?

This is our drive’s code that uses the joysticks:

  motor[LeftDrive2]   = -vexRT[Ch3];       
  motor[RightDrive4]  = vexRT[Ch2];       

This is a code that can be edited to change the speed of the motors: (bolded)


 motor[Mech1]        = ((vexRT[Btn5U] * **127**) * ana_1) - ((vexRT[Btn5D] * **127**) * ana_2);

The problem is that there is no setting to adjust the speed of motors when using joysticks. However there is for buttons…
How would you set up the joysticks so that the speed isn’t the default 127, but is something like 100?

An oldie but goodie! I encourage our kids to use log drive for better precision yet it still gives you full throttle capability.

https://vexforum.com/t/logarithmic-drive/18117/1

You could also create a ratio or mapping to say when I put this value in, I want this value out. So joy_val/127 is the percentage towards the top. Then take that and multiply by your new top value. You said 100 so…


motor[RightDrive4] = vexRT[Ch2]*100/127;

You could put a variable for the 100 and increase/decrease it via some other means like a button or just a re-download of the code.

That’s awesome! Thanks!

Is your goal to cap how fast it will ever go?
The joystick reads a range from -127 to 127 and the motor takes in the same values. That is why the classic
motor=joystick; works.

To scare down the power that can be sent you just need a factor to multiply it by.
motor=joystick*100/127; as stated above will allow a maximum of 100 power to be sent to each motor.