TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

Electric Motors and Controllers
casainho   10 GW

10 GW
Posts: 4464
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

Post by casainho » May 23 2020 6:20am

rcx194 wrote:
May 23 2020 6:14am
casainho wrote:
May 05 2020 11:32am
Please go ahead and put a warning on the wiki, maybe on the firmware installation page.
As per request I've added a warning to the Wiki. Feel free to edit/improve what I've written.

Image
Note that is valid for also SW102, so, I think that information should be in upper level of the instructions.
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless Ebike boar ANT+ and Bluetooth, Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation to help my developments: paypal.me/jorgecasa

rcx194   10 mW

10 mW
Posts: 28
Joined: Mar 18 2020 5:29pm

Re: TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

Post by rcx194 » May 23 2020 6:32am

casainho wrote:
May 23 2020 6:20am
Note that is valid for also SW102, so, I think that information should be in upper level of the instructions.
I can't find a suitable place higher up, so added the same warning to the SW102 page.

rcx194   10 mW

10 mW
Posts: 28
Joined: Mar 18 2020 5:29pm

Re: TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

Post by rcx194 » May 23 2020 8:33am

Calibrated the torque sensor on my TSDZ2 today using a baggage scale and human weights.... jeeze does it make a difference to the ride! Power delivery is now awesome!

I'm curious, with the factory firmware and display, are the torque sensors calibrated at the factory?

vshitikov   10 W

10 W
Posts: 76
Joined: Mar 05 2020 7:24am

Re: TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

Post by vshitikov » May 23 2020 8:53am

rcx194 wrote:
May 23 2020 8:33am
Calibrated the torque sensor on my TSDZ2 today using a baggage scale and human weights.... jeeze does it make a difference to the ride! Power delivery is now awesome!

I'm curious, with the factory firmware and display, are the torque sensors calibrated at the factory?
I didn't have the same experience with calibration and reverted back to original. Maybe calibration is better suitable for the torque mode but in my case I had unpleasant results. The linear curve instead of logarithmic make assist very weak at the low cadence and I have to press even harder on the pedals to make my bike moving after the stop. I also experienced an uneven assistance while rotating a pedal, like if I had a oval chain-ring. I think this comes from the fact that the assistance is not averaged through the chainring rotation. I saw that Casainho added a filter to rectify that but I didn't yet try the new 1.0.0 version.
The torque sensors are obviously not calibrated at the factory, they do not need to be calibrated as they have general logarithmic curve that fits most of the general use. I recently used my bike on the high hills and saw all the limitations of the motor control that people were complaining: delayed start after the gear change, low assistance at low cadence e.t.c. I usually didn't see this while using my bike in the city.
I'm going to try 1.0.0 version version and I'm going to tweak some parameters to slightly change the control to better fit my riding style

wpenner   100 W

100 W
Posts: 104
Joined: May 10 2018 3:27pm

Re: TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

Post by wpenner » May 23 2020 3:40pm

Hi,

I'm trying to update a TSDZ2 kit that came with a 850c display. Is there any problem opening the display and flashing using SWD STLINKV2. Will i end up with the same result result as if i used a bootloader box? I already have the stlink, but don't really have time to and money to order the bootloader box?

Thanks to anyone who can help with this maybe easy question.

James Broadhurst   10 W

10 W
Posts: 99
Joined: Nov 10 2016 3:29pm
Location: Oxford, England

Re: TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

Post by James Broadhurst » May 23 2020 4:54pm

vshitikov wrote:
May 23 2020 8:53am
The linear curve instead of logarithmic make assist very weak at the low cadence and I have to press even harder on the pedals to make my bike moving after the stop. I also experienced an uneven assistance while rotating a pedal, like if I had a oval chain-ring. I think this comes from the fact that the assistance is not averaged through the chainring rotation.
Best way of running 1.0 beta1 is with the calibration disabled. I had not appreciated why until I read this. Many thanks!

Nfer   10 W

10 W
Posts: 73
Joined: Sep 17 2019 6:51am

Re: TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

Post by Nfer » May 23 2020 7:51pm

James Broadhurst wrote:
May 23 2020 4:54pm
vshitikov wrote:
May 23 2020 8:53am
The linear curve instead of logarithmic make assist very weak at the low cadence and I have to press even harder on the pedals to make my bike moving after the stop. I also experienced an uneven assistance while rotating a pedal, like if I had a oval chain-ring. I think this comes from the fact that the assistance is not averaged through the chainring rotation.
Best way of running 1.0 beta1 is with the calibration disabled. I had not appreciated why until I read this. Many thanks!
Is your display setup in metric units and the weights in kilograms?

