So for the competition, I want to have my bot not run at full voltage all the time because that causes strain on the motors which is not good. So I am concerned and am trying to figure a way to restrict the motor voltage. I am completely new to vexcode but not programming in general. Can someone point me in the right direction please! Please note that this is for driver control not auton.
Welcome to the forum @nickdoesrobotics !
In this case, it may be helpful to include your code, so that way we can figure out exactly what changes you could make.
Are you hoping to do this for the drive or a different part of the robot?
For the drive, one suggestion I have could be to multiply the joystick value by 0.5 to reduce it by half. This does have an unfortunate drawback that you can’t really go at full speed during driver control. To solve this, you could program a button on the controller so that when it is pressed, the drive only runs at half speed, and when it is not pressed it runs at full speed (or vice versa if you felt like it)
Another suggestion is you could try and use an exponential drive function. I’m not really sure that this would help you very much:
For using the buttons to control motors, you can likely just change the speeds.
I am concerned that if I keep the “drive” at full speed the motors will burnout, how exactly do i multiply the joystick value?
Just do something like:
(0.5 * Controller1.Axis.value())
Which is probably what you have in your code (or at least pretty close).
First of all, welcome to the forum!
Although an answer is provided above, I do not believe you need to limit the motor voltage to prevent burnout. Instead, consider factors on build quality such as friction and making sure your gear ratios are realistic. I believe that is the greatest problem, and merely “patching” a problem as important as your drivetrain via code is not a good idea.
We have found that the main reason the motors burn on drives isn’t because of running at top speed it’s their acceleration to max speed that hurts you the most