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

casainho said:
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.
 
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?
 
rcx194 said:
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
 
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.
 
vshitikov said:
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!
 
James Broadhurst said:
vshitikov said:
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 said:
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-firmware/TSDZ2_wiki/wiki/Flash-the-firmware-on-850C-using-SWD
 
wpenner said:
wpenner said:
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-firmware/TSDZ2_wiki/wiki/Flash-the-firmware-on-850C-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)
 
casainho said:
- 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 said:
vshitikov said:
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.
 
wpenner said:
wpenner said:
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-firmware/TSDZ2_wiki/wiki/Flash-the-firmware-on-850C-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.
 
casainho said:
Benoit said:
casainho said:
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 !
 
Benoit said:
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
 
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.
 
vshitikov said:
Benoit said:
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 .
 
wpenner said:
wpenner said:
wpenner said:
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-firmware/TSDZ2_wiki/wiki/Flash-the-firmware-on-850C-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 said:
vshitikov said:
Benoit said:
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).
 
andyme said:
wpenner said:
wpenner said:
wpenner said:
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-firmware/TSDZ2_wiki/wiki/Flash-the-firmware-on-850C-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 said:
andyme said:
wpenner said:
wpenner said:
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-firmware/TSDZ2_wiki/wiki/Flash-the-firmware-on-850C-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
 
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:
 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.
 
benno said:
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:
 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 said:
(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 said:
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.
 
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 :
a49a9ec9ecf06fcbd70cd305402c0985.jpg


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


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) :
2f515f9b8a90e56889c11627a35ea66c.jpg


Source code :
Code:
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) :
ade6917dd35c0ada6ca7645286c48b77.jpg


Source code :
Code:
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:
FIELD_SCROLLABLE("Battery", batterySOCMenus),
 
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.
 
Hi,

I've just updated my motor and SW102 to the latest version (v1.0.0-beta.1, previously I had the v0.8.0) and noticed a bug with the torque calibration.
The menu systematically locks when trying to go below the pedal start, so the calibration data can't be set. It happens if the calibration is activated or not.

I don't know if it's the same issue than the menu lock since it seems to be relatively random but I haven't done a lot of tests.
 
Back
Top