Tsdz2 firmware open source adapted to vlcd5, vlcd6 and xh18

Electric Motors and Controllers
Waynemarlow   1 kW

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

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

Post by Waynemarlow » Jun 23 2020 2:35pm

Are you sure you wouldn't be better off with something with a bit more oooomph, the poor old TSDZ2 must be having an asthma attack trying to pull that lot around.

Patoruzusos   1 mW

1 mW
Posts: 14
Joined: Jun 11 2020 10:13pm

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

Post by Patoruzusos » Jun 23 2020 3:59pm

Waynemarlow wrote:
Jun 23 2020 2:35pm
Are you sure you wouldn't be better off with something with a bit more oooomph, the poor old TSDZ2 must be having an asthma attack trying to pull that lot around.
Maybe. It was (is) my first and only motor so far, bought 4 years ago. But more than this would probably be a legal problem in the EU.
Still it supported first the huge rear bags, later the fully loaded trailer, and more recently pulling my GF with a hand held bungy on difficult occasional moments (she has no motor, so all the load on me, and I pull her only when she gets too slow). Granted, pulling two slim persons, two bikes, loaded trailer bags with heavy camping equipment uphill I can do it only at low speeds :) Rest of the times the legal restrictions are my limits, not the motor itself.

The only real upgrade since then was a 52T wheelchain, a 11-50T cassette and removing front derailer. Now that I am replacing the blue gear (after 4 years, nylon again), found out and wanted to test what the new firmware could bring to it. And next upgrade/project, as I mentioned, solar power. The battery powers not only the bike but mini fridge, electric blankets, camping lights, phones, laptops, inflatable bed, etc. (I use a 48v - 24v 120W DC - DC converter to power most of the things). I might be pushing it too far, but it works well. and it is modular, so I can keep it as agile or heavy as required.

But honestly speaking, yes, when I bought 2 battery packs (one without cells for the DIY 13s2p) I had already in mind I the option of buying later a second motor kit (same or different depending on the experience) to have both bikes converted. I could move my TSDZ2 to my GF's in the future if you recommend something else for me

7lucky7   1 mW

1 mW
Posts: 12
Joined: Apr 04 2020 10:52am

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

Post by 7lucky7 » Jun 23 2020 4:16pm

For people that have done internal maintainance.

What kind of lubrication do people use and has anyone found a way to reduce the drag caused by the rubber sealant rings on the chainring side?? (It's significantly less without these and the cranks full with gravity, but with them in place much more drag

I've had it apart once to check the blue gear after 1000 miles and regreased inside with lithium grease which sure helped. I was loathed to remove and ride without the rubber seal and find lots of dust or water inside when I next ride. Anyone tried this?

Any tips???

Jim

Waynemarlow   1 kW

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

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

Post by Waynemarlow » Jun 23 2020 4:19pm

Bafang M600 would be ideal but would require a bit of bike surgery.

Pretty impressed that the TSDZ2 even with a 52T front gear can still pull all that kit + girlfriend for 4 years. That motor should go in the hall of fame for abused TSDZ2 engines :)

Waynemarlow   1 kW

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

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

Post by Waynemarlow » Jun 23 2020 4:26pm

7lucky7 wrote:
Jun 23 2020 4:16pm
For people that have done internal maintainance.

