• Hello ES! We could use some help to get us past the finish line on building the new knowledgebase for the forum.
    Can you donate? Please see our fundraising page. Thank you!

TSDZ2 OSF for all displays, VLCD5-VLCD6-XH18, LCD3, 860C-850C-SW102.

No, that's not the case.
When the lights are turned on, the data is displayed sequentially, for the time set for each piece of data.
If you set a time to zero, that piece of data is displayed continuously and the sequence is interrupted.
You probably set the "Data 1" time to zero.
If you want to see the next piece of data, the time must be different from zero, max 250 (25 seconds).
You also need to understand the system's limitations.
Setting a high number of data is fine for values that change slowly (temperature, voltage, used Wh) and with short display times.
But if the data changes quickly (cadence, power, current) and is displayed over long periods of time, you'll end up no longer knowing which piece of data you're looking at.
That's why, to display cadence, I recommended displaying just one piece of data.

Yes, above 80 rpm the power starts to decrease; that's normal.
It may even drop to 100/150 W if the cadence is very high, above 100 rpm at 18 kHz and 110 rpm at 19 kHz, and further increasing the cadence will cause the power to drop to zero.

Keep in mind that pedal pressure also affects power; the force applied at 100 rpm is less than at 80 rpm, even if it feels the same to you.
At those speeds, you're definitely pedaling on flat ground, and it's easy to exceed the cadence limit beyond which you lose power.
I've seen 300 W at 110 rpm, but in different conditions, a very steep climb and a low gear.

If you need more speed and you ride mostly on flat ground, choose a larger chainring, but if you ride a lot of hills, stick with the 34T chainring and settle for 27 km/h. The motor will heat up less and last longer.
I find it strange to only reach 27 km/h with a 34T chainring, I have a 30T chainring and 29" wheels, at 80 rpm I reach 28 km/h, you probably have smaller wheels.
May be an idea, go back to page 113 when I was messing with my 48V TSDZ2B "but as the torque sensor seemed a bit limp or I am just a light weight, I increased by 20% the Power and Torque Assist Mode values to give me the same feel as on my other bike, did not want a this point in time to open the TSDZ2B up and mess with the torque sensor, know what load cell elements are like" I have put the screen shots there and no I did not a calibration, been fine since January.
Thank you for the information. Now I understand everything.
Recently, my son and I did some testing with the bike, and he says the support with OSF is much better than it was at the beginning with the original setup and the original 42T chainring in the front.
We're riding with a 34T front chainring, and the speed on flat terrain is about 25–27 km/h. The 34T chainring in the front has to stay because it allows him to ride in the mountains.

I'm considering adding a second chainring in the front and modifying the front derailleur so he can switch from 34T to 40T (or 38T) when there’s a lot of asphalt and flat terrain.

Thank you very much for taking the time to answer my questions and provide explanations, and for developing OSF. Much respect to you all.

Best regards, and I wish you all the best.
 
  • Like
Reactions: dgc
Finally!! Thank you!! It was a ground problem! It flashed no problem.
Hi sorry for replying to an old comment but I'm having a similar issue to you. I tried all different kinds of firmware. Sometimes when I powered on display it would die and instantly switch off if I let go of power. Sometimes I stays in but won't get past the splash screen. Earlier, when you said it flashed successfully but you were having issues, did U get 100% complete in apt burn so you believed it was a successful flash? I'm thinking I have the same problem. I made my own bootloader box and use UART comm on my jtlink with a buck converter to increase voltage. I can't power on display while connected it doesn't supply enough power (display flashes) but it successfully flashes apparently. If I use power from a usb charger plug display turns on but then it won't start the flash...also where you " connected ground" was this something inside the display? Or while you were flashing
 
