Our team has a pretty good code for keeping the flywheel at a constant speed. However, the code contains a while loop, from which the robot cannot do anything else before the flywheel reaches the target speed. In driver skills, it would often take 4-6 sec at the beginning of each round and we find this pretty annoying. Is there any way to shorten this time or allow the robot to multi-task? I have tried the sleep function, but pros says that it is not defined within the scope. Do I have to include other files for it to work?
Block code or text? Can’t help you with text, but I can help you with block
It looks like it is in text. If you have a while loop inside of your driver loop, I would get rid of it as the nested while statement is what’s blocking everything else.
I have it as a function stored in function.cpp and included it in main.cpp’s driver loop. Whenever I hit the button, the robot’s flywheel will run this code.
If I get rid of it, the flywheel wouldn’t have velocity control.
You could multitask, this can be done line this:
vex::task taskName(callback);
multitasking allows multiple chunks of code run parallel to eachother.
The way that we keep the flywheel at the same speed is by controlling it with voltages, they are more consistent and it doesn’t do that weird up-down speed thing
Do you mean using the motor.spin(directionType::fwd, 12.0, voltageUnits::volt);?
So I know that the motor power range from -12 to 12. Does having 12 make the motor spin at max speed? And if this is the case, where does the speed control come in?
I never used this vex::task taskName(callback); before. Do I just input the name of the function for speed control? May you please provide me with an example? Thanks in advance
12 volts is max speed, it’s mostly trial and error for the right speed
So, if I find out that that 10 volts give me a good speed and program motor.spin(directionType::fwd, 10.0, voltageUnits::volt);, will the flywheel keep spinning at this consistent speed or it would become faster as time elapse? Essentially what I am asking is whether this function as a built in speed control thing.
It should be very consistent, the only time that it might slow down is if you get overheated