About the project

  1. about this documentation in HTML
  2. License


  1. BMSBattery S06x
    1. LCD control panel
      1. LCD protocol
    2. S06S
      1. PWM signals
        1. very low speed - 6 steps
        2. low speed up to max speed - sineware
    3. S06P
      1. various info
        1. 01
        2. 02
  2. BMSBattery S12S
  3. BMSBattery bottle battery controller
  4. GreenEBikeKit
  5. Kunteng 18 mosfets

Datasheets and application notes

  1. STM8S105C6T6
    1. Interrupts
  2. Alternatives

Development tools

  1. STLinkV2 - Flash/program/debug hardware
  2. Flash and debug connector on S Series controller
  3. Debug OpenOCD and Eclipse
    1. stm8-binutils-gdb
  4. Flash programming
  5. C library
  6. Various resources
    1. Printf example

Motor control

  1. Motor control scheme of S06S controller
  2. BLDC 6 steps
  3. PWM schemes
    1. So, Which PWM Technique is Best? (Part 1)
    2. So, Which PWM Technique is Best? (Part 2)
    3. So, Which PWM Technique is Best? (Part 3)
    4. So, Which PWM Technique is Best? (Part 4)
    5. So, Which PWM Technique is Best? (Part 5)
    6. So, Which PWM Technique is Best? (Part 6)
    7. So, Which PWM Technique is Best? (Part 7)
  4. PWM control and Dead Time Insertion
  5. Low inductance motors
  6. Throttle Control Modes


  1. forum messages
    1. 2017.04.25 - Initial forum message
    2. 2017.05.08 - First flash and debug on a dev board
    3. 2017.05.18 - First code flashing and running
    4. 2017.05.20 - more new information
  2. How to unlock proteced read memory
  3. STM8S003 board
  4. LOG
    1. 2017.06.19 - SVM current waveforms


  1. 2017.05.22 - Hackaday Links: May 21, 2017

Smart BMS with bluetooth

Throttle Control Modes

Forum message discussing Throttle Control Modes:

by Altair » Tue Mar 15, 2016 10:37 am
In this post, I want to have a look at the existing throttle modes and maybe examine the need for a different one.

RPM mode:
Everyone is familiar with the Speed mode where the position of the throttle controls directly the RPM of the motor. This is done internally by Pulse Width Modulating the signal going to the motor, effectively varying the voltage applied to the phases of the motor. The motor tries to follow the speed commanded by the throttle, within its torque limits, of course.
With this mode, the throttle feels more like a switch than a throttle because tries hard to match each new position of the throttle, resulting in constant small accelerations & decelerations.

TORQUE mode:
The common Torque mode that everyone prefers works by controlling the current going to the motor, rather than the voltage. It controls in fact the strength of the motor.
The throttle commands a certain torque, and then the resulting RPM is dependent of the load that the motor has to work against. If there is a very small load as when you're on flat ground with a tail wind, the bike will gain speed more and more even if the throttle is almost closed. This is sometimes not fun because you have to close completely the throttle from time to time to try to maintain a constant speed.
In the torque mode with the throttle just cracked open, the motor will end up reaching its maximum RPM if there is no load on the rear wheel.

POWER mode:
With all our (internal-combustion-engined) cars and motorcycles, it is very easy to maintain a chosen speed, easier that with our electronic controllers, and the reason is that in addition to being primarily torque-based, the throttle also controls the RPM of the engine when there is little load on the wheels. Like for example, with the transmission in neutral, the engine doesn't keep increasing its RPM until it reaches the max.
So the automotive throttle seems to be mostly a torque control, but at lower position, it integrates a form of RPM control. It facilitates the control of vehicle speed. This type of control feels the most natural to me, anyway.

Would it be worthwhile to try to integrate this form of control in our controllers?
It probably already exists, maybe in the Kelly controllers. From the comments I've read, the throttle mode used is not of the torque mode ("not a true torque mode but it feels good") but there is no details given in their specs.


by Alan B » Wed Mar 16, 2016 8:41 am
The standard Throttle to PWM mode that most controllers use is open-loop. Nice and simple. With a clamp to limit battery current and a calculated estimate of phase current. I call this PWM Throttle to differentiate it from a true Speed Mode.

Speed Mode is a bit different, as it is closed loop, like throttle adjusted cruise control. It is similar to PWM throttle, but even more annoying. Not sure who would want that mode. The Cycle Analyst has it, though I've not tested it.

The CA mode I've used is Battery Current mode. This is an improvement over PWM throttle, but at low speeds only a part of the throttle range is useful since current multiplication causes the motor current to hit the limit at a low throttle setting like 20%. Still it gives better control than the traditional PWM Throttle.