If there's no longer support, it's not a calibration issue.
Have you tried disabling "Set max speed from display"?
Mbrusa
I have found that limiting the wattage power selection for street mode to 300W also limits the power for off road etc to 300W
tried it on several TSDZ2 bikes , firmware TSDZ2-v20.1C.6-update-3.
|Used a power meter .
Only found out because I lend my bikes out and want to restrict power to 300 when on streets
I tried re-flashing the controller with factory original ( worked ok ) and then flashing osf but same thing
 
Last edited:
Do you mean the power limit in Street mode also limits power in Offroad mode?
Are you sure you're testing it in Offroad mode as well?
I think you're still testing in Street mode.
 
Do you mean the power limit in Street mode also limits power in Offroad mode?
Are you sure you're testing it in Offroad mode as well?
I think you're still testing in Street mode.
Yes absolutely sure that I'm enabling "off road" , the only thing it could be is that I'm using the DZ40 display's on all my bikes but they were switching lights ok before ,
I'll install a VLCD5 back on one and try again tomorrow
 
Hie,
My previous code was buggy it worked (somehow but not as it should) only by chance! A lot of work and test later, it works fine this time...

it's a modification for cadence of mbrusa firmware. It can be adapt to others mode i presume.

Cadence Punch and Sliding Power Control

🎯 Purpose​

The firmware adds a “punch” feature: a short boost of assistance when you suddenly accelerate your pedaling cadence or apply strong torque. This makes the bike feel more responsive in traffic or when restarting, while still staying within legal limits thanks to a sliding average power limiter.


🔹 Punch Trigger​

The punch can be activated in two ways:

  1. Cadence acceleration
    • The controller compares the average cadence over ~0.75 s (WINDOW_PAST) with the average over ~0.3 s (WINDOW_CURRENT).
    • If the short‑term cadence is at least +3% higher (punch_threshold_percent = 103) and above 50 rpm (punch_cadence_floor), the punch is triggered.
  2. High pedal torque
    • If the pedal torque ADC value exceeds a threshold (TORQUE_PUNCH_THRESHOLD = 220), the punch is also triggered, even without cadence acceleration.

🔹 Punch Duration and Intensity​

  • punch_duration[] → defines how long the punch lasts depending on assist level (e.g. 3 s in ECO, 10 s in TURBO).
  • punch_coef_x100[] → defines the intensity multiplier (e.g. 110 = +10% in ECO, 125 = +25% in TURBO).
  • PUNCH_RAMPDOWN_SEC → smooth ramp‑down time after punch (default 2 s).
  • PUNCH_COOLDOWN_SEC → minimum cooldown before another punch can trigger (default 3 s).
  • rampdown_steps → number of steps for the ramp‑down smoothing (default 20).

🔹 Sliding Power Control (Street Compliance)​

To remain legal, the firmware continuously monitors average power over 2 minutes:

  • POWER_BUFFER_SIZE = 120 → 120 samples at 1 Hz = 2 minutes.
  • THRESHOLD_REDUCE = 80 → if average power > 80% of Street limit, punch is reduced (shorter).
  • THRESHOLD_BLOCK = 92 → if average power > 92% of Street limit, punch is blocked.
  • STREET_MODE_POWER_LIMIT → defines the legal Street limit (e.g. 290 W for me because it give less than 250W on shaft of motor<250W legal).
👉 Even if the punch temporarily boosts power, the 2‑minute sliding average ensures the motor never exceeds the legal Street limit in sustained use (250W on the shaft is legal limit for everage power).


✅ Summary​

  • Punch = short boost triggered by cadence acceleration or high torque, only above a minimum cadence.
  • Duration and strength are set by punch_duration[] and punch_coef_x100[].
  • Ramp‑down and cooldown make the punch smooth and predictable.
  • A 2‑minute sliding power limiter ensures the bike always respects the Street power limit, so the assistance never exceeds what is legally allowed.

⚖️ Legal Compliance​

