Velocity Control - Battery Compensation Term

When doing velocity control with the talon srx’s, the velocity you get from your feed-forward term is going to be affected by battery voltage. Has anyone experimented or used a battery offset term to correct for this? Is it worth it?


The I gain is for things like that. We use I and P for velocity control and as long as you design your gearbox / motor combo with enough headroom then the I and P can compensate. We design our speed controlled devices to operate at 60% duty for the ideal situation. For example, if you want your shooter to go 2500 RPM, it better hit that speed at 60% - 70% duty. This way, the I and P gain can do their job. When testing without speed control, if you set your motor command at .6 or .7, then you should be able to score your game object from the desired shooting spot with a full battery and one ball at a time. At least, this is what we do.


I’m currently working on something similar. It seems like when the Talon is in Velocity Control Mode the feed forward term is used to calculate an output voltage. This would make think that it wouldn’t be affected by battery voltage unless it dropped bellow the requested output.
I’m not certain, but I’m sure CTRE will give an answer soon.

Is there a way to calculate this? Such as if I’m using a motor say with a 10kRPM free speed but I want my shooter to go 2.5kRPM, what method or charts would I need to calculate the ratio that will get me to 2.5kRPM at 60-70% duty cycle? I assume it would be less aggressive gearing than if I did the usual calculation, which in this case would be 4:1

Here’s a rough calculation:

10000 rpm motor free speed at 100% command
6500 rpm motor free speed at 65% command
2500 desired operating rpm of flywheel
2.6:1 speed reduction gear ratio = 6500/2500

YMMV depending on how much friction and windage you have in your gearing and flywheel

Didn’t think it would be just that simple, thanks

This ^ with a 0.8-0.9 for gearbox efficiency will get you close. For this example, 65% command: 10,000 rpm * 0.65 * 0.8 = 5200 rpm free speed. 5200/2500 yields approx 2:1 gear ratio.

Consider the following thought experiment:

Take a CIM whose free speed is 5310 rpm at 12 volts and connect it to a good quality properly assembled and lubed 2:1 gearbox whose output shaft is connected to nothing (no load).

Using the same computation you did above, the CIM’s speed would now be 5310*0.8 = 4248 rpm.

Now go to the motor curves for CIM and you’ll see that CIM is drawing 29 amps.

Do you believe that? If not, where is the error?

An unloaded, well lubed, 2:1 gearbox has a much higher efficiency factor and thus I would expect a higher CIM speed and lower current. If you lube the gearbox with toothpaste you might create enough friction to draw 29 amps at 4248 RPM. :slight_smile:

The 0.8-0.9 factor approximates typical losses seen in FRC for gearboxes + belt/chain + bearing friction + wheel/roller windage.

I’ve seen the .8 number in various places for drivetrains, which include rolling friction, carpet deformation, multi-stage gearboxes, and gears/chains or belts/pulleys.

It would be very interesting to see test data for a quality 2:1 single-stage gearbox (properly assembled and lubed) connected directly to a properly balanced spokeless shooter flywheel, when the flywheel is spinning unloaded (i.e. not firing balls) at its operating speed. Volunteers?

I would guesstimate the torque speed relationship is not linear from free speed. So the small amount of load the gearbox presents reduces the speed more initially without necessarily loading the motor to the point of 29A. I would then expect additional load to be more linear in current and speed.

Our experience from last year, make sure you F term undershoots the desired speed, as opposed to overshoots the desired speed. When this is true, the srx is rock solid and smooth. I would not try to compensate the F term higher after the tune. I would tune with a full battery, make the F slightly under the target, and let the PID do the work. It was a beautiful thing last year on our shooters.

The other thing to watch for, is if you are going to let the shooter wheels run down, put them in %vbuss mode, or you will pid them to 0, which will make them stop fast and with a lot of heat for no good reason.

SRX lets you clamp the PIDF output, no? Don’t allow negative voltage. And make sure it’s in coast mode.

Looks pretty linear down to about 0.03 Nm.

Thanks Paul. I usually design for my shooting speed to be at about 50% max velocity, because that’s usually right around the peak power for the motor and I want to optimize spin-up time after a shot.

Good to know I don’t have to mess around with battery compensation.

I wrote down some numbers last night from one of our prototypes. The setup is not exactly as we discussed but a data point nonetheless.

(2) 775pros through 4:1 VersaPlanetary gearboxes driving a set of shooter wheels via 24T HTD pulleys (1:1) and belts. The shaft is nicely supported running on Thunderhex bearings. CTR Mag encoder on the VP.

A vbus command of 1.0 yielded roughly 4400-4500 RPM. The battery checked in around 13V before we started the test but I didn’t record the exact voltage while it was running.

775pro free speed is 18730, so a perfectly efficient 4:1 gearbox would give 18730/4 = 4683 RPM. The efficiency factor for this free running system is 4400/4683 = 0.94 to 4500/4683 = 0.96

I forgot to check the motor currents but IIRC from the previous night it was on the order of 3-6 amps per motor. With the motor is running at 17600-18000 RPM this roughly matches the motor curve of 6-8.5 amps.

0.95 factor seems like a better number for a free running system. However, in the case of a shooter or intake, using a 0.8 factor may get you closer to your desired vbus because of slippage at the wheel/ball interface. For the prototype mentioned above, we calculated the theoretical RPM required to achieve our desired exit velocity based on a trajectory simulation. We wanted gear ratio to run the motors around 60-65% vbus. The closest fit just under the target was a 4:1 gearbox that put it at 50% vbus. In testing, the motors ran at 60-65% vbus. So 0.5/0.625 = 0.8 magic. A bit sketchy, based on a theoretical trajectory simulation, but my guess is that using a 0.8 factor for shooter/intakes will get you close.

I totally agree with Paul.

And yet… we just added a form of battery compensation in the last CTRE installer. Check out section 10.8 in the latest Talon SRX Software Reference Manual. When enabled, the output of PIDF represents a portion of a specified voltage, which is compared against the measured battery voltage, yielding a voltage-compensated duty cycle.