With the Cortex there was a lot of programming to be done for flywheels. It was somewhat complex and close to beyond me unless I picked through it slowly. The kids I was working with were using some sort of @jpearman 's Take Back Half program and concepts.
With VCS is it as easy as setting the target RPM?
Only slightly more complicated (if you have a 2 wheel flywheel) would be to set the right side RPM, and have the left side target the right’s actual RPM.
Are there any tips for ramping up/down single flywheels with VCS?
function flywheel(targetSpeed)
//Percent; maximum speed difference per ramping step; tweak as desired
persistent constant speedDelta = 10
//Milliseconds; minimum delay between ramping steps; tweak as desired
persistent constant period = 1000
//Milliseconds; initial value should be less than -period
persistent var lastExecutionTime = -2000
if currentSystemTime - lastExecutionTime ≥ period
if abs(targetSpeed - currentSpeed) > speedDelta
//abs() = absolute value
setSpeed(currentSpeed + ((targetSpeed - currentSpeed) /
abs(targetSpeed - currentSpeed)) * speedDelta)
//setSpeed(currentSpeed + (±1) * speedDelta)
otherwise
setSpeed(targetSpeed)
end if
set lastExecutionTime = currentSystemTime
end if
end function flywheel
My
persistent
keyword corresponds to the
static
keyword in C/C++
This function is designed to be completely safe to call in your main execution block (assuming
setSpeed()
is safe). You can set your main execution loop’s frequency to any reasonable value and my implementation will work.
Does VCS even have the ability to override the built in motor PID currently? I remember manual PWM was mentioned as a method for controlling the motor, but I don’t see any reference for if/how you can impliment it.
As far as I can tell, no, which is extremely limiting for teams using VCS. I tried looking through the entire VCS API so I could use voltage control on my drive (which is far easier to control), but ended up switching to PROS.
The PWM and Motor PID functions are exposed in the PROS API. You can find more information about how these functions work in their PROS documentation entries:
is analogous to
vexDeviceMotorPwmSet()
function describes the various parameters that can be set to the Motor PIDs, as well as how they need to be formatted.
These functions are all part of the standard PROS API, and are paired with some additional functions that are designed to make the Motor PIDs easier to modify.