Tsdz2 firmware open source adapted to vlcd5, vlcd6 and xh18

Electric Motors and Controllers
User avatar
stancecoke   100 kW

100 kW
Posts: 1169
Joined: Aug 02 2017 2:56pm

Re: Tsdz2 firmware open source adapted to vlcd5, vlcd6 and xh18

Post by stancecoke » Feb 05 2020 9:01am

Waynemarlow wrote:
Feb 05 2020 8:37am
For some reason I'm really struggling to get the GUI to operate correctly on my PC
Make sure that every piece of software is installed in the correct path on your computer according to the manual.
For the use of the GUI the Java Runtime Environment has to be installed.
Waynemarlow wrote:
Feb 05 2020 8:37am
Is there anyway we could just get one of you guys to just compile a file for the motor and make it public.
As you can't set all the parameters with the stock displays, every user has to compile his own firmware with his personal settings.
So you can't work with a common hex file.

regards
stancecoke

Nfer   100 mW

100 mW
Posts: 44
Joined: Sep 17 2019 6:51am

Re: Tsdz2 firmware open source adapted to vlcd5, vlcd6 and xh18

Post by Nfer » Feb 05 2020 9:09am

ilu wrote:
Feb 05 2020 5:36am
Does anyone know if it's possible to add a brake sensor to a controller which has only the 6-pin display cable? Perhaps soldering a wire on the controller and connecting that to the sensor?
https://github.com/OpenSource-EBike-fir ... ke-sensors

Elinx   100 W

100 W
Posts: 187
Joined: Aug 09 2019 6:58am

Re: Tsdz2 firmware open source adapted to vlcd5, vlcd6 and xh18

Post by Elinx » Feb 05 2020 10:03am

Waynemarlow wrote:
Feb 05 2020 8:37am
For some reason I'm really struggling to get the GUI to operate correctly on my PC, its probably me :) . ...
You must be sure to have installed JRE, SDCC and STVP.
Check if SDCC and STVP are installed on C: and not C:/program files/

Without JRE you can install the FW by editing the basic settings inside config.h with notepad.
Compiling with compile_20.bat, flashing with program_20.bat.
All this is a lot easier with one button inside the Configurator Gui.

Waynemarlow   1 kW

1 kW
Posts: 319
Joined: Jul 09 2016 7:22am
Location: Bucks, England

Re: Tsdz2 firmware open source adapted to vlcd5, vlcd6 and xh18

Post by Waynemarlow » Feb 05 2020 11:29am

Thanks guys I'll keep endeavoring to get this to run.

elfnino   100 mW

100 mW
Posts: 43
Joined: Mar 06 2019 5:09am

Re: Tsdz2 firmware open source adapted to vlcd5, vlcd6 and xh18

Post by elfnino » Feb 06 2020 4:08am

Elinx wrote:
Feb 04 2020 4:25am
Till there is a working Gui I have made configuration sections in the English Google translation and improve the layout a bit.
EN-Parameter-Config.h-guide-TSDZ2-mb.20beta1.A.pdf
:thumb: thanks for the EN translation !

However it is not clear how to activate Walk Assist or Cruise mode on VLCD5.. there is just recommendation to check original manual of the display but there isn't such thing..

User avatar
stancecoke   100 kW

100 kW
Posts: 1169
Joined: Aug 02 2017 2:56pm

Re: Tsdz2 firmware open source adapted to vlcd5, vlcd6 and xh18

Post by stancecoke » Feb 06 2020 6:25am

I've added a wiki page with a short installation-guide and links to the related forum discussions:

https://github.com/stancecoke/TSDZ2-Smart-EBike/wiki

Improvements are welcome, any user with a github account can edit the page.

regards
stancecoke

Elinx   100 W

100 W
Posts: 187
Joined: Aug 09 2019 6:58am

Re: Tsdz2 firmware open source adapted to vlcd5, vlcd6 and xh18

Post by Elinx » Feb 06 2020 6:43am

elfnino wrote:
Feb 06 2020 4:08am
......

