Thank you for taking the time to read and answer my question ahead of time.
During the build season and at our recent participation in the Qualifier Event at Ransom Everglades Upper School, we noticed that, as the match went on, the potential difference in the battery would decrease, and that would cause our flywheels to spin slower, since the potential difference was dropping. Is there some way of programming the Cortex on ROBOTC to always deplete the battery’s voltage at a constant rate (preferably at its max), so there is no change in speed in the flywheels in our two-minute match? If there is not a way to do this, and it is a mechanical problem, is there any way to diagnose this?
I’m not exactly sure how you would do this. Batteries vary quite a bit. You can get a voltage reading on the battery but there is not necessarily a current sensor to know the rate of usage nor is there an overall capacity of the battery available. You may need to buy a battery beak to test the capacitance of the battery in mAhours. (it’s not cheap but we have one for our club to test battery charge effectiveness)
You could estimate current using the smart motor library and integrate the current coming out. But you have to go deeeeep into that code to get it to work and even then, the results you may see from battery to battery may vary depending upon age, charge, and even temperature.
You could also keep a view on the rate of battery voltage over time and see if the rate is going down too fast to hold back on the motors. But is that also causing you to not play the way you want to? While in the debugger, stream that out and save from result to result.
Do you distribute the load using a power expander? How many motors are at work and can you distribute the load across both the cortex and power expander? Now you have two current draws and voltage sources to worry about… Not the right direction for reducing variables…
Lastly, get more batteries than you want and bench test them against the robot in timed runs. Find the good ones and use those exclusively in competitions. Try to use the same chargers too in order to reduce variations as well.
On a different approach, you can use some programming techniques to ramp up the power given to your motors as you speed up. Going up slowly can reduce the current spikes and make your battery mileage go further. Kind of like flooring it in a Prius. You won’t go nearly as far on the battery.
the best thing for you to do is to actual control the flywheels velocity, instead of just sending it a power value, you would do this by putting encoders on your flywheels then using them to measure the velocity of the wheel, then you would use a control loop like a PID loop, or some of the other types that have been discussed recently on the forums
here is a video I made explaining the PID loop method