smorgasbord
Well-Known Member
- Region
- USA
For the past few weeks I've been on a mission to finally get our Bafang Ultra motors (UART) tuned. I've learned a lot along the way, thanks to some posters here and to some reverse engineering. There have been several guides posted on the interwebs (old joke, sorry), which surprisingly have incorrect information. So, here's my attempt to note where these guides are wrong.
1. Karl Gesslein's I Void Warranties: Hacking The Bafang Ultra Max Mid-Drive EBike Drive
This is the first guide published, and it's been the basis for every other guide since - with its good and bad information repeated. Note that Gesslein first published a BBSxx guide that was based on a long Endless Sphere thread that contained a lot of top-notch reverse engineering. Gesslein himself did a bunch of reverse engineering for his Ultra guide, but appears to have run out of steam by the time he hit the Torque Tab. Here's where I believe he goes wrong:
2. Biktrix's Bafang Controller/PAS Programming Guide
It's perplexing to me that bicycle OEM Biktrix claims to have a "secret sauce" for Bafang Ultra firmware "hex codes" that they claim makes their Ultra motors better than any other Ultra motors, yet Biktrix's guide for user programming still contains several demonstrable errors:
In an EBR thread it is implied that Michael works for/at Frey, but that's not actually claimed in the guide. Furthermore, there's a couple of reviews of Frey bikes in other blog posts from Michael, which would seem to exclude that relationship. This is a popular EBR thread, and for years people have followed this guide and claimed wondrous results. However, it was my frustration with this guide that kept me searching for more and better information. Anyway, here's where I believe Michael gets it wrong:
This is a recent guide, which was originally based on Gesslein's guide (see above), but missed the Gesslein's Pedal Tab analysis (!), and then quickly revised after he received some comments pointing him at Michael's "Smooth" guide. Given his settings, it appears he didn't do much if any testing and so repeats the mistakes of those previous guides and then some. However, I should acknowledge that his advice on setting up the PAS Current %'s in the Basic tab is quite good and led me to a small variation of it for my post on the subject.
5. @ebikaholic's Youtube video How to Program Bafang Ultra Torque Settings
He references Gesslein's original guide, and the video does a good job showing how to setup the programming software and hardware.
What's been intellectually interesting about this voyage for me is how many people have played with these settings for so long, and yet find that they've "improved" things when their assumptions about what the settings control have been wrong. Whether that's because of a coincidences in gear selection to correspond low pedal cadence with low bike speed, or simply that the Spd100 column controls everything above 13 MPH (!) so it doesn't matter what the other columns were except in getting up to that speed, or some human perception thing (take the Selection Attention Test, it's fun!), I don't know. But, it's something to ponder.
BTW, for anyone who doubts me, it's quite easy to setup a SPD Table to prove my assertion on Wheel RPM for yourself. Just make MaxCur = MinCur for all columns except SPD40, then go for a ride in bottom gear and note the bike speed at which the power kicks on and off. Then do the same ride in top gear and see that despite a much slower pedal cadence, the power kicks on and off at exactly the same bike speeds. Then change Wheel Diameter in Basic (not the Display) and note the same bike speeds. Finally, set the number of magnets to 2 instead of one and (now you need to use an external GPS for bike speed) note the bike speeds are doubled for power on and off. Hence, the proof that it's Wheel RPM, not pedal cadence that the SPD table keys off of. You can repeat this for the other SPD columns, too, as I did.
If you somehow get different results than I have gotten, get in touch and we'll see if we have firmware version differences or something.
1. Karl Gesslein's I Void Warranties: Hacking The Bafang Ultra Max Mid-Drive EBike Drive
This is the first guide published, and it's been the basis for every other guide since - with its good and bad information repeated. Note that Gesslein first published a BBSxx guide that was based on a long Endless Sphere thread that contained a lot of top-notch reverse engineering. Gesslein himself did a bunch of reverse engineering for his Ultra guide, but appears to have run out of steam by the time he hit the Torque Tab. Here's where I believe he goes wrong:
- Basic Tab: Limit Spd(%)
- LimitedCurrent(A) value shown is halved in the Luna Ludicrous controller. This may have been true at the time but is no longer the case as my 2019 and 2020 (repaired/replaced by Luna in 2023) Ultra motors demonstrate.
- Torque Tab: Base Voltage
- Admits he doesn’t know what this does, but it's important for pedal torque response.
- Torque Tab: Delta Voltage
- Doesn’t mention calibrating for max voltage, which is important for pedal torque response.
- Torque Tab: 0 Speed Boost time
- Admits he doesn’t know what this does (It provides a power boost for when the pedal/wheels haven't turned (or turned much) yet.
- Torque Tab: Spd0-Spd100:
- Not only gets it wrong by claiming these are percents of the highest motor RPM, actually says that what is really is (bike speed/wheel rpm) is wrong!
- Torque Tab: MaxCur(%)
- Lowered these in an attempt to have a smooth take-off when he should have changed Delta Voltage table instead. A lower MaxCur won't make take-off smooth, it'll make it underpowered.
- Torque Tab: StarDegree
- Admits couldn’t find what changes to this affected. It's probably Start Degree and uses the hall effect system to know when the pedals have moved.
2. Biktrix's Bafang Controller/PAS Programming Guide
It's perplexing to me that bicycle OEM Biktrix claims to have a "secret sauce" for Bafang Ultra firmware "hex codes" that they claim makes their Ultra motors better than any other Ultra motors, yet Biktrix's guide for user programming still contains several demonstrable errors:
- Basic Tab: Limit Spd(%)
- This is not bicycle speed. For BBSXX motors it’s motor rpm, and that may be true for Ultra motors as well, but at any rate my testing ruled out road speed.
- Pedal Tab: Bottom 8 Parameters
- As Gesslein documented, these are almost certainly not used by the Ultra, yet values are given and described as having an effect on the Ultra. It’s not harmful to use their recommended values, but you don’t need to think about changing them.
- Throttle Handle Tab: Mode
- The description for Speed and Current Modes are exactly backwards!
- Torque Tab: Base Voltage
- Incorrect to suggest setting to 0. Should be set to the throttle voltage output when no pressure is put on the pedals.
- Torque Tab: Delta Voltage
- Has confusing wording, such as: "This value equals the increase from base voltage and lower values to equal force.” Although after thinking about it some more, I think it's right in concept with this example: "For example, if the base=700mV, 0-5kg=200mV and 5-10kg=200mV when tqVoltage=1100mV the controller will read 10kg of force on the pedal." At least if you interpret "read 10kg of force" as "output 10kg to the Spdxx table."
- Torque Tab: Spd0-Spd100
- Incorrect that the steps are percentage of full motor speed. They are Wheel RPM ranges.
- Torque Tab: MaxCur(%)
- Incorrect reference to RPM range of the motor.
In an EBR thread it is implied that Michael works for/at Frey, but that's not actually claimed in the guide. Furthermore, there's a couple of reviews of Frey bikes in other blog posts from Michael, which would seem to exclude that relationship. This is a popular EBR thread, and for years people have followed this guide and claimed wondrous results. However, it was my frustration with this guide that kept me searching for more and better information. Anyway, here's where I believe Michael gets it wrong:
- Basic Tab: Limit Current(%)
- Is not based on road speed, but on Motor rpm
- Basic Tab: Wheel Diameter (Inch)
- Will NOT affect speedo read-out as Ultra-compatible displays use their own wheel diameter/circumference settings
- Basic Tab: SpdMeterSignal
- Does not explain this correlates to number of magnets on the wheel with the external wheel rpm sensor
- Is probably incorrect that this “removes some lag in PA start up procedure.” To be fair, I don’t yet have proof of this yet, but if it were true then you might have to travel 2 meters before motor assist starts in some situations (depending on magnet location relative to sensor) and I've not experienced that myself.
- Pedal Tab: Bottom 8 Parameters
- As Gesslein documented, these are almost certainly not used by the Ultra, yet values are given and described as having an effect on the Ultra. It’s not harmful to use their recommended values, but you don’t need to think about changing them.
- Torque Tab: Base Voltage
- No explanation of what this should be set to, nor how to figure it out. The 740mV value shown is reasonable, however, and will give far better results than the 0 many bikes come with by default.
- Torque Tab: MinCur(%))
- Incorrectly describes that the values used are based on pedal cadence. They are based on Wheel RPM.
- Torque Tab: MacCur(%))
- Incorrectly describes that the values used are based on pedal cadence and/or motor RPM. They are based on Wheel rpm.
- Torque Tab: Delta Voltage table
- Does not describe what to do with the “load cell output” range.
- Incorrectly describes that setting 0-5Kg to a larger value will allow for ‘ghost pedaling.’ If anything, a larger value will require more pressure than the default linear value. Ghost pedaling is likely enabled by a very low Full and/or Return value, but I haven’t verified this.
- Has confusing explanations for how the Delta Voltage Table works, for instance: “For example, for the first 200mV load cell output, program will calculate as 0-5Kg load. If you are to change 200mV to 400mV, software will now calculate load of 0-5Kg over first 400mV. “
- Includes a value for Base Voltage without explanation of what that represents or how it was obtained. It's actually a reasonably good value for the Ultra motors I've tested and read about others testing.
- Overall, however, Michael's Delta Voltage Table values are reasonable and are probably why people like this tune. But, understanding this table is key to make the tune better for you.
- Torque Tab: Spd Table
- SPD0-SPD100: Representation of motor speed in percentage steps is incorrect. Again it's Wheel RPM and the numbers don't appear to correlate with anything I've found yet.
- Discussion of pedaling force versus pedal cadence is accurate and informative, but does not apply as written since the SPD table does not incorporate cadence as an input at all.
- Values Michael chose thinking they were pedal cadence are not necessarily valid for Wheel RPM.
This is a recent guide, which was originally based on Gesslein's guide (see above), but missed the Gesslein's Pedal Tab analysis (!), and then quickly revised after he received some comments pointing him at Michael's "Smooth" guide. Given his settings, it appears he didn't do much if any testing and so repeats the mistakes of those previous guides and then some. However, I should acknowledge that his advice on setting up the PAS Current %'s in the Basic tab is quite good and led me to a small variation of it for my post on the subject.
- Basic Tab: Limit Spd(%)
- This is NOT bicycle speed. For BBSXX motors it’s motor rpm, and that may be true for Ultra motors as well, but it’s definitely not bicycle speed per my testing.
- Pedal Tab: Bottom 8 Parameters
- As Gesslein documented, these are almost certainly not used by the Ultra, yet values are given and described as having an effect on the Ultra. It’s not harmful to use their recommended values, but you don’t need to think about changing them.
- Torque Tab: Base Voltage
- No explanation of what this should be set to, nor how to figure it out. The 740mV value cribbed from Michael’s value remains reasonable.
- Torque Tab: Delta Voltage
- Values shown sum up to exceed the maximum output of the Ultra’s torque sensor. This means that the maximum reported torque of 60Kg is reported at about a rider-applied 48Kg. So, the value he provides for 50-60Kg is actually ignored by the system!
- Values shown decrease by 5 for each of the 8 ranges, but he fails to recognize/accommodate that the lowest 4 ranges cover a 5Kg span while the upper 4 ranges cover 10Kg. Thus, the values do not produce the kind of curve the author claims.
- Torque Tab: Spd Table
- Repeats the incorrect claim that the 6 ranges are motor speed ranges and not bike speed ranges. They are actually Wheel RPM ranges, but that’s closely correlated to bike speed.
- Torque Tab: Full(Kg)
- Incorrectly describes what reducing the setting does, claiming that “toning it back” by reducing the values reduces the power output. In fact, reducing the values means that maximum power is produced at lower pedal pressures!
- Torque Tab: MaxCur(%)
- Again repeats the incorrect claim that Spd columns are based on motor speed.
5. @ebikaholic's Youtube video How to Program Bafang Ultra Torque Settings
He references Gesslein's original guide, and the video does a good job showing how to setup the programming software and hardware.
- Torque Tab: Delta Voltage Table
- Says to leave this alone, which is non-optimal as without setting the Base Voltage you get a jump in perceived applied pedal torque right at startup, the default table values mean you don't get the full range and don't get a progressive torque curve.
- Torque Tab: Spd Tab
- Is incorrect that this represents Motor RPM or Pedal RPM. These are Wheel RPM.
- This affects everything done in his table. His MinCur of 100 for fast bike speeds means he's basically at a abrupt On/Off throttle-like cadence sensing for any reasonable bike speeds (given he's on the road).
What's been intellectually interesting about this voyage for me is how many people have played with these settings for so long, and yet find that they've "improved" things when their assumptions about what the settings control have been wrong. Whether that's because of a coincidences in gear selection to correspond low pedal cadence with low bike speed, or simply that the Spd100 column controls everything above 13 MPH (!) so it doesn't matter what the other columns were except in getting up to that speed, or some human perception thing (take the Selection Attention Test, it's fun!), I don't know. But, it's something to ponder.
BTW, for anyone who doubts me, it's quite easy to setup a SPD Table to prove my assertion on Wheel RPM for yourself. Just make MaxCur = MinCur for all columns except SPD40, then go for a ride in bottom gear and note the bike speed at which the power kicks on and off. Then do the same ride in top gear and see that despite a much slower pedal cadence, the power kicks on and off at exactly the same bike speeds. Then change Wheel Diameter in Basic (not the Display) and note the same bike speeds. Finally, set the number of magnets to 2 instead of one and (now you need to use an external GPS for bike speed) note the bike speeds are doubled for power on and off. Hence, the proof that it's Wheel RPM, not pedal cadence that the SPD table keys off of. You can repeat this for the other SPD columns, too, as I did.
If you somehow get different results than I have gotten, get in touch and we'll see if we have firmware version differences or something.
Last edited: