# Voltage Limiting

I was reading a thread on CD and someone said that in addition to current limiting, you can also voltage limit motors. I know I can use talon to current limit but how do I implement voltage limiting?

It will help to know what language you are using.

Java

Sure you can. Just never allow the motors to go above some output percentage in code.

Except, as the battery changes your output changes. You’ll need to scale it by using the current battery voltage versus some “nominal” value to prevent that. There is a talon-srx built in voltage limiting feature that we used extensively in LabView last year. Unfortunately I don’t know what the java version of that is - it was part of the CTRE library of vi’s.

I don’t think that voltage limits are a natively supported feature in the same way that current limits are. I would say the easiest workaround would likely be to enable voltage compensation with

``````talon.configVoltageCompSaturation(double voltage, int timeoutMs);
talon.EnableVoltageCompensation(true);
``````

And then programmatically limit your voltage by never sending a command above your voltage limit.

EDIT: actually you should set the “voltage” argument to your desired voltage limit, then your commands -1 to 1 are scaled with respect to that. So I think if you set

``````talon.configVoltageCompSaturation(6,10);
talon.EnableVoltageCompensation(true);
``````

commanding 0.5 in PercentOutput control mode would output 3V, commanding 1 would output 6V etc. I can’t test that right now but I suspect that this is what you’d want. That would work as a voltage limit I think.

As someone who knows almost nothing about motors, do motors have a constant resistance? Can you just do a current limit with V = IR applied?

Somewhat.

The current will be a function of the difference between the applied voltage and the back-emf voltage. So, you need to know the back-emf voltage to calculate the current limit voltage. Once you know the back-emf, V=IR still applies, but the resistance does have a temperature dependency. However, R will increase with temperature, so your current limit will become more conservative as the motor heats up.

Due to a brush DC motor’s back EMF and the motor coil’s impedance characteristics the motor coil’s resistance at rest will not work without considering the phase angles in the quantities making them no longer simple decimal numbers but complex numbers (polar or imaginary notation) and those precise numbers at any given moment would best be estimated with calculus.

Here’s some information on modelling a DC brush motor for a simulation:
https://www.mathworks.com/help/physmod/sps/ref/dcmotor.html;jsessionid=a8d49c7f6a2d85fbf2354faf1332

Inductors and capacitors have a quality called impedance which has a real element we think of as resistance but a complex quantity induced by the way a coil’s magnetic properties work, or a capacitor’s storage of energy works. We say current leads the voltage with capacitors, or voltage leads the current with coils. This relationship would become very clear if you test either compentent with an oscilloscope outfitted with 2 channels one measuring voltage and the other measuring current (using a current probe if you can). You’ll see the leading/lagging very clearly.

There is an option to configure the peak output of the TalonSRX in terms of the percent output.

``````
configPeakOutputForward(percentForward, timeoutMs)
configPeakOutputReverse(percentReverse, timeoutMs)

``````

With voltage compensation enabled, this function can easily be used to set a voltage limit. The peak output forward ensures that the TalonSRX never commands a percent output above the limit and the peak output reverse ensures that the TalonSRX never commands a percent output below that limit.

Edit [Clarification]: This capping of output is effective in all control modes.

OP, FYI, there’s a lot of folks around here who have done some pretty advanced work into the nature of various limiting strategies for electrical & physical values on motors. If you’re willing to share, do you have an end goal in mind? The community here may have some good suggestions to guide you!

Not really tbh. We got some 775pros for next season so just making sure we keep our chances of burnin them out the lowest possible