What kind of lubrication do people use and has anyone found a way to reduce the drag caused by the rubber sealant rings on the chainring side?? (It's significantly less without these and the cranks full with gravity, but with them in place much more drag

I've had it apart once to check the blue gear after 1000 miles and regreased inside with lithium grease which sure helped. I was loathed to remove and ride without the rubber seal and find lots of dust or water inside when I next ride. Anyone tried this?

Any tips???

Jim
A very large no as it lets water straight into the electronic compartment, end result is new controller, new torque sensor and most bearings.

In my view it is the one design flaw of the engine, the plastic cover holding the seal will wear away with mud and the crank passing it and it will eventually chop the outer seal protector off leaving the seal to eventually work its way out and then the next puddle is catastrophic.

We have looked at making up some sort of ali protector and glueing it onto the outer to give it a bit protection. The last engine rebuild we did we liberally coated the seal area with grease and it helped a lot with drag.

7lucky7   1 mW

1 mW
Posts: 12
Joined: Apr 04 2020 10:52am

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

Post by 7lucky7 » Jun 23 2020 4:32pm

Waynemarlow wrote:
Jun 23 2020 4:26pm
7lucky7 wrote:
Jun 23 2020 4:16pm
For people that have done internal maintainance.

What kind of lubrication do people use and has anyone found a way to reduce the drag caused by the rubber sealant rings on the chainring side?? (It's significantly less without these and the cranks full with gravity, but with them in place much more drag

I've had it apart once to check the blue gear after 1000 miles and regreased inside with lithium grease which sure helped. I was loathed to remove and ride without the rubber seal and find lots of dust or water inside when I next ride. Anyone tried this?

Any tips???

Jim
A very large no as it lets water straight into the electronic compartment, end result is new controller, new torque sensor and most bearings.

In my view it is the one design flaw of the engine, the plastic cover holding the seal will wear away with mud and the crank passing it and it will eventually chop the outer seal protector off leaving the seal to eventually work its way out and then the next puddle is catastrophic.

We have looked at making up some sort of ali protector and glueing it onto the outer to give it a bit protection. The last engine rebuild we did we liberally coated the seal area with grease and it helped a lot with drag.
Thanks!!!

Sounds exactly what I did. Basically grease everywhere but the seals definitely helped quite a bit. Next time I go inside I'll see if I can figure anything else to improve.

Segway but yes it seems incredible durable. I've pulled a trailer of 40kg with me 85kg also on the bike and no issues at all. Just use your gears, don't stomp on the pedals in top gear from a standstill. My blue gear didn't seem to have any problems at 1k if mostly commuting (25 mile in round trip)

Patoruzusos   1 mW

1 mW
Posts: 14
Joined: Jun 11 2020 10:13pm

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

Post by Patoruzusos » Jun 23 2020 9:53pm

Waynemarlow wrote:
Jun 23 2020 4:19pm
Bafang M600 would be ideal but would require a bit of bike surgery.

Pretty impressed that the TSDZ2 even with a 52T front gear can still pull all that kit + girlfriend for 4 years. That motor should go in the hall of fame for abused TSDZ2 engines :)
Remember I have a 11-50T cassette on the back, I can choose a gear for every situation.
In fact, I am changing the blue gear not because it wore out, but because recently another bike hit me sideways directly on the motor while standing at a traffic light on a short city trip (cold motor). 1/3 of the teeth pulverized instantly and became a blueish greasy fiber paste. I can share the gear for the Hall of Fame though :)
bg.jpeg
bg.jpeg (193.49 KiB) Viewed 289 times

7lucky7   1 mW

1 mW
Posts: 12
Joined: Apr 04 2020 10:52am

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

Post by 7lucky7 » Jun 24 2020 5:04am

Patoruzusos wrote:
Jun 23 2020 9:53pm
Waynemarlow wrote:
Jun 23 2020 4:19pm
Bafang M600 would be ideal but would require a bit of bike surgery.

Pretty impressed that the TSDZ2 even with a 52T front gear can still pull all that kit + girlfriend for 4 years. That motor should go in the hall of fame for abused TSDZ2 engines :)
Remember I have a 11-50T cassette on the back, I can choose a gear for every situation.
In fact, I am changing the blue gear not because it wore out, but because recently another bike hit me sideways directly on the motor while standing at a traffic light on a short city trip (cold motor). 1/3 of the teeth pulverized instantly and became a blueish greasy fiber paste. I can share the gear for the Hall of Fame though :)
bg.jpeg
I find it somewhat hard to believe that a single impact did that to your gear but certainly looks like it needs replacing!!!

mbrusa   100 W

100 W
Posts: 132
Joined: Dec 11 2019 12:13am

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

Post by mbrusa » Jun 24 2020 5:20am

Patoruzusos wrote:
Jun 23 2020 11:35am
mbrusa wrote:
Jun 19 2020 8:49am
The max battery capacity is only used to calculate the remaining%. Only one value can be saved in eeprom on shutdown.
You should only change batteries when fully charged, which you can already do.
I am really confused here. My unmodified xh18 calculates the remaining %, without knowing the capacity. How? Furthermore, I seldom charge to 100% (not always practical), I may even charge it for a few minutes while stopping at a restaurant, and the display always shows the remaining %. And the battery pack has additionally inside a 48v circuit board to also calculate the remaining battery, this time not in % but with 5 leds. it also only knows it is powered by a 48V pack. Con someone explain how this works without knowing the capacity and why this firmware needs it? My understanding says one cannot guess capacity level from Voltage level on Li Ion packs.

As I mentioned earlier, I have a city pack (13s2p) and a touring pack (13s and somewhere between 7p and 9p any way to verify this without tearing the pack apart?). I have a trailer and would like to place on top a solar panel to see if I can go touring with my 2p pack. This will be constantly and simultaneously charged/discharged. Will I be getting accurate %? Running out of power with a trailer in some distant mountain could be disastrous :shock:
Patoruzusos you have to understand how the remaining battery% works.
The parameters concerned are:
"Battery power max (Wh)", is the nominal battery capacity, from this value the remaining capacity is calculated.
In your case, you need to set the maximum capacity of the largest battery.

"Battery capacity calibration (%)", for setting the actual battery capacity.
Calibration procedure: With the battery fully charged, check the percentage on the display, it must be 99.9%. At this point, use the bike until the battery is completely exhausted. Check the residual percentage and calculate the effective percentage value (100 - residual value). Set the parameter with this value. Example, final residual percentage 8%, effective capacity 92% 100 - 8.

"Reset soc percentage" (V), voltage value for automatic reset to 99.9% of the percentage of remaining capacity, with battery fully charged. Recommended values ​​from 4.10 to 4.15, otherwise with lower values, after a short turn, if the voltage does not fall below this value, when it is switched on again it resets to 99.9 again.
If desired, it can be done manually by activating the following procedure:
Select the 4-TURBO level and press the light button 2 times within 5 seconds of power on. Now the displayed percentage value will change, the new value will be proportional to the bars (4 or 6). Useful when putting a battery that is not fully charged or the first time it is turned on after flashing.
This% value obtained with manual reset is less precise, because it is based on the voltage value, it is therefore important to set accurate voltage values ​​for the cell bars.
The software calculates the actual consumption by measuring the voltage and current absorbed, but the charging current cannot be measured.
If you charge the battery only partially you have to do a manual reset.
If you replace the battery with a not fully charged one, you have to do the manual reset.
If you set "Battery power max (Wh)" for the largest battery, for example 1000Wh, the percentage will be for this battery.
With the smaller battery, for example 250Wh, the valid percentage will be from 99.9% only when the battery is fully charged, up to 75% with the battery discharged.
The manual reset of the remaining percentage, with the small battery cannot work.
With the small battery you can only check the status of the bars.
Flexible OpenSource firmware for TongSheng TSDZ2 motor and VLCD5 VLCD6 XH18 displays
https://github.com/emmebrusa/TSDZ2-Smart-EBike-1

mbrusa   100 W

100 W
Posts: 132
Joined: Dec 11 2019 12:13am

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

Post by mbrusa » Jun 24 2020 5:56am

kallt_kaffe wrote:
Jun 23 2020 6:47am
Got my STLinkV2 yesterday and have since been trying out this firmware. Still tweaking settings and just did ADC working range calibration. Right pedal measured 130 while left measured 120 so I entered 125 in the configurator. Is that the recommend thing to do or should I go with the lower or higher value?

Also I cannot get the "auto display data with lights on" to work on my display. Manual display of data works if I go into display mode but in set parameter mode with lights on it just goes E02 and the briefly flashes 00.0 a couple of times. It should display battery percentage and voltage as the two first numbers and those are not supposed to be zero. Manually displaying the data shows data as it should. My display (VLDC5) is version 5.0, and allows settings speed limit up to 60km/h instead of the normal 45km/h so I suppose it may work different in some ways compared to older displays. Anyone else seen this?
Strange, if the data display works in manual mode it should also work with the lights on, the procedure is the same.
You only have to press the lights button once, you will see E02 for 5 seconds, then the battery% for 5 seconds and after the voltage for another 5 seconds.
In case it doesn't work, if you can, try posting a video and the ini file.

For the "Pedal torque adc range" value, a slightly higher value is better. You have to find the assistance that suits you in "Torque assist" and "eMTB" mode.
Flexible OpenSource firmware for TongSheng TSDZ2 motor and VLCD5 VLCD6 XH18 displays
https://github.com/emmebrusa/TSDZ2-Smart-EBike-1

Patoruzusos   1 mW

1 mW
Posts: 14
Joined: Jun 11 2020 10:13pm

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

Post by Patoruzusos » Jun 24 2020 6:08am