:thumb: thanks for the EN translation !

However it is not clear how to activate Walk Assist or Cruise mode on VLCD5.. there is just recommendation to check original manual of the display but there isn't such thing..
Have you seen the display operation manual too? That one I have translated too.
EN-Manual_display operation-TSDZ2-mb.20beta1.A.pdf
(581.83 KiB) Downloaded 136 times
I have both files uploaded for the first time here

Later I have edited and uploaded only the configuration guide two times
1- layout improvement. (the one you have) for editing all config.h settings with notepad.
2 - re-arranged specific for the new Java Configurator GUI which had split the settings into basic and advanced.
Last edited by Elinx on Feb 06 2020 1:18pm, edited 2 times in total.

DavyWavy66   1 µW

1 µW
Posts: 1
Joined: Feb 06 2020 10:54am

Re: Tsdz2 firmware open source adapted to vlcd5, vlcd6 and xh18

Post by DavyWavy66 » Feb 06 2020 11:03am

Hello,

I've been following this wit increasing excitement for a little while. :D Thank you for the hard work!

Can anyone help with this issue? I have my ST-Link connected and all the files installed in C:\
When I press compile in the GUI and after it runs through the compile I get the following error,
"loading file option_no_prot.ihx in option byte image in computer"

Any help appreciated.

Regards,


David

User avatar
stancecoke   100 kW

100 kW
Posts: 1169
Joined: Aug 02 2017 2:56pm

Re: Tsdz2 firmware open source adapted to vlcd5, vlcd6 and xh18

Post by stancecoke » Feb 06 2020 12:23pm

DavyWavy66 wrote:
Feb 06 2020 11:03am
"loading file option_no_prot.ihx in option byte image in computer"
Ah, again an issue of my .gitignore settings. I just fixed it at github. Please download the repo again, it should work now!
https://github.com/stancecoke/TSDZ2-Sma ... 9c5fe54be1

regards
stancecoke

godofglow   10 mW

10 mW
Posts: 23
Joined: Oct 19 2019 2:46am

Re: Tsdz2 firmware open source adapted to vlcd5, vlcd6 and xh18

Post by godofglow » Feb 06 2020 2:19pm

stancecoke wrote:
Feb 06 2020 12:23pm
DavyWavy66 wrote:
Feb 06 2020 11:03am
"loading file option_no_prot.ihx in option byte image in computer"
Ah, again an issue of my .gitignore settings. I just fixed it at github. Please download the repo again, it should work now!
https://github.com/stancecoke/TSDZ2-Sma ... 9c5fe54be1

regards
stancecoke
just awesome stancecoke! thx a lot! :bigthumb:

Like it because based on the casahino-base-repo

elfnino   100 mW

100 mW
Posts: 43
Joined: Mar 06 2019 5:09am

Re: Tsdz2 firmware open source adapted to vlcd5, vlcd6 and xh18

Post by elfnino » Feb 07 2020 5:32am

Elinx wrote:
Feb 04 2020 7:33pm
stancecoke wrote:
Feb 04 2020 1:47pm
.....

The configurator works now for the basic settings. I think it is mostly self explanatory.
https://github.com/stancecoke/TSDZ2-Smart-EBike
.......

For people who want to bring the advanced settings into the GUI.......
Till then I have re-arranged the configuration guide for basic and advanced settings.
EN-Configurator -TSDZ2-mb.20beta1.A.pdf
In te section How to assist WALK ASSIST :
Activated with the dedicated button, consult the manual of your display

But in the official VLCD5 manual I could not find any WALK ASSIST or CRUISE dedicated button.. so which button is it ?

Elinx   100 W

100 W
Posts: 187
Joined: Aug 09 2019 6:58am

Re: Tsdz2 firmware open source adapted to vlcd5, vlcd6 and xh18

Post by Elinx » Feb 07 2020 5:48am

