# Limit current of ESC by software

I am designing a cheap electric skateboard.

I have played around with various parameters for quite a while until I finally converged towards a specific motor and a specific battery. Lithium batteries are too expensive so I'm going for an AGM motorcycle battery. The problem is that the 0.025Ohm resistance of the motor leads to a huge current (hundreds of amps) up to 10km/hr which is most of my operational range. Other motors do not provide me with sufficient torque, therefore I need to include a current limiter to protect the ESC and maximise the battery capacity. For information, the continuous rating of the ESC I'm using is 60A.

I'm planning on measuring the current with a Hall Effect current sensor such as the Allegro modules out there, and an Arduino. Then map the current to a % of the duty cycle to subtract to the setpoint, before sending it to the ESC. For example, up to 30A => 0 feedback, 60A and above => 100% feedback, varying linearly in between. My gut feeling says it's basically a bang-bang controller which should be converging.

Any better alternatives?

• Torque is controlled only my average current. Acceleration is controlled by Torque, mass and friction. So the best fix to reduce slew rate on acceleration control or target velocity slew rate. Oct 24, 2016 at 17:32
• Have you verified that this motor gives you sufficient torque at 30A (or 60A)? Oct 24, 2016 at 17:33
• As you are fast with downvoting, consider again a~M~I. If you limit current, you limit momentum/torque you limit acceleration. There is no sense in using a powerful motor, then limiting its current. Overload the motor and the battery for a limited amount of time instead. Both parts have lots of mass and forgive temperature-restricted overloads. Oct 24, 2016 at 19:57
• Which motor, ESC, and battery do you have? Oct 24, 2016 at 23:30
• @Janka: You are fast with jumping to conclusions. I am not responsible for your downvote, actually everyone have been downvoted including me. Haters gonna hate :) I finally switched the motor for a less powerful one with a higher resistance (0.3Ohm instead of 0.03) such that the current at 0 speed and 12V is not too high. But I'm still interested in the answers. Oct 28, 2016 at 8:51

You are probably overthinking this.

First, as soon a DC motor is rotating, there is an internal voltage source which works against the outer voltage. Second, the rotor coil of a DC motor is fed an AC voltage because of the commutator, which means its inductivity adds a lot of additional resistance to the circuit, depending on speed.

So, overcurrent is only a problem at a standstill and very low speeds. The usual way to handle this is to have thermoswitches at all interesting points (battery too!) and thermofuses as a measure of last resort.

• I find your answer particularly interesting since I was considering the DC brushed motor equivalent model ignoring the inductance of the windings, and the AC nature of currents in the windings is going to make a difference => higher speed, higher frequency => higher drop across inductor => lower torque => torque ripple? +1 Oct 28, 2016 at 8:51
• In the usual model, the inductance of the rotor windings is accounted on: Ua=IaRa+ La dIa/dt +Uq. And yes, a DC motor with series excitation as commonly used for vehicle drives has lower torque at higher speeds because the excitation coil gets less current then. But that is both to account on the rotor impedance rising and the rotor voltage source working against the outer voltage. Oct 28, 2016 at 9:16

Although limiting the current by acceleration control as proposed by @Tony_Stewart should work up to a point, limiting or controlling the torque should provide better performance. With a DC motor, controlling current quite effectively controls torque. In engine powered vehicles, the throttle essentially controls torque by regulating fuel flow. That essentially provides torque controlled operation with an outer-loop acceleration and speed control implemented by observation and throttle control by the operator.

I would propose proportional control of current from 0 to 150% of the rated continuous safe operating motor current with an inverse time override for operation above rated motor current. The ESC should be selected to accommodate the maximum safe operating current of the motor.

The trick to solve this is to analyze the Motor DCR coil resistance to Battery ESR ratio and you will find LiPo is your best solution considering heat rise in the battery and RdsON switches is proportional to both ESR in battery and RdsON in MOSFETs.

Then limit the current by controlling the servo acceleration. F=ma and F is proportional to current so limit the acceleration , a and then current will be limited. This applies to both start and stop.

Servo systems need to be complex to handle a variety of inputs and desired response. Ultimately heat and temperature rise must be controlled and detected not just current or acceleration or velocity. But ultimately you want a smooth ride so the best control is power input and the limiting factor is temperature rise. But as in any engine without active cooling, if you do not anticipate the temperature rise you may have to wait for it to cool down when it overheats.

Therefore I still suggest acceleration control is the best for smooth operation and velocity limits will and thermal rise will occur according to demand and power dissipation.

Therefore you must have some thermal feedback to limit current*time product both which are proportional to temperature rise and not just current limit for brief instances.

As with any "underpowered" system you cannot get max power all the time nor would want it to spin wheels with constant current incase of loss of traction, so you need load sensing, thermal sensing, velocity sensing, and acceleration sensing for a smooth control.

You certainly wont get a complete design here either without requirements, which is your first obligation.

• I like your thinking here. But I've a thought that crosses my mind. The longer the chain of events enclosed within a closed loop control system, the longer the delay (which is probably the single most important factor in making control more difficult) and the more terms that may be needed to capture what's needed to get good control. So I worry a little about this approach, as much as I also like the idea of it.
– jonk
Oct 24, 2016 at 18:58
• Acceleration control won't limit current when load is variable, as it is in most applications and extremely so in this one. Oct 24, 2016 at 19:26
• Acceleration control effectively means current control. Because a~M~I Oct 24, 2016 at 19:52
• You can either assume constant load and have acceleration controlled Current or variable load with constant current and risk stalling. You can implement both but then compromise acceleration Oct 24, 2016 at 21:16
• The usual way to do it is having two regulating loops. The inner one controlling the current/torque by adjusting the terminal voltage, the outer one controlling the speed by adjusting the reference value for the current. Oct 28, 2016 at 11:13