Power Control feedback throttle in the CA is almost the same as Battery Current, except they feed back on voltage times current. So it compensates for sagging pack voltage, as was mentioned above. Not a very different user experience unless your pack sags significantly.

Most of the sinewave controllers have torque throttle, which is easier for them since they need to measure motor current as part of the sinewave control algorithm. Sevcon, Sabvoton and the BAC series that is experimenting with are examples of these.

Some high end controllers have "torque plus speed" control. This would probably be close to an ICE throttle. I think Sevcon has this, but the programming is reportedly complicated. I haven't tried programming a Sevcon myself.

It is better to put these algorithms inside the controller, but the commodity controllers don't seem to be moving in that direction, so making an external adapter to achieve this is common, hence the CAv3 or Throttle Tamer, among others.

I have ridden the Zero motorcycles most of which which have a Sevcon based torque throttle, and I have a Sabvoton controller on the Borg which has a torque throttle in the controller, plus the various CA setups that I have used, plus the Bafang BBSHD has a torque throttle simulation in the controller that works fairly well. While I do see the "unloaded accelerate to max speed" when testing with the wheel off the ground characteristic of the torque throttles, in real conditions this is rarely noticed. Riding on ice or doing large jumps would be cases where it might be noticed. Possibly in extremely slippery mud. But generally it does not happen when there is any loading on the motor, and the control experience is greatly enhanced over the default PWM throttle control.

I've been looking at the motor control equations and it appears that a torque control adapter for PWM throttle controllers is possible without a motor current sensor. To do so requires incorporating the control parameters for the motor into the algorithm. I plan to test this out soon with a prototype for my AWD Novara Mountain Bike setup. If it works out perhaps we'll have something of general interest to report.

I've always been interested in the "torque plus speed" throttle mode, so will probably try that as well. It should take a very few lines of code to add that to a torque throttle.


by Alan B » Thu Mar 17, 2016 12:01 am
Hi Folks.

Thanks for the comments. Trying to explain it clarifies it, a good exercise to work through.

There is no perfect throttle curve. That's the wrong way to think about the system. It is a moving target.

RPM is needed to adjust the mapping dynamically. Think of it this way. There are two components of voltage in the motor. One is back EMF and the other is driving heat and making torque. Back EMF is related to RPM. So if you know the RPM you can calculate the back EMF component of the effective motor voltage.

Let's take the case of a stalled motor. Not turning. This makes zero back EMF. So we can ignore that for a minute and explore the torque production mechanism. Then we'll add the motion part back and deal with that.

If you know the resistance of the motor (and wires, etc), you can calculate the voltage required for any motor current (we ignore inductance here). Let's pick 100 milli ohms of resistance to make it easy. If we put 1V on this motor we'll get 10 amps. If we put 10 volts on this motor we'll get 100 amps (which we'll assume is our max motor phase current). So we have a nice torque throttle from 0 to 10 volts.

If the battery is say 50 volts, and we have a standard PWM controller we'll only get useful torque control from zero to 20 percent of throttle which makes the 10 volts (at zero speed). Then the controller should not allow the PWM to go above 10V since it is (we hope) correctly estimating or measuring motor current and 100 amps is our limit.

So we have a nice torque throttle at zero RPM, at least from 0 to 20% of throttle, and a mapping could be made to spread that out over the whole throttle, but of course the torque makes things move, and that mapping would not allow us to get to full speed. But, as long as we know the back EMF for the present RPM we can just add that to the voltage we need for the torque we want and make the PWM for that (which is the voltage we send to the controller's PWM throttle input). So the 10 volts of torque control range just moves up the voltage scale as the speed goes up. If the back EMF at some speed is 15 volts, we want to output PWM for 15 to 25 volts to the motor (at that speed) for the full throttle torque control range. If this is constantly updated as the speed changes it will simulate a torque throttle.

There are complications like resistance changing as the motor heats, and knowing the back EMF versus speed accurately enough and so on, but you get the idea. How well this works will have to be tested to see if these other details are significant enough to matter much, or if we can put them into the manager's equations and have it make those adjustments too.

Does this make sense? I know it is a bit confusing.


images/58-1.pngby Alan B » Thu Mar 17, 2016 12:34 am
Torque plus Speed is a bit different - it is a torque throttle that has a speed limit. So a 50% throttle setting would produce 50% torque but only up to 50% speed. So it is a way of controlling speed when the torque loading gets very low. Kind of like and ICE throttle.