elfnino wrote:
Feb 07 2020 5:32am
...... in the official VLCD5 manual I could not find any WALK ASSIST or CRUISE dedicated button.. so which button is it ?
In settings the name for walkassist is 6km/h on off

dameri   100 W

100 W
Posts: 146
Joined: Sep 20 2018 10:57am

Re: Tsdz2 firmware open source adapted to vlcd5, vlcd6 and xh18

Post by dameri » Feb 07 2020 5:50am

ilu wrote:
Feb 05 2020 5:36am
Does anyone know if it's possible to add a brake sensor to a controller which has only the 6-pin display cable? Perhaps soldering a wire on the controller and connecting that to the sensor?
Here is temperature sensor installing on 6-pin controller by jbalat.
https://www.youtube.com/watch?v=Wb8Omk6e7GI

elfnino   100 mW

100 mW
Posts: 43
Joined: Mar 06 2019 5:09am

Re: Tsdz2 firmware open source adapted to vlcd5, vlcd6 and xh18

Post by elfnino » Feb 07 2020 7:53am

Elinx wrote:
Feb 07 2020 5:48am
elfnino wrote:
Feb 07 2020 5:32am
...... in the official VLCD5 manual I could not find any WALK ASSIST or CRUISE dedicated button.. so which button is it ?
In settings the name for walkassist is 6km/h on off
Thanks !
Attachments
Capture.JPG
Capture.JPG (39.98 KiB) Viewed 1617 times

revher   10 mW

10 mW
Posts: 21
Joined: Dec 19 2019 5:14pm

Re: Tsdz2 firmware open source adapted to vlcd5, vlcd6 and xh18

Post by revher » Feb 08 2020 6:34am

stancecoke wrote:
Feb 06 2020 12:23pm
DavyWavy66 wrote:
Feb 06 2020 11:03am
"loading file option_no_prot.ihx in option byte image in computer"
Ah, again an issue of my .gitignore settings. I just fixed it at github. Please download the repo again, it should work now!
https://github.com/stancecoke/TSDZ2-Sma ... 9c5fe54be1

regards
stancecoke
Hi Stancecoke, I am new on this list and was a little bit lost in this long thread but I appreciate your new wiki and I started to install the softwares. I think that you could mention that the installation is for Windows (which I don't have anymore but can install with VirtualBox). Also you could add a precision and say "download and install a complete version of SDCC (with includes and libraries)". I was willing to keep my C: drive small (the virtual fdi) and got errors on the includes (and libraries). But I have been able to get the main.ihx successfully for a 36V 10.4Ah battery.

Other point, would it be possible to remember, close to the default 45, that in the EU the max speed for a pedelec is 25km/h?

I also have an additional question. As I just bought a ST-Link V2 with a short 4 wires cable, I haven't tested (yet) the electric connection with the TSDZ2 via the 6-pin male connector; but I was wondering if you could add a first menu to your very nice configurator which could help the new user to transmit the original stock firmware of the motor and save it on the C: drive. That initial step would also test the electric connection and wiring.

I read or viewed from early jbalat YouTube videos that 3 panes have to be saved and I can understand that this initial new step could not be easily implemented in your Java configurator.

In any case, I thank you (and the others casaino etc) very much in your efforts to improve and simplify the processing.

Regards,
revher

PS: I haven't tested this new firmware yet and I am still using the stock original firmware which is quite good for me (250W) but I would appreciate if I could read somewhere what are the real major improvements with the open-source. For example why a linear torque curve is clearly better than the original parabolic and if it is so clear why Tongsheng did not adapt it to their stock new motor. The "benefits" that are included in the readme "The motor runs more efficient therefore it becomes more powerful and consumes less energy." and "The ebike will feel more responsive and agile." could be more convincing with a link to a technical reference.

PPS: I have two TSDZ2 motor a first one with a new Vermont E-Jersey German with a VLCD5 and an Aliiexpress adapted to an old bike with an XH18. I would like to change the VLCD5 monitor with a new XH18 monitor. My question is: is it possible to change the monitor keeping the original firmware in place? And if the answer is yes, why should we have to choose between VLCD6, VLCD5 and XH18? Could it be the same firmware in the future? (I know that temperature and new ad-dons could be important).

obcd   100 W

100 W
Posts: 138
Joined: Jul 16 2019 3:45pm

Re: Tsdz2 firmware open source adapted to vlcd5, vlcd6 and xh18

Post by obcd » Feb 08 2020 8:15am

The open source firmware uses "simplified FOC" to drive the motor. That should be more efficient than the standard firmware.

The open source firmware has options to adjust maximum battery current and motor winding currents. This allows the motor to produce higher peak power when needed if the battery is up to it. If however you go to high on those, the motor can overheat. A thermal sensor can measure motor temperature and reduce the current when the motor is overheating.

The Tsdz2 torque sensor is not always working equal well and there output can differ from one motor to another. At the start, it's output increases linear with the pressure on the pedals, but it doesn't stay like that over it's full range. Due to those differences, settings can work fine for one person and not so good for another. The open source firmware tries to compensate for those differences so that the experience becomes equal for everyone.

Finally, there is the startup behavour. Some people like high assistance at takeoff so they are quickly up to speed when a red light becomes green. Others like it more if assistance increases gradually. It's better for the chain and the gearings and it reduces the risks for slipping and accidents. It's obviously also better for battery life.

There are basically 2 major diversions of the open source firmware. One uses the original Tsdz2 displays and has most of the parameters hardcoded in the firmware by editing the config files or using a configurator program and the other uses a reprogrammed kuteng or bafang display and has the options to alter configurations on the fly. Not all revisions work on every display. The kuteng will likely be abandonded due to the limited code size of it's buildin microcontroller. The Bafang 850C is graphical and has a bigger display. It also comes with a higher price card. The Bafang SW102 still needs to be opened for it's initial programming and it's not really designed for that. (It's glued together). It has a buildin bluetooth interface which can become a bonus in the future for smartphone connectivity.

