TSDZ2 Programming - from scratch



     New/Alternate TSDZ2 Firmware versions can restrict changes from taking effect by the simple code modification outlined below. We now recommend uploading complete motor profiles instead of the manual modification. Here is a link to the program and data memory files for 36v, 48v, and 52v:


     Simply open the appropriate file under the corresponding tab (data memory and program memory) and then write to save, and you should be good to go! The above files will program your motor for high, but safe levels of amperage. Feel free to contact us with any questions, we are always happy to help.


Original Article:

 Programming the Tongsheng TSDZ2 is not near as user friendly as the Bafang BBS Series, but in a world of limited ebike/motors that is not going to stop us! There is little information out on this topic, so here is a breakdown of the process - from making the programming cable, installing and configuring the software, to changing the voltage and amperage values.

Preparing the Programming Cable

     To make a TSDZ2 programming cable, you need a speed sensor extension cable - not just a spare speed sensor, because not all the wires coming from the motor/controller speed sensor 6 pin connector are carried through to the sensor itself. The sensors themselves only utilize a couple wires, the remaining being for lights, and programming purposes. So, we must use the speed sensor extension cable, in order have all the available wires to tap into.

     Below is the speed sensor cable pinout, and a diagram showing the correct connection points for use with the ST-LINK V2. There are small wires and connectors included with the ST-LINK V2 kits that you can use to make the cable ‘plug and play’. Note as shown in the diagram below, you only will be using 4 of the 6 available wires.

Speed Sensor PINOUT:

green: headlight 6V – NOT USED

white: speed sensor input – NOT USED

brown: 5V (VCC) – split and connected at 2 points as shown in diagram

black: SWIM – connected as shown in diagram

orange: GROUND (GND) – connected as shown in diagram

purple: RESET (RST) – connected as shown in diagram

Speed Sensor to ST-LINK V2 Connection Points

Installing the ST-LINK V2 Software and Drivers, (for Windows)

     If you don’t already have the software/drivers installed from the ST-LINK V2 kit, then you can go to the address below for the ST Visual Programmer files: https://drive.google.com/open?id=1kfwc6R54bI2dubrXLtT2N5Rod3jWo6yp

If you are using Windows 7, 8, or 10, you will also need to download the folder https://drive.google.com/open?id=1u47wV3-g4PeRCuZhMP8_UhKqbDtBY0-9 and install the updated drivers within.

     Once you have the software and the correct drivers installed, you need to adjust the configuration. Open ST Visual Programmer, click ‘Configure’ in the Menu Bar, then click ‘Configure ST Visual Programmer’. Configure as follows – Hardware: ST-LINK || Port: USB || Programming Mode: SWIM || Device: STM8S105x4 (as seen in the screenshot below). Click the ‘OK’ button and you are now ready to program your TSDZ!

Programming your TSDZ2

  • Power off the TSDZ2, and connect it to the programming cable/ST-LINK V2. Plug the ST-LINK V2 into your computer’s USB port.
  • Open ‘ST Visual Programmer’  and you will see the screen below. All full of 00 00’s, and with 3 tabs – Program Memory, Data Memory, and Option Byte. The software will start in the ‘Program Memory’ tab, but the only place we are concerned with is ‘Data Memory’.

  • Open the DATA MEMORY tab and press the ‘READ’  button to read the current parameters set to your TSDZ2 Controller. You will notice the ’00 00’s populate with values, particularly on line 00004000, as seen below:

     The only values we are concerned with are on line 00004000 - the 2nd couple/set of numbers (5A in the above screenshot, which correspond to VOLTAGE), and the 3rd couple/set of numbers (14 in the above screenshot, which correspond to AMPERAGE).

  • Voltage is set as an Encoded Value (seen in the chart below). Some TSDZ2/Controllers will read values not on the chart below, but regardless of what they read, the values below will set the correct range for the Voltage they correspond to.













  • Amperage is set as the actual value, i.e.14 = 14 amps max, 17 = 17 amps max, etc. 10-18 MAX is recommended. Some TSDZ2/Controllers will read‘00’when they come from the factory which seems to default the power level. Regardless of what the previous value is, this is where you make the change to set your desired MAX AMP Setting.

     To be clear, the example screen above was programmed to 36v/14a while the example screen below is set to 52v/17a. See how the voltage corresponds to the values in the chart above, and the amperage is the actual value? We are not concerned with anything other than the 2nd and 3rd couples/sets of numbers on line 00004000, in the Data Memory Tab.

  • Change the Voltage and Amperage Values as Desired (as described above), then press the ‘WRITE’  button to write the new parameters to your TSDZ2 Controller.

     That’s it! It is recommended to close and reopen ST Visual Programmer, and re-read the settings, to ensure your changes did in fact ‘write’. If so - then it’s time to test the new settings! If you ever have a problem reading/writing/connecting etc… make sure you double check the connections on the ST-LINK V2, sometimes the split VCC/5v wire can slip off the ST-LINK V2 body. If that is not the issue, make sure you have installed the correct drivers, and that you have configured the ST-LINK V2 as described above.


If you need further assistance, feel free to message support@eco-ebike.com


Leave a comment

Please note, comments must be approved before they are published