For legal reasons, the firmware always enforces the Street power limit. Even if punch temporarily boosts assistance (by torque or cadence), the 2‑minute sliding average is capped at STREET_MODE_POWER_LIMIT.

  • If the average approaches the limit, punch is reduced or blocked.
  • This ensures the motor never exceeds the legal Street assistance limit in sustained use.
  • Offroad mode is only used internally during punch, but the controller automatically returns to Street mode afterwards.

----------------------------------------------------------------------------------------------------------------------------------
The parameters:

1. Punch Trigger (cadence and torque)​

  • punch_cadence_floor Minimum cadence (in RPM) required before punch can trigger.Example: 50 → punch only works above 50 rpm.
  • punch_threshold_percent Relative cadence increase threshold (in %) over a short window.Example: 103 → punch triggers if cadence rises by +3% within ~300 ms.
  • TORQUE_PUNCH_THRESHOLD Torque ADC threshold. If pedal torque exceeds this value, punch can also trigger.Example: 220.
  • WINDOW_CURRENT / WINDOW_PAST Defines the averaging windows for cadence detection.
    • WINDOW_CURRENT = 12 (~300 ms)
    • WINDOW_PAST = 30 (~750 ms)The firmware compares the short‑term average (avg_cur) with the longer one (avg_past) to detect acceleration.

2. Punch Duration and Intensity​

  • punch_duration[] Duration of punch per assist level (OFF, ECO, TOUR, SPORT, TURBO).Example: 3 s in ECO, 10 s in TURBO.
  • punch_coef_x100[] Multiplicative factor applied during punch (x100).Example: 110 = +10% in ECO, 125 = +25% in TURBO.
  • PUNCH_RAMPDOWN_SEC Time for smooth ramp‑down after punch (default 2 s).
  • PUNCH_COOLDOWN_SEC Minimum cooldown before punch can trigger again (default 3 s).
  • rampdown_steps Number of steps for ramp‑down smoothing (default 20).

3. Sliding Power Control (Street compliance)​

  • POWER_BUFFER_SIZE Size of the rolling buffer for average power (default 120 → 2 minutes).
  • POWER_SAMPLE_CYCLES Sampling rate (40 cycles = 1 s).
  • THRESHOLD_REDUCE / THRESHOLD_BLOCK Percentage thresholds of the Street power limit:
    • Below 80% → punch allowed.
    • Between 80–92% → punch reduced (shorter duration).
    • Above 92% → punch blocked.
  • STREET_MODE_POWER_LIMIT Legal Street power limit (e.g. 250 W).The firmware computes a 2‑minute sliding average of power and ensures it never exceeds this value.
 

Attachments

  • ebike_app.c
    145.6 KB · Views: 2
Last edited:
Yes absolutely sure that I'm enabling "off road" , the only thing it could be is that I'm using the DZ40 display's on all my bikes but they were switching lights ok before ,
I'll install a VLCD5 back on one and try again tomorrow
My apologies it's apparently something to do with the DZ40 as everything works as expected with the VLCD5
 
Update released for stock displays.
Change List v20.1C.6-update-4

1 - Fixed bug in overcurrent delay (E07 error).
There have been reports of unwanted E07 overcurrent triggering. I suggested increasing the delay time, but it didn't work; due to a bug, the delay was always at the minimum.
Fixed.

2 - Calculating SOC voltage with battery pack resistance.
In previous versions, to ensure a fluctuation-free display of the SOC bars, the last measured voltage value without current draw was used.
However, there was a drawback: if you never stopped pedaling on a long climb, the SOC bars would only be updated at the end, when you stopped pedaling.
Now, real-time voltage is used, and to obtain a stable value, the voltage drop in the battery is added, as on the 860C.
However, it is necessary to enter the battery pack resistance in the configurator. Read the manual carefully.

3 - Added power-on current check (E05 shared with THROTTLE error).
This is why I added this check.
I happened to remove the battery without turning off the display (860C). When I turned it back on, the bike started on its own; I barely had time to hold it, lift the rear wheel, and turn off the display; the data memory had been corrupted.
This is a dangerous situation.
Now, if for any reason the motor starts unexpectedly when the display is turned on, the motor immediately shuts down, displaying error E05.