User avatar
stancecoke   100 kW

100 kW
Posts: 1169
Joined: Aug 02 2017 2:56pm

Re: Tsdz2 firmware open source adapted to vlcd5, vlcd6 and xh18

Post by stancecoke » Feb 08 2020 8:20am

revher wrote:
Feb 08 2020 6:34am
I appreciate your new wiki and I started to install the softwares.
You are welcome! :D
If you have any approvements for the wiki, just edit it. Anybody with a github account can write to the wiki.

regards
stancecoke

revher   10 mW

10 mW
Posts: 21
Joined: Dec 19 2019 5:14pm

Re: Tsdz2 firmware open source adapted to vlcd5, vlcd6 and xh18

Post by revher » Feb 08 2020 11:02am

stancecoke wrote:
Feb 08 2020 8:20am
revher wrote:
Feb 08 2020 6:34am
I appreciate your new wiki and I started to install the softwares.
You are welcome! :D
If you have any approvements for the wiki, just edit it. Anybody with a github account can write to the wiki.

regards
stancecoke
I have a github account but I can't see the edit/newpage button on your wiki.

revher   10 mW

10 mW
Posts: 21
Joined: Dec 19 2019 5:14pm

Re: Tsdz2 firmware open source adapted to vlcd5, vlcd6 and xh18

Post by revher » Feb 08 2020 11:05am

obcd wrote:
Feb 08 2020 8:15am
The open source firmware uses "simplified FOC" to drive the motor. That should be more efficient than the standard firmware.
...
Thank you, this is exactly what somebody would like to read in Stancecoke's wiki (but I haven't found yet how to write in).

User avatar
stancecoke   100 kW

100 kW
Posts: 1169
Joined: Aug 02 2017 2:56pm

Re: Tsdz2 firmware open source adapted to vlcd5, vlcd6 and xh18

Post by stancecoke » Feb 08 2020 11:50am

