Skip to content

dzid26/TSDZ2-Smart-EBike

 
 

Repository files navigation

GitHub issues Build Action

This repository is updated by mbrusa.

This fork is based on the TSDZ2-v0.20beta1 adapted for Tongsheng protocol displays, like stock VLCD5, VLCD6, XH18 or other displays with the same protocol and 6-pin Tonsheng connector, SW102, DZ41, 850C or 860C for TSDZ2. With these last displays, the visualization of data and errors must be checked..

Endless Sphere forum reference thread: endless-sphere.com..

See the wiki for instructions

This ebike motor controller firmware project is to be used with the Tongsheng TSDZ2 mid drive motor. Note: firmware can't be written to Enerdan sold TSDZ2 motors and controllers because they are equipped with V2 controller and XMC1300 microprocessor instead of STM8.

It has the following benefits compared to the stock firmware:

  • The motor runs more efficient therefore it becomes more powerful and consumes less energy.
  • The ebike will feel more responsive and agile.
  • Using other supported displays and pheriperals will provide more functionality and features.
  • Because this project is in heavy development more features will be added.

This project is being developed and maintained for free by a community of users. Some of them are developers who work professionally developing this type of technology for very well known companies.

Building and flashing with Java tool

Windows

  • Install SDCC. version 4.1.0 or higher required.
  • Install ST Visual Development.
  • Install Java.
  • Open JavaConfigurator.jar customize the parameters and click Compile & Flash
  • Or use supplied .bat scripts, e.g. src/compile_and_flash.bat
  • With 32-bit Windows systems, replace the files in the \tools\cygwin\bin folder with those in the bin_32.zip file

Linux and MacOS

  • Install SDCC. version 4.1.0 or higher required.
  • Install Stm8flash git clone https://github.com/vdudouyt/stm8flash.git && cd stm8flash && make && sudo make install
  • Install Java.
  • Open JavaConfigurator.jar customize the parameters and click Compile & Flash
  • And/Or use supplied shell script compile_and_flash_20.sh

For more information, go to the wiki instructions.

Development / contributing

Setup

  1. Clone this repository
  2. Install the SDCC compiler

Debugging

  • You can do cd src & make -j4, import elf into STMStdudio and plot global variables in real-time
  • Or use VScode and one of the debugging setups from .vscode/launch.json
  1. on Windows, unpack stm8-gdb.exe binary to folder located in your system's PATH environment variable
  2. make sure OpenOCD 0.12 is installed
  3. install cpptools
  4. press F5 in VScode to build, flash, and debug (STM8-gdb profile)

Testing

Setup

Initialize virtual environment (optional)::

py -m venv .venv

Enable virtual environment or let VScode to do it automatically:

.venv\Scripts\activate or source .venv\Scripts\activate

Install dependencies:

pip install .

Usage

Run tests:

pytest

Calculate coverage and generate html report (probably will not work on Windows): pytest --coverage

Compile the firmware manually

  • cd src/ and use make or compile.bat to compile the firmware.

Flashing the firmware manually

  • Use make flash or flash.bat to flash the firmware.
  • If you have Android with OTG you can transfer main.hexto your phone and use Stm8 updater app to flash the stm8s105s6
  • For advanced flashing and option bytes managment use ST Visual Programmer STM8. You can use preconfigured project file from tools/ST_Vision_Programming.stp.

Editing environment

  1. VScode can be used for the development. a) open project top folder as workspace b) install extensions from recommended popup c) configure Intellisense by going to Settings ctrl+, and specifying @id:C_Cpp.default.systemIncludePath according to SDCC installation folder, e.g: C:\\Program Files\\SDCC\\include d) Ctrl+Shift+b to build the firmware

IMPORTANT NOTES

  • Installing this firmware will void your warranty of the TSDZ2 mid drive.
  • We are not responsible for any personal injuries or accidents caused by use of this firmware.
  • There is no guarantee of safety using this firmware, please use it at your own risk.
  • We advise you to consult the laws of your country and tailor the motor configuration accordingly.
  • Please be aware of your surroundings and maintain a safe riding style.

About

TSDZ2 Open Source Firmware adapted to VLCD5-VLCD6-XH18 displays

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 74.3%
  • Java 19.3%
  • HTML 4.5%
  • Python 1.4%
  • Batchfile 0.2%
  • Makefile 0.2%
  • Shell 0.1%