I just wanted to know how to program the motors to where the speed changes depending on the value of the scroll on the Logitech Attack 3 Joystick.
Are you talking about drivetrain motors or something else?
- read the value of that axis (Axis 3 I think)
- convert it to a number between 0 and 1 (y=mx+b, yay algebra)
- Multiply your other joystick inputs by this number (or your motor outputs)
It may not be useful to have the bottom of the throttle act as 0. Maybe make it 20% (0.2 to 1 is now the output of y=mx+b)
let’s look at how this works. At full throttle, and max joystick input, the motor will get (joystick * throttle) = (1 * 1) = 1
If you bring the throttle back to 50% (0.5), then the motor gets (1 * 0.5) = 0.5, which is half speed.
2 Shooter motors.
I reccomend against doing something like that. 4183 tried it for our first regional last year and learned that it was nearly impossible to get fine control of our shooter speed due to the slop in the throttle. Before our second competition, we programmed the joysticks to control rate of change in speed rather than speed.
It’s pretty simple code to write:
If speed-up button is pressed, shooter speed = shooter speed + constant If speed-down button is pressed, shooter speed = shooter speed - constant
Other buttons can be used to stop the shooter or run it at preset speeds.
However, if your shooter works consistently at a range of speeds, the throttle might work fine.
If you really want to do that, you don’t need to do algebra because WPI does it for us already. All the axes read from 1 to -1. So you should be able to just give the motors the axis and they should behave accordingly.
You don’t want to run your shooter in reverse and you want to be able to get maximum resolution by using the throttle’s full range of travel.