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

Hi casainho,

I will install a TSDZ2 on my bike, with stock firmware for the first days.

Then, I would like to move to your firmware so I have 2 questions :
- Actually, with VLCD5, I have seen a firmware made by qmarco but version 0.16C/D... Is it a good start point ?
- I will buy a new screen. You told about 850C and KT-LCD3. Which one is better to buy ? Is there a good chance to see the firmware for 850C ?

Thank you
 
orfait said:
- I will buy a new screen. You told about 850C and KT-LCD3. Which one is better to buy ? Is there a good chance to see the firmware for 850C ?
Go with KT-LCD3 and 850C firmware is far from having stable version.
 
casainho said:
Go with KT-LCD3 and 850C firmware is far from having stable version.
Nice, I will buy one.
I have read about space limitation for KT-LCD3 microcontroller. That's why I thought it may be better to go with 850C.
Maybe using a STM8S007C8T6 could solve this ?
 
I improved the pedal cadence calculation as also now there is a variable specific about pedaling forward. LCD3 now shows cadence even when rotating pedals backwards but the motor power is cut every time user pedals backwards.

This new code is on master branch but I must plan a new stable version for release.......
 
casainho said:
I improved the pedal cadence calculation as also now there is a variable specific about pedaling forward. LCD3 now shows cadence even when rotating pedals backwards but the motor power is cut every time user pedals backwards.

This new code is on master branch but I must plan a new stable version for release.......

Great news. Thanks Casainho. Let us know when and where we can grab it and I will test it out.
 
casainho said:
I improved the pedal cadence calculation as also now there is a variable specific about pedaling forward. LCD3 now shows cadence even when rotating pedals backwards but the motor power is cut every time user pedals backwards.

This new code is on master branch but I must plan a new stable version for release.......