7lucky7 wrote:
Jun 24 2020 5:04am
I find it somewhat hard to believe that a single impact did that to your gear but certainly looks like it needs replacing!!!
I believe the impact broke only one or a few teeth.
Until the impact, all was fine, but immediately after the motor did a repetitive and constant loud tok tok tok noise.
Probably reaching the missing teeth area, sliding there, and hitting the next tooth hard persistently until pulverized,
After another tooth was gone, the next one must have been be hit even harder (more sliding momentum), creating a small chain reaction. By the time I reached home, many teeth were gone. So far my theory :)

I could place it back and ride for a few more minutes to verify if the next adjacent teeth get destroyed to confirm my theory. But I rather place the new gear and test the new firmware instead :)

P.S. I see now in the picture there is an arrow showing the rotation direction. After a closer physical inspection (but it can be also seen in the pic) the next tooth which would be hit according to this rotation, is almost fully gone, and the next one is starting to be eroded. All other teeth look pretty healthy. So yeah, that feels now even more certain.
Last edited by Patoruzusos on Jun 25 2020 12:13pm, edited 1 time in total.

kallt_kaffe   10 mW

10 mW
Posts: 25
Joined: Jun 06 2020 11:06am

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

Post by kallt_kaffe » Jun 24 2020 8:11am

mbrusa wrote:
Jun 24 2020 5:56am
Strange, if the data display works in manual mode it should also work with the lights on, the procedure is the same.
You only have to press the lights button once, you will see E02 for 5 seconds, then the battery% for 5 seconds and after the voltage for another 5 seconds.
In case it doesn't work, if you can, try posting a video and the ini file.
I reflashed with it enabled again and did a video and I'll try to find a way to share it. Will get back to you when I've done so. Meanwhile the config.h attached aswell as the ini-file.

What happens is that the light turns on and E02 is displayed for a long time then flashes to 00.0 quickly and then back to E02 for a long time again and it keeps doing it over and over again and it seems like it won't stop. After like a minute or so I pressed the light-button again and the it flashes E02 the same way it does when it setting a paramenter. This makes me believe that it actually switched to "off-road"-mode once I finally pressed the light button a second time. As I did this with the bike inside my house I did not actually confirm that but I can do that later if you wish.
mbrusa wrote:
Jun 24 2020 5:56am
For the "Pedal torque adc range" value, a slightly higher value is better. You have to find the assistance that suits you in "Torque assist" and "eMTB" mode.
Ok, so I'll use the higher value, 130, that was given by the right pedal then. I have only tried "Power assist" so far, is the advanced torque mode only used in the torque assist and eMTB modes?
Attachments
config.h
(4.31 KiB) Downloaded 2 times
20200624-145323CEST.ini
(607 Bytes) Downloaded 2 times

kallt_kaffe   10 mW

10 mW
Posts: 25
Joined: Jun 06 2020 11:06am

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

Post by kallt_kaffe » Jun 24 2020 8:31am

mbrusa wrote:
Jun 24 2020 5:56am
try posting a video
And here's the video (I hope): https://gofile.io/d/nEMH5M

You'll probably need to download it and play it in VLC or similar.

kallt_kaffe   10 mW

10 mW
Posts: 25
Joined: Jun 06 2020 11:06am

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

Post by kallt_kaffe » Jun 24 2020 10:09am

mbrusa wrote:
Jun 24 2020 5:56am
Strange, if the data display works in manual mode it should also work with the lights on, the procedure is the same.
I do not have any lights connected but I will try flashing again with lights enabled to see if it makes a difference. I had a look the at the source code and I wonder if these lines in ebike_app.c could be the problem:

Code: Select all

							#if ENABLE_LIGHTS
							// set lights flag
							ui8_lights_flag = 1;
							// lights 5s off		
							ui8_lights_on_5s = 0;
							#endif
The auto-display code seems to expect this flag to be true so maybe it's only set to true if lights are enabled? (I haven't had time to try to understand all the code this is mostly a guess).

EDIT: I ended up changing the code to this and flashing the exact same configuration as before and now auto-display-data works just like expected.

Code: Select all

//							#if ENABLE_LIGHTS
							// set lights flag
							ui8_lights_flag = 1;
							// lights 5s off		
							ui8_lights_on_5s = 0;
//							#endif

mbrusa   100 W

100 W
Posts: 132
Joined: Dec 11 2019 12:13am

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

Post by mbrusa » Jun 24 2020 1:42pm

I only saw it now.
Of course the lights must be enabled.
Flexible OpenSource firmware for TongSheng TSDZ2 motor and VLCD5 VLCD6 XH18 displays
https://github.com/emmebrusa/TSDZ2-Smart-EBike-1

kallt_kaffe   10 mW

10 mW
Posts: 25
Joined: Jun 06 2020 11:06am

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

Post by kallt_kaffe » Jun 24 2020 2:05pm

mbrusa wrote:
Jun 24 2020 1:42pm
I only saw it now.
Of course the lights must be enabled.
Yes, but that I suppose is an error in the code? The auto-display-data-feature should not need external lights to be enabled. I think removing the lines I disabled as described above should do the trick.

Patoruzusos   1 mW

1 mW
Posts: 14
Joined: Jun 11 2020 10:13pm

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

Post by Patoruzusos » Jun 24 2020 2:29pm

mbrusa wrote:
Jun 24 2020 5:20am
Patoruzusos wrote:
Jun 23 2020 11:35am
I am really confused here. My unmodified xh18 calculates the remaining %, without knowing the capacity. How?
Patoruzusos you have to understand how the remaining battery% works.
Hi mbrusa, I read your explanation, and then again. I shook my head and googleducated myself further. Fuel-Gauge ICs, Coulomb meters, smart monitoring, self learning algorithm, different IC chips from TI and others, monitoring of charging, voltage monitoring, etc. I still do not get the theory fully (first I need the theory understanding, later the practical implications for my two batteries)

So lets get firs clear how it works now.
My Battery Pack: I went on and open it to see what it uses, this is what I found
20200624_210146.jpg
20200624_210146.jpg (379.73 KiB) Viewed 222 times
20200624_210017.jpg
20200624_210017.jpg (340.34 KiB) Viewed 222 times
Fuel Gauge indicator, and a no name IC chip configured for 48v.
From the battery it gets only two cables. I guess it measures voltage, has a resistor to measure small currents under different voltage levels, has a self check every time it is powered on, learns and saves top voltages and lowest voltages and with the assistance of the mentioned current meter can more or less guess which voltage represents which charge level.

I guess my current motor/display do something similar, and that is how I get the levels in my xh18. Changing my battery pack does not affect this results because one one hand both packs have it's own fuel gauge circuit, and on the other the current firmware does not care about capacity but voltage, so providing 2p or 9p is irrelevant as long as I always provide 13s and packs with similar cells voltage wise.

The new firmware uses a calibration method instead, which should be more precise, and measures consumption, initial voltage and cut off voltage, and has no self learning algorithms. Since it it uses consumption, it need to know capacity. This is use for the % (a number). For the bars (fuel gauge) the % is also used.

Am I right or I got it totally wrong?

kallt_kaffe   10 mW

10 mW
Posts: 25
Joined: Jun 06 2020 11:06am

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

Post by kallt_kaffe » Jun 25 2020 3:10am

Patoruzusos wrote:
Jun 24 2020 2:29pm
The new firmware uses a calibration method instead, which should be more precise, and measures consumption, initial voltage and cut off voltage, and has no self learning algorithms. Since it it uses consumption, it need to know capacity. This is use for the % (a number). For the bars (fuel gauge) the % is also used.
I haven't checked the code but I suspect the % battery left is using the capacity (TARGET_MAX_BATTERY_CAPACITY) and it resets the %-counter if the voltage is above what is defined with LI_ION_CELL_RESET_SOC_PERCENT. Default is 4.05V which on a 13s-battery means 52.65V.

However, the bars seems to rely only on voltage or else this config seems pointless:

Code: Select all

// full
// Cell voltage full (V)
#define LI_ION_CELL_VOLTS_FULL 3.95
Minimum voltage value to display the complete battery charge status, 4 notches with VLCD6 and XH18
display, 6 notches with VLCD5.
// 4 bars
// Cell voltage 3/4 (V)
#define LI_ION_CELL_VOLTS_3_OF_4 3.85
// Cell voltage 2/4 (V)
#define LI_ION_CELL_VOLTS_2_OF_4 3.55
// Cell voltage 1/4 (V)
#define LI_ION_CELL_VOLTS_1_OF_4 3.25
Voltage value to display intermediate charge states.
From 1 to 3 notches, for VLCD6 and XH18 displays.
// 6 bars
// Cell voltage 5/6 (V)
#define LI_ION_CELL_VOLTS_5_OF_6 3.80
// Cell voltage 4/6 (V)
#define LI_ION_CELL_VOLTS_4_OF_6 3.65
// Cell voltage 3/6 (V)
#define LI_ION_CELL_VOLTS_3_OF_6 3.50
// Cell voltage 2/6 (V)
#define LI_ION_CELL_VOLTS_2_OF_6 3.25
// Cell voltage 1/6 (V)
#define LI_ION_CELL_VOLTS_1_OF_6 3.10
Voltage value to display intermediate charge states.
From 1 to 5 notches, for VLCD5 display.
// empty
//Cell voltage empty (V)
#define LI_ION_CELL_VOLTS_EMPTY 2.90
Voltage value to display the state of the completely discharged battery, 0 notches.
For all these parameters, check the technical characteristics of the cells used.
So the way I look at it (still not having looked at the code) the % left will show wrong number if you switch between batteries with different capacity or partially charge your battery but the bars will still be showing how much battery is left (as they are based on voltage). Also as a last resort you can always choose to display the current voltage of the battery if you do not trust the bars.

Patoruzusos   1 mW

1 mW
Posts: 14
Joined: Jun 11 2020 10:13pm

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

Post by Patoruzusos » Jun 25 2020 4:35am

kallt_kaffe wrote:
Jun 25 2020 3:10am
So the way I look at it (still not having looked at the code) the % left will show wrong number if you switch between batteries with different capacity or partially charge your battery but the bars will still be showing how much battery is left (as they are based on voltage). Also as a aHlast resort you can always choose to display the current voltage of the battery if you do not trust the bars.
That makes sense, and clarifies what mbrusa said before: "With the small battery you can only check the status of the bars"

This would mean:
Bars behave as they always did, Voltage base (and is not a representation of the calculated % in bars)
% which I assume is a number (have not tried the firmware yet) is a new feature, and better for most cases, and it relies additionally on capacity and consumption. Since it cannot measure charging currents, it needs full charges and partial charges will be unaccounted for.

Would it be possible to choose at runtime between two different % calculations, calibrated capacity/consumption based and voltage based? The second would be an interpolation between the predefined voltage levels.

Another idea for the capacity/consumption calculation: If the voltage rises partially (solar charged, few minutes on the grid, etc) it could try to heuristically push the % upwards, maybe getting a hint from the voltage calculation defined levels.

Or maybe a third auto profiling / permanent self calibration/learning method, where the actual capacity of the pack is constantly recalculated based on the current consumption and voltage drop.

Analogously, another feature (I think it is not developed, forgive me if wrong) is autonomy: how many assisted kilometres remain for the current battery level (% or bars) under current consumption/conditions. This is probably more important than the battery level itself, and the ultimate reason why a battery level is shown in the first place.
Last edited by Patoruzusos on Jun 25 2020 11:17am, edited 1 time in total.

mbrusa   100 W

100 W
Posts: 132
Joined: Dec 11 2019 12:13am

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

Post by mbrusa » Jun 25 2020 9:02am

kallt_kaffe wrote:
Jun 24 2020 10:09am
mbrusa wrote:
Jun 24 2020 5:56am
Strange, if the data display works in manual mode it should also work with the lights on, the procedure is the same.
I do not have any lights connected but I will try flashing again with lights enabled to see if it makes a difference. I had a look the at the source code and I wonder if these lines in ebike_app.c could be the problem:

Code: Select all

							#if ENABLE_LIGHTS
							// set lights flag
							ui8_lights_flag = 1;
							// lights 5s off		
							ui8_lights_on_5s = 0;
							#endif
The auto-display code seems to expect this flag to be true so maybe it's only set to true if lights are enabled? (I haven't had time to try to understand all the code this is mostly a guess).

EDIT: I ended up changing the code to this and flashing the exact same configuration as before and now auto-display-data works just like expected.

Code: Select all

//							#if ENABLE_LIGHTS
							// set lights flag
							ui8_lights_flag = 1;
							// lights 5s off		
							ui8_lights_on_5s = 0;
//							#endif
Yes, exactly, in that position the condition #if ENABLE_LIGHTS is not needed.
For lights output, the condition is checked with ui8_lights_state.
Flexible OpenSource firmware for TongSheng TSDZ2 motor and VLCD5 VLCD6 XH18 displays
https://github.com/emmebrusa/TSDZ2-Smart-EBike-1