wpenner   100 W

100 W
Posts: 104
Joined: May 10 2018 3:27pm

Re: TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

Post by wpenner » May 23 2020 9:01pm

wpenner wrote:
May 23 2020 3:40pm
Hi,

I'm trying to update a TSDZ2 kit that came with a 850c display. Is there any problem opening the display and flashing using SWD STLINKV2. Will i end up with the same result result as if i used a bootloader box? I already have the stlink, but don't really have time to and money to order the bootloader box?

Thanks to anyone who can help with this maybe easy question.
Well i can confirm this is probably is not a good idea. Flashed my screen and my motor and now the bike does not turn on with the power button and black display on 850C. Is is possible i was supposed to use a file that does not say bootloader on it. I tried to follow these instructions that say pick a file with *bootloader.bin

https://github.com/OpenSource-EBike-fir ... -using-SWD

wpenner   100 W

100 W
Posts: 104
Joined: May 10 2018 3:27pm

Re: TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

Post by wpenner » May 23 2020 9:24pm

wpenner wrote:
May 23 2020 9:01pm
wpenner wrote:
May 23 2020 3:40pm
Hi,

I'm trying to update a TSDZ2 kit that came with a 850c display. Is there any problem opening the display and flashing using SWD STLINKV2. Will i end up with the same result result as if i used a bootloader box? I already have the stlink, but don't really have time to and money to order the bootloader box?

Thanks to anyone who can help with this maybe easy question.
Well i can confirm this is probably is not a good idea. Flashed my screen and my motor and now the bike does not turn on with the power button and black display on 850C. Is is possible i was supposed to use a file that does not say bootloader on it. I tried to follow these instructions that say pick a file with *bootloader.bin

https://github.com/OpenSource-EBike-fir ... -using-SWD
I'm fairly confident it is an error on the wiki page. I flashed one that did not say bootloader, and now it says "waiting for tsdz2" for a couple of seconds then the display shuts itself off(next problem to figure out)

Nfer   10 W

10 W
Posts: 73
Joined: Sep 17 2019 6:51am

Re: TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

Post by Nfer » May 23 2020 9:43pm

casainho wrote:
May 22 2020 6:33pm

- solve SW102 lock issues on configurations menu
I finished the toque sensor calibration but after 100 reboots I could not insert any ADC and weight value on the SW102. The display freezes every time I scroll down the torque sensor menu. The last thing I can see is "pedal grou left", I am able to change it to "right" but it freeze if I scroll down.

James Broadhurst   10 W

10 W
Posts: 99
Joined: Nov 10 2016 3:29pm
Location: Oxford, England

Re: TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

Post by James Broadhurst » May 23 2020 10:54pm

Nfer wrote:
May 23 2020 7:51pm
Is your display setup in metric units and the weights in kilograms?
Yes.

Setting up an 850C in imperial had some weird effects in earlier versions of the firmware but nearly all gone with the latest 1.0.0-beta.1
Last edited by James Broadhurst on May 24 2020 3:20am, edited 1 time in total.

User avatar
elfnino   100 mW

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

Re: TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

Post by elfnino » May 23 2020 10:54pm

James Broadhurst wrote:
May 23 2020 4:54pm
vshitikov wrote:
May 23 2020 8:53am
The linear curve instead of logarithmic make assist very weak at the low cadence and I have to press even harder on the pedals to make my bike moving after the stop. I also experienced an uneven assistance while rotating a pedal, like if I had a oval chain-ring. I think this comes from the fact that the assistance is not averaged through the chainring rotation.
Best way of running 1.0 beta1 is with the calibration disabled. I had not appreciated why until I read this.
Many thanks!
Well I am still bigger fan of the previous implementation of eMTB (based on torque) where I could just set coefficient and make the logarithmic curve less or more exponential. It was simple and effective.

dameri   100 W

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

Re: TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

Post by dameri » May 24 2020 1:39am

wpenner wrote:
May 23 2020 9:01pm
wpenner wrote:
May 23 2020 3:40pm
Hi,

I'm trying to update a TSDZ2 kit that came with a 850c display. Is there any problem opening the display and flashing using SWD STLINKV2. Will i end up with the same result result as if i used a bootloader box? I already have the stlink, but don't really have time to and money to order the bootloader box?