4 - Restored old parameters.
I've also been told that, with the same level multipliers, there has been a decrease in assistance compared to the 2.x versions, mainly in hybrid mode.
As a precaution, I had changed two parameters; I have now restored the previous values.
 
Update released for stock displays.
Change List v20.1C.6-update-4


4 - Restored old parameters.
I've also been told that, with the same level multipliers, there has been a decrease in assistance compared to the 2.x versions, mainly in hybrid mode.
As a precaution, I had changed two parameters; I have now restored the previous values.
I was one of the hybrid owners who had found earlier versions of 1.C.6 not as strong, a;though putting the te0 and te1 numbers into the torque sensor calibration improved performance.

Loaded up 1.C.6.4 this morning with the torque sensor calibration numbers, I'm getting enough assist now, Thank you.

Is it my imagination, or is the motor quieter and smoother?
 
I've just tried the latest 6-update-4 and I definitely notice an improvement, so well done mbrusa :D

I use hybrid mode as my default and left all my other settings as they were. I found the motor was more sensitive to pedal input and the pick-up smoother and quicker. I normally only use levels 1 and 2 and both of these seemed to be more responsive.

Like many other forum members, I'm most grateful for all the effort put in by mbrusa (and others) in making significant enhancements to the TSDZ2B motor.
 
Aha. I finally realized how to read the two torque sensor values off the VLDC5 with OSF! I realized it was the top line that contained the values but I ha been watching the lower line., The numbers were close to what I had entered.

I was unable to get the display to calibrate the ADC conversion but I had disabled the estimated calibration button. Will get that next time I reprogram.
 
Hi everyone. I don't know if I can ask this here so as not to create confusion, but if you tell me this is the wrong thread, I'll delete the post. I want to modify my wife's bike from a standard MTB to an ebike. I'm debating between the tsdz2b and the tsdz8. My concern is the tsdz8's weight. On Ali, it says it weighs around 5.8kg, which is over 1.2kg more than the tsdz2b. And most importantly, can I install OSF on any tsdz8 I buy? Or do I have to buy an "older tsdz8"? I don't want to have problems later with being unable to install OSF.
Thank you.
 
Hi everyone. I don't know if I can ask this here so as not to create confusion, but if you tell me this is the wrong thread, I'll delete the post. I want to modify my wife's bike from a standard MTB to an ebike. I'm debating between the tsdz2b and the tsdz8. My concern is the tsdz8's weight.

What is the intended use? Is it for you or your wife. How and where will it be used. Weight of target bike? If weight matters, I guess you are taking the bike out into the fields and forests,

Commercial electric mountain bikes are not light, and come with speed restriction. If you're a good builder and choose a lighter frame, I think you can have at least the same power, probably more speed as a store bought bike for a lot less money and probably not much difference in weight. Think of it in those terms.
 
I'm far from an expert on Tongshen motors or the OSF, but my understanding is:

The TSDZ8 is a more powerful, robust motor which has addressed / resolved the key deficiencies of the TSDZ2B - cooling, axle breakage and so on. Electric assist tends to cancel out any weight penalty, so I'd not be overly concerned about an extra 1.2 kilos. The comment above from docw009 about weight is relevant however if you are planning to go off-road to any extent.

I don't know what limitations there are on the installation of OSF on the TSDZ8, but I believe it can be done. The TSDZ8 is a newer motor, so development or refinement of OSF is perhaps less mature than that for the TSDZ2B?

On my own TSDZ2B I have added additional cooling, have installed extra bearings on each end of the axle shaft and have flashed with the latest version of OSF. My motor is on a tandem bicycle and it was fitted to give some extra help on the hills or into headwinds. I normally only use power levels 1 or 2. It is far from being an electric motorcycle, it just adds a little bit of assistance when needed.
 