kallt_kaffe   10 mW

10 mW
Posts: 25
Joined: Jun 06 2020 11:06am

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

Post by kallt_kaffe » Jun 25 2020 3:22pm

Patoruzusos wrote:
Jun 25 2020 4:35am
That makes sense, and clarifies what mbrusa said before: "With the small battery you can only check the status of the bars"

This would mean:
Bars behave as they always did, Voltage base (and is not a representation of the calculated % in bars)
% which I assume is a number (have not tried the firmware yet) is a new feature, and better for most cases, and it relies additionally on capacity and consumption. Since it cannot measure charging currents, it needs full charges and partial charges will be unaccounted for.
Keep in mind that I'm pretty new to this motor and this firmware (only got my STLinkV2 this monday) so this is just me speculating and guessing but I think what you just wrote pretty much sums up how it works. The %-left feature I think should be considered a bonus-feature. Probably requested because voltage drop (still guessing here) isn't completely proportional to the energy spent and maybe it's not even the same curve for all batteries. That said, batteries age and also perform differently in the different temperatures so the %-left algorithm likely have it's limitations as well. In the end I suppose the battery cut-of-voltage you configure and/or the battery cut-off in the BMS in your battery is what will stop you eventually.
Would it be possible to choose at runtime between two different % calculations, calibrated capacity/consumption based and voltage based? The second would be an interpolation between the predefined voltage levels.
Should be possible, or maybe just make it possible to display another value which is the voltage recalculated as %.
Another idea for the capacity/consumption calculation: If the voltage rises partially (solar charged, few minutes on the grid, etc) it could try to heuristically push the % upwards, maybe getting a hint from the voltage calculation defined levels.
Sounds messy. Easier and probably good enough to just do the voltage to percent conversion you suggested above as an alternate way to view the voltage.
Or maybe a third auto profiling / permanent self calibration/learning method, where the actual capacity of the pack is constantly recalculated based on the current consumption and voltage drop.
Sounds like a interesting challenge but likely complicated if it should support switching between batteries with different capacities.
Analogously, another feature (I think it is not developed, forgive me if wrong) is autonomy: how many assisted kilometres remain for the current battery level (% or bars) under current consumption/conditions. This is probably more important than the battery level itself, and the ultimate reason why a battery level is shown in the first place.
Yes, this is something I'd like to see. I'd be OK with just the battery bars and the ability to view voltage if we had this. A DTE-feature (distance to empty) like most cars have today and also many e-bikes like my other bike with a bosch-motor. I may (or may not) have a look at this in the future. Always fun with a challenge and an opportunity to learn new stuff.

mbrusa   100 W

100 W
Posts: 132
Joined: Dec 11 2019 12:13am

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

Post by mbrusa » Jun 26 2020 3:09am

Hi
There are still some aspects that have not been understood. Maybe it's the translation or I haven't explained them well. I try again.
With the battery fully charged and calibration done, the remaining% is very precise because calculated on consumption, I would say +/- 1%. This with the bigger battery.
Even with the smallest battery, if fully charged, an accurate figure is obtained but the% scale changes.
In the previous post I made an example, with 1000Wh the scale will be from 0% to 99.9%, while with 250Wh the scale will be from 75% to 99.9%. With the small battery, zero is 75%!

The display of the consumption through the bars is less precise because it is calculated on the voltage value, but it is independent of the battery capacity.

I explained that after a partial recharge, a manual reset of the remaining% is possible.
It is a hybrid system, the% reset value is calculated on the voltage and is the intermediate one of the current bar, the precision with 4 bars is therefore +/- 12.5%. Subsequently the update of the remaining% is calculated on consumption.
This method only works with the larger battery.

Patoruzusos, to have the remaining% updated accurately even during charging, you need to put an external "Battery columeter" that has this function. Indeed you should put two, one for each battery!
Flexible OpenSource firmware for TongSheng TSDZ2 motor and VLCD5 VLCD6 XH18 displays
https://github.com/emmebrusa/TSDZ2-Smart-EBike-1

Patoruzusos   1 mW

1 mW
Posts: 14
Joined: Jun 11 2020 10:13pm

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

Post by Patoruzusos » Jun 26 2020 9:43am

Hi mbrusa,

yes, some details are sometimes difficult fully get through. But you just confirmed what kallt_kaffe and I finally understood..