Thanks to anyone who can help with this maybe easy question.
Well i can confirm this is probably is not a good idea. Flashed my screen and my motor and now the bike does not turn on with the power button and black display on 850C. Is is possible i was supposed to use a file that does not say bootloader on it. I tried to follow these instructions that say pick a file with *bootloader.bin

https://github.com/OpenSource-EBike-fir ... -using-SWD
You say you don't have bootloader box. If you flash through 850C tabs you have to use .bin file not bootloader.bin file.

Benoit   10 mW

10 mW
Posts: 27
Joined: May 22 2020 3:24am

Re: TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

Post by Benoit » May 24 2020 3:34am

casainho wrote:
May 23 2020 5:24am
Benoit wrote:
May 23 2020 2:48am
casainho wrote:
May 22 2020 6:33pm

Are there are many others things to do that I think have higher priority:
- solve SW102 lock issues on configurations menu
- solve lights issue
- automatic shutdown does not work
- Trip (with quick reset): time, distance, Wh
- Short Trip: time, distance, Wh
- kms range estimation, based on Wh used of current short trip, last 5 or 10 minutes
- disable sensors: brake, cadence and torque
Maybe I can start to work on the trip features. It's something I could easily test and verify. Is that ok for you ?
[...]
Well, should we invest time to develop all this little details?? I don't known... I would instead invest my time on the wireless new version as for long rides, that type of users will value more using a Garmin Edge device that already implements this features and they are implemented already in conjunction with other important trip data and fitness, and recorded on the cloud.

Well, is up to you to decide in which project you prefer to invest more.
Those two projects are both interesting. But personnaly I think it's important to have an "official" display, directy connected to the motor. Having a wireless display is a very nice feature, but for me it's an accessory and we need a solid "main" display with all the base features any ebike users will expect. (but except points you mention above it's pretty good and maybe we do not need to add other features as essential is already done)

Does the use of such Garmin Edge devices will be used by so much people than the SW102/850C/860C display ?
If it really the case, I will invest time (and money as I haven't any of that kind of device) to help.

ALso I saw on this forum you already talked about using a smartphone as a wireless display instead of the current SW102/850C/860C.
This is for me more usefull than a Garmin Edge like device as lot (all ?) bike users have allready a smartphone.
Is there already iOS/Android applications ? What would be the benefits of a Garmine device ? (ANT+ accessories, that's it)


Anyway, I tried to compile then flash firmware. For the 860C, no problem, I can successfully compile it and flash the display, everything is working well.
But for the motor, I did not have "stm8-size" and "stm8-objcopy" commands. I've search on the web and found some informations. I tried to install stm8-binutils (https://stm8-binutils-gdb.sourceforge.io/) but the last step "make install" report me some errors at the end ("*** [Makefile:1754: install-recursive] Error 1" and 3 more)
So for now compilation give me a "main.elf" file. Is this enough ?
I'm using a Debian 10 command line environnement (which contains source code and is used for compiling) and VS code on Windows 10 for developping (remote SSH).
Thanks for the help !

vshitikov   10 W

10 W
Posts: 76
Joined: Mar 05 2020 7:24am

Re: TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

Post by vshitikov » May 24 2020 4:19am

Benoit wrote:
May 24 2020 3:34am

Anyway, I tried to compile then flash firmware. For the 860C, no problem, I can successfully compile it and flash the display, everything is working well.
But for the motor, I did not have "stm8-size" and "stm8-objcopy" commands. I've search on the web and found some informations. I tried to install stm8-binutils (https://stm8-binutils-gdb.sourceforge.io/) but the last step "make install" report me some errors at the end ("*** [Makefile:1754: install-recursive] Error 1" and 3 more)
So for now compilation give me a "main.elf" file. Is this enough ?
I'm using a Debian 10 command line environnement (which contains source code and is used for compiling) and VS code on Windows 10 for developping (remote SSH).
Thanks for the help !
you don't need them. I compile simply with this line in the makefile. But I compile on Windows.

# How to build the overall program
$(PNAME): $(MAINSRC) $(RELS)
$(CC) $(INCLUDES) $(CFLAGS) $(ELF_FLAGS) $(LIBS) $(MAINSRC) $(RELS)

the other lines with objcopy and stm-size are commented. Then you can rename the file in .hex if necessary

Mr.Flibble   100 µW

100 µW
Posts: 8
Joined: May 05 2020 7:16am

Re: TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

Post by Mr.Flibble » May 24 2020 8:48am

I was getting nowhere with the programming pads on the side of my new sw102, so i tried to open the keypad.
Mine isn't made like the one on the wiki. The whole body is sealed with two holes over the microswitched for the buttons, that rubber bungs on the back of the case button go through.

Still not getting anywhere, I may have melted one of the pads.

Benoit   10 mW

10 mW
Posts: 27
Joined: May 22 2020 3:24am

Re: TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

Post by Benoit » May 24 2020 9:46am

vshitikov wrote:
May 24 2020 4:19am
Benoit wrote:
May 24 2020 3:34am

Anyway, I tried to compile then flash firmware. For the 860C, no problem, I can successfully compile it and flash the display, everything is working well.
But for the motor, I did not have "stm8-size" and "stm8-objcopy" commands. I've search on the web and found some informations. I tried to install stm8-binutils (https://stm8-binutils-gdb.sourceforge.io/) but the last step "make install" report me some errors at the end ("*** [Makefile:1754: install-recursive] Error 1" and 3 more)
So for now compilation give me a "main.elf" file. Is this enough ?
I'm using a Debian 10 command line environnement (which contains source code and is used for compiling) and VS code on Windows 10 for developping (remote SSH).
Thanks for the help !
you don't need them. I compile simply with this line in the makefile. But I compile on Windows.

# How to build the overall program
$(PNAME): $(MAINSRC) $(RELS)
$(CC) $(INCLUDES) $(CFLAGS) $(ELF_FLAGS) $(LIBS) $(MAINSRC) $(RELS)

the other lines with objcopy and stm-size are commented. Then you can rename the file in .hex if necessary
Thanks !

I tried to compile it on Windows juste after posting my last message and it worked (I did not yet flash it however)
That's what I'll do so. I would prefer to compile both firmwares on Linux but the essential is I can compile .

andyme   100 W

100 W
Posts: 210
Joined: Oct 04 2017 1:40pm

Re: TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

Post by andyme » May 24 2020 3:11pm

wpenner wrote:
May 23 2020 9:24pm
wpenner wrote:
May 23 2020 9:01pm
wpenner wrote:
May 23 2020 3:40pm
Hi,

I'm trying to update a TSDZ2 kit that came with a 850c display. Is there any problem opening the display and flashing using SWD STLINKV2. Will i end up with the same result result as if i used a bootloader box? I already have the stlink, but don't really have time to and money to order the bootloader box?

Thanks to anyone who can help with this maybe easy question.
Well i can confirm this is probably is not a good idea. Flashed my screen and my motor and now the bike does not turn on with the power button and black display on 850C. Is is possible i was supposed to use a file that does not say bootloader on it. I tried to follow these instructions that say pick a file with *bootloader.bin

https://github.com/OpenSource-EBike-fir ... -using-SWD
I'm fairly confident it is an error on the wiki page. I flashed one that did not say bootloader, and now it says "waiting for tsdz2" for a couple of seconds then the display shuts itself off(next problem to figure out)
are you sure your wiring is 100% ok? I was away from this thread for over a year now. I had left it when the 805C was still in a very early stage with jtag programming and i still had that display on the shelf. not being up to date really, i installed the bootloader file. this did not work, but also did not ruin anything. i then installed the correct file and got the waiting for tsdz2 message. I opened the display and found that one of the cables had come loose. after resoldering it correctly everything worked out fine immediately.
so according to me there is absolutely no problem using the jtags if you do not make a mistake with the wires.

Benoit   10 mW

10 mW
Posts: 27
Joined: May 22 2020 3:24am

Re: TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

Post by Benoit » May 24 2020 3:42pm

Benoit wrote:
May 24 2020 9:46am
vshitikov wrote:
May 24 2020 4:19am
Benoit wrote:
May 24 2020 3:34am

Anyway, I tried to compile then flash firmware. For the 860C, no problem, I can successfully compile it and flash the display, everything is working well.
But for the motor, I did not have "stm8-size" and "stm8-objcopy" commands. I've search on the web and found some informations. I tried to install stm8-binutils (https://stm8-binutils-gdb.sourceforge.io/) but the last step "make install" report me some errors at the end ("*** [Makefile:1754: install-recursive] Error 1" and 3 more)
So for now compilation give me a "main.elf" file. Is this enough ?
I'm using a Debian 10 command line environnement (which contains source code and is used for compiling) and VS code on Windows 10 for developping (remote SSH).
Thanks for the help !
you don't need them. I compile simply with this line in the makefile. But I compile on Windows.

# How to build the overall program
$(PNAME): $(MAINSRC) $(RELS)
$(CC) $(INCLUDES) $(CFLAGS) $(ELF_FLAGS) $(LIBS) $(MAINSRC) $(RELS)

the other lines with objcopy and stm-size are commented. Then you can rename the file in .hex if necessary
Thanks !

I tried to compile it on Windows juste after posting my last message and it worked (I did not yet flash it however)
That's what I'll do so. I would prefer to compile both firmwares on Linux but the essential is I can compile .
I finally succeeded to compile TSDZ2 firmware with Linux !
What I did : in the "Makefile_linux" file : I changed ELF_FLAGS value from "--out-fmt-elf --debug" to "--out-fmt-ihx --debug".
It then generate a main.ihx file instead of a main.elf. The main.ixh file can then be converted in a main.hex file with this command : "packihx main.ihx > main.hex"

I flashed this file with ST Visual Programmer and it worked flawlessly !

So now I can develop and compile with VS code and its internal terminal (SSH on my Linux VM).

wpenner   100 W

100 W
Posts: 104
Joined: May 10 2018 3:27pm

Re: TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

Post by wpenner » May 24 2020 5:52pm

andyme wrote:
May 24 2020 3:11pm
wpenner wrote:
May 23 2020 9:24pm
wpenner wrote:
May 23 2020 9:01pm
wpenner wrote:
May 23 2020 3:40pm
Hi,

I'm trying to update a TSDZ2 kit that came with a 850c display. Is there any problem opening the display and flashing using SWD STLINKV2. Will i end up with the same result result as if i used a bootloader box? I already have the stlink, but don't really have time to and money to order the bootloader box?

Thanks to anyone who can help with this maybe easy question.
Well i can confirm this is probably is not a good idea. Flashed my screen and my motor and now the bike does not turn on with the power button and black display on 850C. Is is possible i was supposed to use a file that does not say bootloader on it. I tried to follow these instructions that say pick a file with *bootloader.bin

https://github.com/OpenSource-EBike-fir ... -using-SWD
I'm fairly confident it is an error on the wiki page. I flashed one that did not say bootloader, and now it says "waiting for tsdz2" for a couple of seconds then the display shuts itself off(next problem to figure out)
are you sure your wiring is 100% ok? I was away from this thread for over a year now. I had left it when the 805C was still in a very early stage with jtag programming and i still had that display on the shelf. not being up to date really, i installed the bootloader file. this did not work, but also did not ruin anything. i then installed the correct file and got the waiting for tsdz2 message. I opened the display and found that one of the cables had come loose. after resoldering it correctly everything worked out fine immediately.
so according to me there is absolutely no problem using the jtags if you do not make a mistake with the wires.
Thanks for the suggestion i have reflashed the motor and display multiple times, but have had problems every time. I am only programming the "current tab" as instructed (program > Current tab) do i need to go into the data tab to sort my strange problems?

Version 6.2 with .51motor - Works but up and down buttons for display are backwards, and i can not open config menu, when i hold down arrow walk assist turns on and motor moves.

Version 8.0 with .57 motor - Works and i can finally now get into config menu by holding all buttons, but when i press walk assist mode motor moves for .5 seconds and entire system restarts

version 1.00 beta1. Display boots and says waiting for TSDZ2.

wpenner   100 W

100 W
Posts: 104
Joined: May 10 2018 3:27pm

Re: TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

Post by wpenner » May 24 2020 10:19pm

wpenner wrote:
May 24 2020 5:52pm
andyme wrote:
May 24 2020 3:11pm
wpenner wrote:
May 23 2020 9:24pm
wpenner wrote:
May 23 2020 9:01pm


Well i can confirm this is probably is not a good idea. Flashed my screen and my motor and now the bike does not turn on with the power button and black display on 850C. Is is possible i was supposed to use a file that does not say bootloader on it. I tried to follow these instructions that say pick a file with *bootloader.bin

https://github.com/OpenSource-EBike-fir ... -using-SWD
I'm fairly confident it is an error on the wiki page. I flashed one that did not say bootloader, and now it says "waiting for tsdz2" for a couple of seconds then the display shuts itself off(next problem to figure out)
are you sure your wiring is 100% ok? I was away from this thread for over a year now. I had left it when the 805C was still in a very early stage with jtag programming and i still had that display on the shelf. not being up to date really, i installed the bootloader file. this did not work, but also did not ruin anything. i then installed the correct file and got the waiting for tsdz2 message. I opened the display and found that one of the cables had come loose. after resoldering it correctly everything worked out fine immediately.
so according to me there is absolutely no problem using the jtags if you do not make a mistake with the wires.
Thanks for the suggestion i have reflashed the motor and display multiple times, but have had problems every time. I am only programming the "current tab" as instructed (program > Current tab) do i need to go into the data tab to sort my strange problems?

Version 6.2 with .51motor - Works but up and down buttons for display are backwards, and i can not open config menu, when i hold down arrow walk assist turns on and motor moves.

Version 8.0 with .57 motor - Works and i can finally now get into config menu by holding all buttons, but when i press walk assist mode motor moves for .5 seconds and entire system restarts

version 1.00 beta1. Display boots and says waiting for TSDZ2.
Nevermind. Powered on and off controller about 20 times and re plugged all wired connections and it magically works on versoin 1.0 beta1

benno   100 µW

100 µW
Posts: 9
Joined: Apr 16 2020 10:23am

Re: TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

Post by benno » May 25 2020 5:05am

Hello

Your progress with the bluetooth displays looks great!
I have another two questions about the implementation:

(1) In the adc initialization (adc_init()) you initialize Pin 3,5,6,7

Code: Select all

 GPIO_Init(GPIOB,
	    (GPIO_PIN_7 | GPIO_PIN_6 | GPIO_PIN_5 | GPIO_PIN_3),
	    GPIO_MODE_IN_FL_NO_IT);
There is no analog Signal on Pin 3. However, the torque signal is on Pin 4 which
is not initialized here. Is there any reason for that or is it a mistake?
As the torque reading works fine, i did not change it so far.

(2) You explicitly prevent the motor from going over a certain max rotational speed (erps) (at least
in the implementation before you had field weakening).
Is it harmful for the motor to go over that speed? In my experience it just does not deliver any power anymore
if it reaches a certain speed.


By the way, i tried to derive the equations for the foc advance angle. According to my
calculations the angle should be twice as big as it is now.
I did some testing where i keept the motor speed constant and varied the foc angle.
At the optimum foc angle the power consumption is at a minimum.
My findings were that the 2x the current foc angle is usually quite close to the minimum for
all the operating conditions i tested.

casainho   10 GW

10 GW
Posts: 4464
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

Post by casainho » May 25 2020 7:05am

benno wrote:
May 25 2020 5:05am
Hello

Your progress with the bluetooth displays looks great!
I have another two questions about the implementation:

(1) In the adc initialization (adc_init()) you initialize Pin 3,5,6,7

Code: Select all

 GPIO_Init(GPIOB,
	    (GPIO_PIN_7 | GPIO_PIN_6 | GPIO_PIN_5 | GPIO_PIN_3),
	    GPIO_MODE_IN_FL_NO_IT);
There is no analog Signal on Pin 3. However, the torque signal is on Pin 4 which
is not initialized here. Is there any reason for that or is it a mistake?
As the torque reading works fine, i did not change it so far.
See that maybe you did a mistake:
#define TORQUE_SENSOR__PORT GPIOB
#define TORQUE_SENSOR__PIN GPIO_PIN_3

And I agree that defines should be used on ADC init.
benno wrote:
May 25 2020 5:05am
(2) You explicitly prevent the motor from going over a certain max rotational speed (erps) (at least
in the implementation before you had field weakening).
Is it harmful for the motor to go over that speed? In my experience it just does not deliver any power anymore
if it reaches a certain speed.
See this comment on the code:
// motor maximum rotation
#define MOTOR_OVER_SPEED_ERPS 700 // 675 is equal to 120 cadence, as TSDZ2 has a reduction ratio of 41.8

Max speed because there is a min limit of about 28 points to draw the SVM voltage signals. That was the reason why I increased the PWM frequency compared to original firmware.
benno wrote:
May 25 2020 5:05am
By the way, i tried to derive the equations for the foc advance angle. According to my
calculations the angle should be twice as big as it is now.

I did some testing where i keept the motor speed constant and varied the foc angle.
At the optimum foc angle the power consumption is at a minimum.
My findings were that the 2x the current foc angle is usually quite close to the minimum for
all the operating conditions i tested.
Please share your notes about the derivation so we all can learn.

And how did you tested? I hope you also put the motor under different loads with at least pulling 10 amps.
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless Ebike boar ANT+ and Bluetooth, Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation to help my developments: paypal.me/jorgecasa

Benoit   10 mW

10 mW
Posts: 27
Joined: May 22 2020 3:24am

Re: TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

Post by Benoit » May 25 2020 11:18am

I think there is a problem in the source code of the last release, in the "mainscreen.c" file.
If I compile it myself, the main configuration screen is different from the firmware (860C_v1.0.0-beta.1-bootloader.bin
) in the Github release.

In the Github release firmware file :
Image

In my firmware compiled by myself from last version "860C_850C_SW102_v1.0.0-beta.1" :
Image

The "Battery SOC" is missing but there are strange things in the menus "Battery" et "Torque sensor".

In the "Battery" menu, I have a "SOC" item (which redirect to the same screen as "Battery SOC" of the already compiled firmware on the last Github release) :
Image

Source code :

Code: Select all

static Field batteryMenus[] =
		{
						FIELD_EDITABLE_UINT(_S("Max current", "Max curren"), &ui_vars.ui8_battery_max_current, "amps", 1, 20),
						FIELD_EDITABLE_UINT(_S("Low cut-off", "Lo cut-off"), &ui_vars.ui16_battery_low_voltage_cut_off_x10, "volts", 160, 630, .div_digits = 1),
            FIELD_EDITABLE_UINT(_S("Resistance", "Resistance"), &ui_vars.ui16_battery_pack_resistance_x1000, "mohm", 0, 1000),
            FIELD_SCROLLABLE("SOC", batterySOCMenus),
            FIELD_READONLY_UINT(_S("Voltage est", "Voltag est"), &ui_vars.ui16_battery_voltage_soc_x10, "volts", false, .div_digits = 1),
            FIELD_READONLY_UINT(_S("Resistance est", "Resist est"), &ui_vars.ui16_battery_pack_resistance_estimated_x1000, "mohm", 0, 1000),
						FIELD_READONLY_UINT(_S("Power loss est", "Power loss"), &ui_vars.ui16_battery_power_loss, "watts", false, .div_digits = 0),
				FIELD_END };
The "FIELD_SCROLLABLE..." line shouldn't be there but in the "topMenus[]" at the end of the file.

And the "Torque sensor" menu is strange ("Calibration" item appears and some letters are messing up) :
Image

Source code :

Code: Select all

static Field torqueSensorMenus[] =
    {
            FIELD_EDITABLE_UINT(_S("Torque sensor ADC threshold", "Torq s thr"), &ui_vars.ui8_torque_sensor_adc_threshold, "", 5, 75),
            FIELD_EDITABLE_ENUM(_S("Assist w/o pedal rot", "A w/o ped"), &ui_vars.ui8_motor_assistance_startup_without_pedal_rotation, "disable", "enable"), // FIXME, share one array of disable/enable strings
            FIELD_EDITABLE_ENUM(_S("Coast brake", "Coast brak"), &ui_vars.ui8_coast_brake_enable, "disable", "enable"),
            FIELD_EDITABLE_UINT(_S("Coast brake ADC", "Coa bk ADC"), &ui_vars.ui8_coast_brake_adc, "", 5, 255),
            FIELD_SCROLLABLE("Calibration", torqueSensorCalibrationMenus),
        FIELD_END };
The "FIELD_SCROLLABLE..." line shouldn't be there.
And the "torqueSensorMenus" is not available anymore in the compiled firmware of the release. I don't know if it's normal ?

And in the "topMenus[]", this line is missing in order to math the Github release firmware :

Code: Select all

FIELD_SCROLLABLE("Battery", batterySOCMenus),
Last edited by Benoit on May 25 2020 2:30pm, edited 2 times in total.

rcx194   10 mW

10 mW
Posts: 28
Joined: Mar 18 2020 5:29pm

Re: TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

Post by rcx194 » May 25 2020 12:07pm

I'm on version 1.0.0 and I've found that my motor power stays at 220watts. When I first move off, or re-apply pedal power, it will bust to 600+ watts but then settles down at 220w.

Street mode is disabled, and current limit is set to 16 amps. What else should I check.

Post Reply