revher wrote:
Feb 08 2020 11:02am
I have a github account but I can't see the edit/newpage button on your wiki.
Sorry, I had to disable the restriction to collaborators, now is should work!
revher wrote:
Feb 08 2020 11:05am
Thank you, this is exactly what somebody would like to read in Stancecoke's wiki (but I haven't found yet how to write in).
You can find all the information in the wiki of the main project, see the link in the readme.md
https://github.com/OpenSource-EBike-fir ... _wiki/wiki
I want to keep my wiki main page as simple and self explanatory as possible.
For details that are missing from your eyes, please create a new page.
Perhaps you can create one page for Linux users, we had questions about installing SDCC under Linux several times. I'm not familiar with Linux :wink:

regards
stancecoke

revher   10 mW

10 mW
Posts: 21
Joined: Dec 19 2019 5:14pm

Re: Tsdz2 firmware open source adapted to vlcd5, vlcd6 and xh18

Post by revher » Feb 09 2020 5:17am

stancecoke wrote:
Feb 08 2020 11:50am
revher wrote:
Feb 08 2020 11:02am
I have a github account but I can't see the edit/newpage button on your wiki.
Sorry, I had to disable the restriction to collaborators, now is should work!
...
For details that are missing from your eyes, please create a new page.
...
regards
stancecoke
Yes your wiki can be edited now, as well as the main wiki too!

I added some details on what version of the Windows SDCC to install and why. A compromise between details and waste of time by installing the compact but useless version. I hope that you are ok. Otherwise, make it shorten.
Regards,
Revher

revher   10 mW

10 mW
Posts: 21
Joined: Dec 19 2019 5:14pm

Re: Tsdz2 firmware open source adapted to vlcd5, vlcd6 and xh18

Post by revher » Feb 09 2020 1:19pm