Bars are volt based (as the original)
% is a new feature, it needs capacity to subtract consumption, and is more accurate.

The reset became more clear now. It re-calculates the % looking at the voltage, and the provided full capacity. If I want to use two different capacities, I will need to mentally shift my 0% and interpolate the rest.

For the city I would even say that the bars would be enough. Now that I have a better understanding of the theory, I will see which is my most convenient config or configs for me. I have several alternatives depending on how often and where I use each pack. Thanks!

Through this discussion I realized I want the battery status mostly to mentally calculate how long I can still drive (km), as seen in electric (or non electric) cars. That would be a nice consumption based feature to add.

Another idea. Could a self calibration (one full run, from fully charge till cut off) be able to
1) find out the usable/effective capacity (0% being the cut off, not the actual 0)
2) self discover and define 100 voltage values that could be use for bars and % alike
?
This consumption based mapping should give a very close approximation to the implemented % accuracy and also account for partial charges (and even pack changes, I guess, if cells are similar). This would also remove the need of asking the nominal capacity.
mbrusa wrote:
Jun 26 2020 3:09am
to have the remaining% updated accurately even during charging, you need to put an external "Battery columeter" that has this function. Indeed you should put two, one for each battery!
But yes, a coulomb-meter that checks input and output would give the best results of all. I have seen there are many BMS with them integrated, and some of them even with Bluetooth and app. E.g.: https://de.aliexpress.com/item/40008259 ... Hnx54&mp=1
It also gives the remaining time, easy to get the km from there. I guess the provided Bluetooth app will need to be used, or would there be a way to read this info from the UART/CAN ports into the motor controller?

psl2806   1 mW

1 mW
Posts: 10
Joined: Jun 24 2020 10:21am

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

Post by psl2806 » Jun 27 2020 4:43am

Hi, I Have a question about the setting "Battery resistance (milliOhms)"
When I read the wiki it explains how to get this value:
How to start the automatic battery pack resistance estimation:
start with battery already discharged, with any value between 75% and 25%
start pedaling for 10 consecutive seconds, make the motor pull high current value from the battery like 10 amps (use an high assist level). After the 10 seconds you should see a value on the field. For my battery pack of 14S3P 3500 mAh cells, I get a value near 200 milliohm.
repeat the previous step a few times to make sure you always get a similar value
set the measured value Resistance field (I always round up the value)


I'm afraid I don't understand these steps. You have to start pedealing for 10 seconds and then you should see a value on the field. How does this work? Do I have to have the motor connected to my laptop and somehow read this value? Can someone please explain this to me in more detail?
Or can I copy the value from someone else? I have a 48v 17.5A battery connected to a 500 watt motor. The battery is filled with Samsung 35E 3500 mAh cells.
Thanks!

HughF   100 W

100 W
Posts: 148
Joined: Jan 23 2020 6:13pm

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

Post by HughF » Jun 27 2020 7:55am

psl2806 wrote:
Jun 27 2020 4:43am
Hi, I Have a question about the setting "Battery resistance (milliOhms)"
When I read the wiki it explains how to get this value:
How to start the automatic battery pack resistance estimation:
start with battery already discharged, with any value between 75% and 25%
start pedaling for 10 consecutive seconds, make the motor pull high current value from the battery like 10 amps (use an high assist level). After the 10 seconds you should see a value on the field. For my battery pack of 14S3P 3500 mAh cells, I get a value near 200 milliohm.
repeat the previous step a few times to make sure you always get a similar value
set the measured value Resistance field (I always round up the value)


I'm afraid I don't understand these steps. You have to start pedealing for 10 seconds and then you should see a value on the field. How does this work? Do I have to have the motor connected to my laptop and somehow read this value? Can someone please explain this to me in more detail?
Or can I copy the value from someone else? I have a 48v 17.5A battery connected to a 500 watt motor. The battery is filled with Samsung 35E 3500 mAh cells.
Thanks!
I think this feature is only in the latest Casainho code fork which requires an 860c or sw102 display.

Mbrusa can confirm is this feature is available in the fork that runs on the stock displays.
Genesis iOiD Alfine8 Hard tail MTB, 36v TSDZ2, 13s battery, SW102 display
Raleigh reynolds road frame from the 80's, TSDZ2, SW102 display, 1x10 drivetrain, gravel tyres

Post Reply