Is there a way to make a p- loop out of the spin for command?

i have been trying to make a p-loop control the speed of the spin for command, but it doesnt update speed after the spin for command is active, is there a way to make it change speed mid spin for?

The spinFor method handles the PID logic and sets the voltage within the API. If you want to control speed of the motor in a P-Loop you need to directly control the voltage.

spin(directionType dir, double voltage, voltageUnits units)

Teams creating their own proportional loop will measure the rotations and set the voltage based on the size of the error.
double volts = (target - current) * myKpValue

5 Likes


(i know people hate it when you use screenshots of code, but the code was looking very messy in the [code/] format)

this is what i just drafted up to use a p-loop with the spin command, but when i run it nothing happens, i made it print the value, and it says the motor is at 0 degrees, but it just doesn’t work

now that i look at it again, i think i see what is wrong, i might have the < and > signs in the wrong place

1 Like