rob42 wrote:
Jan 26 2020 7:39pm
Thanks for that, I found another option too. In linux (ubuntu 18.04 with SDCC 3.8 I have some related commands

sdasstm8 - -plosgffw main //manipulates symbols etc
sdldstm8 -nf main.lk //linker

I found it all worked by just running `sdldstm8 -nf main.lk` in the src/controller dir after the make process errored. Gave me a main.ihx file which flashed and worked.
Thank you for the hint related to the error due to the unknown stm8-objcopy command. But on OS/X and using the SDCC version installed with homebrew (sdld Linker V03.00 + NoICE + sdld), the -i option (for Intel Hex as (out)file[.ihx]) has to be added, otherwise the main.ihx is not output.

Code: Select all

sdldstm8 -fi main.lk
but it is seems better to use the Makefile_windows which doesn't use the sdlstm8 step because its output is directly main.ihx instead of main.elf

It is not very clean to use a name mentioning ELF and not using it!
ELF_FLAGS = --out-fmt-ihx --debug
instead of --out-fmt-elf --debug
but it works. As said before by someone else, renaming Makefile_windows into Makefile will work for Linux, OS/X and Windows (cygwin).

Regards,
revher

revher   10 mW

10 mW
Posts: 21
Joined: Dec 19 2019 5:14pm

Re: Tsdz2 firmware open source adapted to vlcd5, vlcd6 and xh18

Post by revher » Feb 12 2020 7:30am

stancecoke wrote:
Feb 08 2020 11:50am

You can find all the information in the wiki of the main project, see the link in the readme.md
https://github.com/OpenSource-EBike-fir ... _wiki/wiki
I want to keep my wiki main page as simple and self explanatory as possible.
For details that are missing from your eyes, please create a new page.
Perhaps you can create one page for Linux users, we had questions about installing SDCC under Linux several times. I'm not familiar with Linux :wink:

regards
stancecoke
Hi,
I haven't flashed the opensource firmware to my TSDZ2 motors because I am still lost about:
- how to backup the original Tongsheng firmwares (program, data, EEprom ?);
- if it is possible to flash them back?
- is there a protection against the flashing?
I think that your former wiki https://github.com/stancecoke/BMSBatter ... Java-Tool
gives more information on all these questions and some of them should be added to the current wiki concerning the procedure under Windows https://github.com/stancecoke/TSDZ2-Smart-EBike/wiki.

I have been able to backup the original firmwares with the Unix tools (stm8flash) but I don't know if the Windows procedure (described in the current wiki) can do it.
Also, I have read that the write protection can be deleted from a Unix command but I don't know how to do with the Windows procedure. In particular, I don't know how the file "option_no_prot.ihx" is produced. Also, I think that the file "data.ihx" is empty.

Could someone give some advices before I break the warranty of my motors?
Or am I needlessly too fearful!

Regards,
Revher

PS: I made some changes in the Java, by testing on which OS the configurator is run (Mac OS X or Linux or Windows), and have been able to produce the main.ihx on each of the three OS.

User avatar
stancecoke   100 kW

100 kW
Posts: 1169
Joined: Aug 02 2017 2:56pm

Re: Tsdz2 firmware open source adapted to vlcd5, vlcd6 and xh18

Post by stancecoke » Feb 12 2020 9:24am

revher wrote:
Feb 12 2020 7:30am
because I am still lost
Have you read the wiki of the main project? You can find very much information there. Look at the links to bitbucket, too. You can find the original firmware files there also, so you can go back to the stock firmware any time.

As you have managed to read the flash, EEPROM und Optionbytes, the controller was not locked obviously.
There is no special write protection, if you can read it, you can write it, too. It's just a single bit in the option bytes.

The Kuntengs are always Read/Write protected on delivery. Therefore is the "Unlock" button in the GUI to set the needed option bytes.

marcoq and mbrusa always write all three memory areas (Flash, Data, Optionbytes) with the Compile&Flash button, so the user don't have to care about it. The empty data.ihx writes just zeros to the whole EEPROM to avoid trouble with mixing new and old meanings of data in memory adresses.
revher wrote:
Feb 12 2020 7:30am
I don't know how the file "option_no_prot.ihx" is produced
?! You don't have to know that :-) It's in the repo and there's no need to think about it.
It contains the option bytes and can simply be saved (and then renamed) from the STVP GUI.

Regards
stancecoke

revher   10 mW

10 mW
Posts: 21
Joined: Dec 19 2019 5:14pm

Re: Tsdz2 firmware open source adapted to vlcd5, vlcd6 and xh18

Post by revher » Feb 13 2020 5:43pm

Hi all,

I have been able to flash my TSDZ2 250w 36V 10.4ah motor with a firmware produced with Stancecoke Java configurator that I adapted to run on Linux and OS/X. Even with the same config.h and because (probably) the version of the compiler were different the .rel and main.ihx are about of the same size but they are all three different.

As said by Stancecoke, having been able to backup the original 3 firmware binaries on disk, I have been able to restore two of them the Program and Opt but not the Eeprom and it said "Tries exceeded"

Code: Select all

stm8flash -c stlinkv2 -p stm8s105?6 -s eeprom -w TSDZ_orig_eeprom.bin
Determine EEPROM area
Due to its file extension (or lack thereof), "TSDZ_orig_eeprom.bin" is considered as RAW BINARY format!
1024 bytes at 0x4000... Tries exceeded
make: *** [restoreeeprom] Error 255
In fact, I had forgotten to unplug the battery and the error might come from this (?)

I have just had time for a small ride but I noticed a difference. As the TSDZ2 is a coaster brake, I remarked that when I started backward pedaling the motor did not stop as immediately as before. And I remember having seen different versions of the firmware according to the coaster brake or the free wheel version. This was at the download link provided by eco-cycles https://www.eco-ebike.com/blogs/eco-cycles-instructionals/tsdz2-motor-firmware-programming.

But in fact I haven't find, neither in the config.h nor in the advanced.h, a "useful" COASTER_BRAKE definition. I may be wrong because Casainho explains in his last release 20 beta 1 that he started some e-brake when retro-pedaling, but I am probably confused.

So my question is, does the marcok/mbrusa fork make any distinction between both motors, coaster brake or free wheel as eco-cycle made?

Regards,
revher

Post Reply