i ported punch feature for all assist mode.

works on cadence mode.

If someone wants to test it on others modes.... please tell me if tit works or not!

warning: if you want to stay legal set 25 km/h in offroad mode
while punching, motor will use offroad parameters (ie offroad power)
everage power will stay in street limit but if offroad power is too high motor can over heat.

my motor is 250W/350W rated. i setted offroad to 400W and not more to be safe.

with the punch your firmware will stay in street mode even if you try to set offroad from lcd!

so test your favorite mode and tell me if it works !

Note: you should adjust in code

static uint8_t punch_threshold_percent = 103; // +3% to get punch
this definie how easy it is to get punch from rpm increase

#define TORQUE_PUNCH_THRESHOLD 220 // seuil ADC torque

this define how hard it is to get punch (rpm increase OR absolute torque car give you punch).
Higher value = harder to get. For me 220 is about 19kg on shaft.

Note: don't set minimal RPM less than 40 or 50 or it will stress transmission.
 

Attachments

  • ebike_app.c
    147 KB · Views: 4
Last edited:
Hey,
i bought the dz40 .. but with the wrong connectors :rolleyes:. itś the one compatible with bafang...

Does anyone know if it is possible to solder the vlcd5 cable? Can I use the color coding of the cables as a guide, or is that rather pointless?
Thanks!
 
...
i bought the dz40 .. but with the wrong connectors :rolleyes:. itś the one compatible with bafang...
....
A Bafang display must be flashed just like with the Bafang 860C.
This requires firmware, which isn't currently available for the DZ40
 
A Bafang display must be flashed just like with the Bafang 860C.
This requires firmware, which isn't currently available for the DZ40
Ok, so they dont just differ in the connectors. They actually have different software on the display?
 
Google AI mode says this....
Yes, the TSDZ2B motor works with the DZ40 display
, as many vendors sell them as a compatible kit. While some displays are branded for other motors (like Bafang), a version of the DZ40 exists specifically for Tongsheng motors, often called the DZ40_TSE. You will need the correct 6-pin cable for the TSDZ2B motor, as Tongsheng and Bafang motors use different communication protocols.

There is a Varstrom option to have a TSDZ2B shipped with a DZ240, but it's not sold as a separate item. Contact them and ask if you can buy the display., You would still have to wire it, so ask to buy the cable harness too, Then you might need throttle/brakes if you don't like rewiring projects.
 
Last edited:
Not sure if someone can replicate this but on Firmware open source v20.1C.6-update-4 with VLCD6 when I turn on the lights, the odometer just shows 0 km/h until I reach more than ~22-23 km/h then it works again (also works again with less km/h).
I have this also when going into offroad mode with light on/off button. In each case, when the light is or was on, the odometer stays at zero until it reaches a certain km/h. Never had this before in the older OSF.
 
If you enabled data display when the lights are turned on, the speed is replaced by the value of the first data (SOC%) for the set display data time. The speed only returns at the end of the time.
However, there's a problem. I've already had a couple of reports that SOC% doesn't work with VLCD6; below 80, it displays zero. The same applies to your case.
I still have to figure out why.
Unfortunately, I don't have this display. I tried setting VLCD6 in the configurator, but using XH18 works fine.
If I can't replicate the problem, it becomes difficult to solve.

Try setting "SOC% Calculation" to Wh and let me know if it works. Thanks.
 
Display data when the lights are turned on was off. But it's true, it has nothing to do with speed, but rather with the time it takes until it finally displays values again.
Today I had the opportunity to test it with SOC Calculation set to Wh. Strangely enough, it worked perfectly when I first turned it on (I switched on the light and it only took ~1 second for the values to be displayed again). Then I parked the bike and turned it off. After the second test and turning motor on again, on the way back, it stopped working again. Lights on, no values displayed for ~30 seconds. Display data when lights are turned on is still deactivated in java configurator.
 
Back
Top