Hi Casainho, I just read the changes you made to the code and I see that you use the pedal pair directly in case the pedals don't rotate.
I think you should use this method with or without the pedals rotating.
The first reason is that the motor current is directly proportional to the torque, the second reason is that it simplifies the code.
You just need to know the torque constant (N.m/A) of the engine.
In any case, the current code already requires the use of this constant and the gear ratio between pedals and engine (41.8:1 according to this link https://www.electricbike.com/tsdz2-750w-mid-drive-torque-sensing/ ).
 
NIPSEN said:
casainho said:
I improved the pedal cadence calculation as also now there is a variable specific about pedaling forward. LCD3 now shows cadence even when rotating pedals backwards but the motor power is cut every time user pedals backwards.

This new code is on master branch but I must plan a new stable version for release.......

Hi Casainho, I just read the changes you made to the code and I see that you use the pedal pair directly in case the pedals don't rotate.
I think you should use this method with or without the pedals rotating.
The first reason is that the motor current is directly proportional to the torque, the second reason is that it simplifies the code.
You just need to know the torque constant (N.m/A) of the engine.
In any case, the current code already requires the use of this constant and the gear ratio between pedals and engine (41.8:1 according to this link https://www.electricbike.com/tsdz2-750w-mid-drive-torque-sensing/ ).
Thanks for reading my changes.

I must say I didn't understand what you mean, maybe because I miss knowledge about torque, etc.

I can explain what is done o the code:
- we calculate the pedal human power (torque sensor * cadence)
- we multiply assist level factor setup on LCD3 (let's say user setup a factor of 2.0) to pedal human power. Let's say pedal human power is 100 watts, so the result is 100 * 2.0 = 200 watts
- we set the motor power to be previous calculated value, in this example: 200 watts

There is the exception at startup when pedal candence is 0, and so pedal human power is also 0. Here, we use torque sensor value * assist level factor while the pedal candence is 0. As soon there is some pedal rotation, pedal human power is used.
 
casainho said:
NIPSEN said:
casainho said:
I improved the pedal cadence calculation as also now there is a variable specific about pedaling forward. LCD3 now shows cadence even when rotating pedals backwards but the motor power is cut every time user pedals backwards.

This new code is on master branch but I must plan a new stable version for release.......

Hi Casainho, I just read the changes you made to the code and I see that you use the pedal pair directly in case the pedals don't rotate.
I think you should use this method with or without the pedals rotating.
The first reason is that the motor current is directly proportional to the torque, the second reason is that it simplifies the code.
You just need to know the torque constant (N.m/A) of the engine.
In any case, the current code already requires the use of this constant and the gear ratio between pedals and engine (41.8:1 according to this link https://www.electricbike.com/tsdz2-750w-mid-drive-torque-sensing/ ).
Thanks for reading my changes.

I must say I didn't understand what you mean, maybe because I miss knowledge about torque, etc.

I can explain what is done o the code:
- we calculate the pedal human power (torque sensor * cadence)
- we multiply assist level factor setup on LCD3 (let's say user setup a factor of 2.0) to pedal human power. Let's say pedal human power is 100 watts, so the result is 100 * 2.0 = 200 watts
- we set the motor power to be previous calculated value, in this example: 200 watts

There is the exception at startup when pedal candence is 0, and so pedal human power is also 0. Here, we use torque sensor value * assist level factor while the pedal candence is 0. As soon there is some pedal rotation, pedal human power is used.

You're explaining confirms my good reading of the code. Forgive me for expressing myself badly, I'll try to be less confused.

My remark concerns the operation without pedal rotation.

The pedal torque should not be transformed into motor current as you did.

First of all you have to convert the pedal torque into engine torque by dividing it by the gear ratio. Because 1N.m motor equals 41.8N.m pedal on the tsdz2.

Once the motor torque is known, it must be transformed into current thanks to the torque constant of the motor (Kt) in N.m/ampere that I do not know. https://en.m.wikipedia.org/wiki/Motor_constants

Then I said that this calculation method could be applied even when the pedals rotate to simplify the code and make the engine torque independent of the pedal speed measurement, and thus obtain a faster and more accurate calculation.
 
If we consider that tsdz2 run at 4000rpm unloaded with 48V, so Kt = 83.3rpm/V
And the relationship between Kv and Kt, so

Kt=60/(2.pi.Kv)=0.115N.m/A

Ex: for 10N.m on pedals, so 10/41,8 = 0.24N.m engine side.

So I = 0.24/0.115 = 2A

Ex2: for maximum current of 16A
Engine torque = 0.115*16 = 1.84N.m max
Equivalent pedal torque = 1.84*41.8 = 77N.m.
 
We don't need to know the motor torque, as we just want to control the power. If we ignore losses it's just P = U * I. Of course you could take the detour via the mechanical power P = motor-torque * motor-speed, but why should we do that???

For the short moment of applied torque at standstill, the knowledge of the physical ratio of torque at the crank and the torque at the chainwheel has only academical value...

regards
stancecoke
 
stancecoke said:
We don't need to know the motor torque, as we just want to control the power.

I'm not saying you need to know the torque of the engine.
I say that without pedal speed, you "must" have known the gear ratio and the engine torque constant Kt.

stancecoke said:
If we ignore losses it's just P = U * I. Of course you could take the detour via the mechanical power P = motor-torque * motor-speed, but why should we do that???

The use of power is indeed interesting because it allows you not to have to know the gear ratio and the motor torque constant. But, to know the power, you had to use the pedaling speed.

The actual solution:
Pedal Torque * Pedal Speed = Power
Power / Voltage = Current

With my proposal:
Pedal torque * Constants = Current

As you can see, my proposal eliminates the need to know the pedal speed.
That's the benefit.

stancecoke said:
For the short moment of applied torque at standstill, the knowledge of the physical ratio of torque at the crank and the torque at the chainwheel has only academical value...

I wouldn't have said acedemical, but empirical :wink:

There are a large number of solutions, I just wanted to offer you the simplest and most direct, using the least resources, and at the same time share my knowledge with you. :thumb:
 
NIPSEN said:
The actual solution:
Pedal Torque * Pedal Speed = Power
Power / Voltage = Current

With my proposal:
Pedal torque * Constants = Current

You can write also:
Code:
Pedal Torque * Pedal Speed = Power
Power= Voltage * Current

from this follows

Code:
Pedal Torque * Pedal Speed = Voltage * Current

With your suggestion it follows

Code:
Pedal Speed / Voltage = constant

But that's only nearly correct when idling and when you are looking at the phase voltage = dutycycle * battery voltage.

We use battery voltage and DC rail current for calculating the power. I think you will confirm that the battery voltage is not zero when the pedals are at standstill....

regards
stancecoke
 
Hi folks!

I would like to download the open source software to a KT-LCD3 screen and connect the screen/flash to my TSDZ2 motor with throttle. Is there someone who can supply me with the computer link and the wires/cables necessary to do this, please?
I can do most things but whilst I have a soldering iron it's not my favourite pastime and if there's someone who can supply these ready made for me I'd be grateful enough to pay for them. :mrgreen:
 
stancecoke said:
NIPSEN said:
The actual solution:
Pedal Torque * Pedal Speed = Power
Power / Voltage = Current

With my proposal:
Pedal torque * Constants = Current

You can write also:
Code:
Pedal Torque * Pedal Speed = Power
Power= Voltage * Current

from this follows

Code:
Pedal Torque * Pedal Speed = Voltage * Current

With your suggestion it follows

Code:
Pedal Speed / Voltage = constant

But that's only nearly correct when idling and when you are looking at the phase voltage = dutycycle * battery voltage.

We use battery voltage and DC rail current for calculating the power. I think you will confirm that the battery voltage is not zero when the pedals are at standstill....

regards
stancecoke

I don't know exactly where you want to go with this formula, except to check its relevance. Whatever it is, it is still interesting to play with the formulas, and as we can see, the ratio of the regime to tension is constant.
The problem comes rather from the reading you make of it, indeed, by pedal speed you have to see the engine speed, and the voltage is the one applied to the engine.
We simply find that the engine speed is proportional to the voltage applied, i.e. the constant Kv.
 
NIPSEN said:
We simply find that the engine speed is proportional to the voltage applied, i.e. the constant Kv.

Again, this is only correct for idle running. The higher the load, the lower the speed at constant voltage...

regards
stancecoke
 
stancecoke said:
NIPSEN said:
We simply find that the engine speed is proportional to the voltage applied, i.e. the constant Kv.

Again, this is only correct for idle running. The higher the load, the lower the speed at constant voltage...
I think the BEMF voltage varies constantly with the speed. But there is no advantage to calculate it.

I think is great NIPSEN that is trying to give new ideas and yes, at startup we are multipling torque sensor for assist level factor, which is strange because assist level is for a power factor... Anyway, I think would be to confuse to have another factor to configure on LCD3. Also, startup boost can be used for that since it is the factor to multiply torque sensor value at startup.

I really prefer to have as we now pedal power and motor power, because it is easy to explain to user that assist level is a factor that multiplies the user pedal power to get the motor power assistance.
 
WIGHTDIAMOND said:
Hi folks!

I would like to download the open source software to a KT-LCD3 screen and connect the screen/flash to my TSDZ2 motor with throttle. Is there someone who can supply me with the computer link and the wires/cables necessary to do this, please?
I can do most things but whilst I have a soldering iron it's not my favourite pastime and if there's someone who can supply these ready made for me I'd be grateful enough to pay for them. :mrgreen:

You can get everything that you need right here:

https://www.electrifybike.com/store/c37/TSDZ2_Flexible_Open_Source_Firmware_Products.html#/
 
vailbiker said:
WIGHTDIAMOND said:
Hi folks!

I would like to download the open source software to a KT-LCD3 screen and connect the screen/flash to my TSDZ2 motor with throttle. Is there someone who can supply me with the computer link and the wires/cables necessary to do this, please?
I can do most things but whilst I have a soldering iron it's not my favourite pastime and if there's someone who can supply these ready made for me I'd be grateful enough to pay for them. :mrgreen:

You can get everything that you need right here:

https://www.electrifybike.com/store/c37/TSDZ2_Flexible_Open_Source_Firmware_Products.html#/

Cheers VB!
 
casainho said:
I think is great NIPSEN that is trying to give new ideas and yes, at startup we are multipling torque sensor for assist level factor, which is strange because assist level is for a power factor... Anyway, I think would be to confuse to have another factor to configure on LCD3. Also, startup boost can be used for that since it is the factor to multiply torque sensor value at startup.

I really prefer to have as we now pedal power and motor power, because it is easy to explain to user that assist level is a factor that multiplies the user pedal power to get the motor power assistance.

I'm sorry, I'm going to look like the boring guy, but that's fine.
The problem is not to use an assistance factor dedicated to power for a torque. The problem is that you divide torque by voltage to calculate the setpoint current. The consequence is that the current setpoint will be underestimated.
Maybe that explains the need you had to implement the boost?

Secondly, if you directly use the conversion of pedal torque to current then it is not necessary to set up new assistance factors, you can very well use the old ones, a factor is applicable regardless of the unit.

Finally, I agree with you, for the display part, the user must visualize power.

I am very sorry for not sharing my point of view effectively.
 
I'm not sure this is the correct thread but I have a problem with my TDZS2 and I'm hoping someone can give me some pointers.
I have the 36v 8-pin version with VLCD5 which worked fine.
I decided to hook-up a KT-LCD3 and load the open-source firmware.
I bought a new 8-pin cable and soldered it directly onto the KT-LCD motherboard using the pinout in https://github.com/OpenSource-EBike-firmware/TSDZ2_wiki/wiki/Wire-KT-LCD3-to-TSDZ2 (although I had to reverse Tx and Rx).
The solder points on the KT-LCD3 are close together so I checked for shorts between them. I was getting continuity between connectors 1 and 2 ('(P+) battery voltage' and 'Vin') but there was definately no solder connecting them so I assumed this was as per design.

I hooked it all up and flashed the Open Source firmware (18.2) on the LCD3 and TSDZ2 and everything appeared to work (display, speed indicator etc) but there was no powered assistance.

I hooked the VLCD5 back and re-flashed the TDSZ2 to factory firmware but now I have no speed indicated and no power-assist :confused:

Any suggestions?
 
tbyt2000 said:
I'm not sure this is the correct thread but I have a problem with my TDZS2 and I'm hoping someone can give me some pointers.
I have the 36v 8-pin version with VLCD5 which worked fine.
I decided to hook-up a KT-LCD3 and load the open-source firmware.
I bought a new 8-pin cable and soldered it directly onto the KT-LCD motherboard using the pinout in https://github.com/OpenSource-EBike-firmware/TSDZ2_wiki/wiki/Wire-KT-LCD3-to-TSDZ2 (although I had to reverse Tx and Rx).
The solder points on the KT-LCD3 are close together so I checked for shorts between them. I was getting continuity between connectors 1 and 2 ('(P+) battery voltage' and 'Vin') but there was definately no solder connecting them so I assumed this was as per design.

I hooked it all up and flashed the Open Source firmware (18.2) on the LCD3 and TSDZ2 and everything appeared to work (display, speed indicator etc) but there was no powered assistance.

I hooked the VLCD5 back and re-flashed the TDSZ2 to factory firmware but now I have no speed indicated and no power-assist :confused:

Any suggestions?
Go back to OpenSource firmware and tell us the values you see in 12 menu of options. We need to know if torque sensor is working and pwm value
 
tbyt2000 said:
I'm not sure this is the correct thread but I have a problem with my TDZS2 and I'm hoping someone can give me some pointers.
I have the 36v 8-pin version with VLCD5 which worked fine.
I decided to hook-up a KT-LCD3 and load the open-source firmware.
I bought a new 8-pin cable and soldered it directly onto the KT-LCD motherboard using the pinout in https://github.com/OpenSource-EBike-firmware/TSDZ2_wiki/wiki/Wire-KT-LCD3-to-TSDZ2 (although I had to reverse Tx and Rx).
The solder points on the KT-LCD3 are close together so I checked for shorts between them. I was getting continuity between connectors 1 and 2 ('(P+) battery voltage' and 'Vin') but there was definately no solder connecting them so I assumed this was as per design.

I hooked it all up and flashed the Open Source firmware (18.2) on the LCD3 and TSDZ2 and everything appeared to work (display, speed indicator etc) but there was no powered assistance.

I hooked the VLCD5 back and re-flashed the TDSZ2 to factory firmware but now I have no speed indicated and no power-assist :confused:

Any suggestions?

Are you 100% certain that you didn’t cut the end off the display cable while it was still connected to the motor? There is enough charge in the capacitors of the controller to cause it to be damaged if any wires are shorted even with your battery disonnected. I saw something very similar on a build recently. No pedal assist, but everything else appeared normal. I ended up replacing the controller to fix it.
 
Rydon, please test the new version: https://github.com/OpenSource-EBike-firmware/TSDZ2-Smart-EBike/releases/tag/v0.19.0-beta1

When pedaling backwards, motor power is cut off. Note that the motor resistance is still there.

Can you please tell if you expect that motor goes to 0 velocity before goes backwards when user brakes with coast brakes?? I am thinking on the next step...
 
NIPSEN said:
casainho said:
I think is great NIPSEN that is trying to give new ideas and yes, at startup we are multipling torque sensor for assist level factor, which is strange because assist level is for a power factor... Anyway, I think would be to confuse to have another factor to configure on LCD3. Also, startup boost can be used for that since it is the factor to multiply torque sensor value at startup.

I really prefer to have as we now pedal power and motor power, because it is easy to explain to user that assist level is a factor that multiplies the user pedal power to get the motor power assistance.

I'm sorry, I'm going to look like the boring guy, but that's fine.
The problem is not to use an assistance factor dedicated to power for a torque. The problem is that you divide torque by voltage to calculate the setpoint current. The consequence is that the current setpoint will be underestimated.
Maybe that explains the need you had to implement the boost?

Secondly, if you directly use the conversion of pedal torque to current then it is not necessary to set up new assistance factors, you can very well use the old ones, a factor is applicable regardless of the unit.

Finally, I agree with you, for the display part, the user must visualize power.

I am very sorry for not sharing my point of view effectively.
I think there are some things here:
1. we do not have an issue right now, you suggestion is for an optimization but we are not in need use it
2. I think I miss the knowledge of math to fully understand the advantages of using your proposal
 
casainho said:
Rydon, please test the new version: https://github.com/OpenSource-EBike-firmware/TSDZ2-Smart-EBike/releases/tag/v0.19.0-beta1
Ok, is there any documentation for the menus in version 19?
casainho said:
When pedaling backwards, motor power is cut off. Note that the motor resistance is still there.
If you know the motor resistance is still there, what am I testing?
casainho said:
Can you please tell if you expect that motor goes to 0 velocity before goes backwards when user brakes with coast brakes?? I am thinking on the next step...
By velocity do you mean rpms? Yes, the motor completely stops before pedaling backward.

That motor I sent you that got stuck in customs was a coaster brake motor. They returned it after about 6 months. Should I try sending it again?
 
Back
Top