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

casainho said:
EndlessCadence said:
Btw, do you have time to review this PR? https://github.com/OpenSource-EBike-firmware/TSDZ2-Smart-EBike/pull/16
I've created a preprocessor switch/macro to choose between throttle and non-throttle version of the firmware. Release script builds both and the hexfiles (0.14.1) are included as well.
The code seems ok to me, and I like it lie being more modular.

Code:
apply_throttle (ui8_throttle, &ui8_startup_enable, &ui8_adc_battery_target_current);

static void apply_throttle (uint8_t ui8_throttle_value, uint8_t *ui8_motor_enable, uint8_t *ui8_target_current)	#if THROTTLE
{
I suggest you to keep the right variable names. You pass the address of ui8_adc_battery_target_current but inside you call it ui8_target_current. On the firmware, there are moments were current is used in amps and others where current is ADC steps. The right name should help to read correctly the code and avoid mistakes.
Thanks, then I'll complete the PR to fix the potential safety issue with throttle/temperature sensor.

Regarding the variable names, I did this on purpose to clearly indicate it's a local variable/parameter. In my opinion the code has way too many global symbols and variables but I understand your concern and will take care of it :wink:
 
EndlessCadence said:
casainho said:
EndlessCadence said:
Btw, do you have time to review this PR? https://github.com/OpenSource-EBike-firmware/TSDZ2-Smart-EBike/pull/16
I've created a preprocessor switch/macro to choose between throttle and non-throttle version of the firmware. Release script builds both and the hexfiles (0.14.1) are included as well.
The code seems ok to me, and I like it lie being more modular.

Code:
apply_throttle (ui8_throttle, &ui8_startup_enable, &ui8_adc_battery_target_current);

static void apply_throttle (uint8_t ui8_throttle_value, uint8_t *ui8_motor_enable, uint8_t *ui8_target_current)	#if THROTTLE
{
I suggest you to keep the right variable names. You pass the address of ui8_adc_battery_target_current but inside you call it ui8_target_current. On the firmware, there are moments were current is used in amps and others where current is ADC steps. The right name should help to read correctly the code and avoid mistakes.
Thanks, then I'll complete the PR to fix the potential safety issue with throttle/temperature sensor.

Regarding the variable names, I did this on purpose to clearly indicate it's a local variable/parameter. In my opinion the code has way too many global symbols and variables but I understand your concern and will take care of it :wink:
I think you know why I am obligated to use so many global variables, that is due to a limitation of SDCC.
 
EndlessCadence said:
casainho said:
I think you know why I am obligated to use so many global variables, that is due to a limitation of SDCC.
I don't know what you mean exactly. Passing variables by reference works without issue as far as I know? But I'm interested to know about the limitation of SDCC :wink:
I mean what I wrote on main.c about static local variables inside functions that can't be initialized to a non zero value or SDDC g8vea an error.
 
casainho said:
EndlessCadence said:
casainho said:
I think you know why I am obligated to use so many global variables, that is due to a limitation of SDCC.
I don't know what you mean exactly. Passing variables by reference works without issue as far as I know? But I'm interested to know about the limitation of SDCC :wink:
I mean what I wrote on main.c about static local variables inside functions that can't be initialized to a non zero value or SDDC g8vea an error.
Ah okay, yes I knew that and I'm not complaining about it :wink:
 
casainho said:
.

As we can see, it is easy to get the motor at very high temperatures (inside the motor should be even hot!). I think that looking at your and my values, motor temperature sensor is a must.

So if this a problem even on a casual ride, does this mean with temp sensor we will effectively be running at reduced power virtually all the time? Seems to me a pretty serious deficiency with the TSDZ2.

Are there any modifications we could make to the motor to cool it during use?
 
I have been reading this post and everything I can get my hands on about this motor. What is the gear ratio between the motor and the chain ring? The bafang boasts 21.9:1 but it is much more expensive. Does it come in a 700 watt version (rms) or are all these kits I read about just 500 watts rms and 700 max? I been lookin' and I am struggling to find these details.

peace,
Victor Reppeto
Turner, Or
P.S. I can't wait to try this custom firmware.

I just located post 1388947 and it says the gear ratio is 41.4:1! Wow! That's double the Bafang!

vscope said:
I checked some images on the web.
fetch

index.php

PSWPOWER-Main-gear-lager-inkl-f-r-TSDZ2-elektro-fahrrad-zentralen-mittelmotor.jpg


Seems like gear ratio is:
outside 92/10
Inner wheel: 36/8
So all in all

92/10
36/8

9.2 * 4.5 = 41,4 / 1 ration
so 4000rpm / 41.4 = 96rpm cadence

so with the 48v motor i will reach 4000rpm/96rpm with full 13s battery and 2800rpm/68rpm (70%) with empty battery?
and with 36v motor i will reach 4000rpm/96rpm with full 13s battery and the same with empty battery?
is that correct?
 
vreppeto said:
I have been reading this post and everything I can get my hands on about this motor. What is the gear ratio between the motor and the chain ring? The bafang boasts 21.9:1 but it is much more expensive. Does it come in a 700 watt version (rms) or are all these kits I read about just 500 watts rms and 700 max? I been lookin' and I am struggling to find these details.

peace,
Victor Reppeto
Turner, Or
P.S. I can't wait to try this custom firmware.

Victor there are 2 different motors with different windings. Both are set up to do about 4000rpm at full voltage at around 90 cadence. The 48v motor should be able to handle 750w for a short while, I was running my 36v at 600w for some time on the way home. I have boosted my cadence up to 120 which is great for the riding I do both on the road and off. It does heat up if you push it. That’s why I have installed the temperature sensor and I can keep an eye on what is going on. You would really only buy this motor if you want torque sensing, all the new bikes are all torque sensing these days and it’s a natural way of riding an ebike. I think PAS really sucks and it’s dangerous in areas with lots of pedestrian traffic. My friends who have the bbs02 like riding at 50km/hr without putting in any effort and they scoff when I tell them I ride at 32. If you are even thinking about a Bafang then this is probably the wrong motor for you.

Spiked, would be great if we could conduct some heat between the motor and motor casing ? Any ideas ?
 
jbalat said:
Victor there are 2 different motors with different windings. Both are set up to do about 4000rpm at full voltage at around 90 cadence. The 48v motor should be able to handle 750w for a short while, I was running my 36v at 600w for some time on the way home. I have boosted my cadence up to 120 which is great for the riding I do both on the road and off. It does heat up if you push it. That’s why I have installed the temperature sensor and I can keep an eye on what is going on. You would really only buy this motor if you want torque sensing, all the new bikes are all torque sensing these days and it’s a natural way of riding an ebike. I think PAS really sucks and it’s dangerous in areas with lots of pedestrian traffic. My friends who have the bbs02 like riding at 50km/hr without putting in any effort and they scoff when I tell them I ride at 32. If you are even thinking about a Bafang then this is probably the wrong motor for you.

Spiked, would be great if we could conduct some heat between the motor and motor casing ? Any ideas ?

That 41.6:1 gear ratio is just what I am looking for. The torque sensing acceleration is perfect especially combined with a internally geared wide range rear hub, then I can keep the cadence between 60 and 90 and still cut my commute time in half. I commute 20k between Turner and Salem. The custom firmware you all have developed is greatly appreciated.

Cooling? A liquid cooling system similar to a pc or laptop maybe? There is enough room for small fins but I am really jealous with the clearance under my bb. If it were modeled after an evaporative refrigeration system or used convection then no pump would be necessary.
 
casainho said:
kortina said:
casainho said:
kortina said:
Reconnected the LCD and Battery, turned on and setup the 52v parameters.

Still no luck, same deal as yesterday... LCD shows voltage, and accurate speed, but no power.
What you mean by no power? For motor to start, you need to use throttle or apply force on pedal for the torque sensor -- maybe some of this parts are failing on your hardware??

No throttle attached. I have taken it for a test ride and applied plenty of torque.
I also used menu 9 to read out the Torque Sensor values, and I can see these move as I apply force.
Strangely 9,0 (ADC Throttle) was jumping between 8 and 9. Is this normal?

How do I clear the options bytes tab?
Please look at duty-cycle value on menu 9, while you apply torque and report.

Also verify/read the option bytes and make sure they are correct with PWM enable.

Flashed 14.1 to the motor and lcd. Uploaded a default 'option' tab (just after opening STVP).

The Menu 9,6 - PWM duty cycle stays at 0 when I attempt to ride (any torque level that I apply)

I looked at the option list and could find PWM enable ?
Can someone list the options that I should set? (or send a file?)

Thanks again for your persistence.
 
kortina said:
casainho said:
kortina said:
casainho said:
What you mean by no power? For motor to start, you need to use throttle or apply force on pedal for the torque sensor -- maybe some of this parts are failing on your hardware??

No throttle attached. I have taken it for a test ride and applied plenty of torque.
I also used menu 9 to read out the Torque Sensor values, and I can see these move as I apply force.
Strangely 9,0 (ADC Throttle) was jumping between 8 and 9. Is this normal?

How do I clear the options bytes tab?
Please look at duty-cycle value on menu 9, while you apply torque and report.

Also verify/read the option bytes and make sure they are correct with PWM enable.

Flashed 14.1 to the motor and lcd. Uploaded a default 'option' tab (just after opening STVP).

The Menu 9,6 - PWM duty cycle stays at 0 when I attempt to ride (any torque level that I apply)

I looked at the option list and could find PWM enable ?
Can someone list the options that I should set? (or send a file?)

Thanks again for your persistence.
Which 14.1 version are you using? Keep in mind that the 14.1 non-throttle version still needs some testing.

Use version 14.0 for a better tested version.
 
EndlessCadence said:
kortina said:
casainho said:
kortina said:
No throttle attached. I have taken it for a test ride and applied plenty of torque.
I also used menu 9 to read out the Torque Sensor values, and I can see these move as I apply force.
Strangely 9,0 (ADC Throttle) was jumping between 8 and 9. Is this normal?

How do I clear the options bytes tab?
Please look at duty-cycle value on menu 9, while you apply torque and report.

Also verify/read the option bytes and make sure they are correct with PWM enable.

Flashed 14.1 to the motor and lcd. Uploaded a default 'option' tab (just after opening STVP).

The Menu 9,6 - PWM duty cycle stays at 0 when I attempt to ride (any torque level that I apply)

I looked at the option list and could find PWM enable ?
Can someone list the options that I should set? (or send a file?)

Thanks again for your persistence.
Which 14.1 version are you using? Keep in mind that the 14.1 non-throttle version still needs some testing.

Use version 14.0 for a better tested version.

I attempted to use 14.1 (no throttle).
 
kortina said:
The Menu 9,6 - PWM duty cycle stays at 0 when I attempt to ride (any torque level that I apply)
Then something is wrong... when you apply torque on the pedals AND rotate the pedal (with the default configurations on LCD3), the duty_cycle should increase to values like at least over 50 up to 255 and then the motor should rotate.

If your torque sensor is working as you verified before, I would say is something wrong on your configurations of LCD3. Please put the full list of configurations and justify each configuration because of the hardware you have, etc, so we can review that they are correct.

Also, report here the full list values of menu 9, when no pedaling and values when you pedal with torque.
 
Kortina, do me a favour and flash my version
I have all the files for every tab so just take it in turn 1 tab at a time, do not do flash all.
https://endless-sphere.com/forums/viewtopic.php?f=30&t=93818&start=675#p1417561
Make sure each tab is verified after flashing.

I had the same problem as you but somehow I got my motor working again, just can’t remember exactly what i did
 
casainho said:
kortina said:
The Menu 9,6 - PWM duty cycle stays at 0 when I attempt to ride (any torque level that I apply)
Then something is wrong... when you apply torque on the pedals AND rotate the pedal (with the default configurations on LCD3), the duty_cycle should increase to values like at least over 50 up to 255 and then the motor should rotate.

If your torque sensor is working as you verified before, I would say is something wrong on your configurations of LCD3. Please put the full list of configurations and justify each configuration because of the hardware you have, etc, so we can review that they are correct.

Also, report here the full list values of menu 9, when no pedaling and values when you pedal with torque.

Reflashed to v14.0 (Screen and Motor)
Set the following:
1,0 = 16 (left the default, I am sure my battery can do 25A)
1,1 = 42.0 (because I have a 14cell battery and 42v / 14cells = 3.0 (which is the lowest I should take my panasonic cells)
1,2 = 14 (Because I have a 14s4p 52v battery)
1,3 = 130 (left default as I am not sure)

Diag - When stationary
9,0 = 9
9,1 = 0
9,2 = 39
9,3 = 0
9,4 = 0
9,5 = 0
9,6 = 0
9,7 = 0
9,8 = 1

Diag - When pedalling
9,0 = 9
9,1 = 0
9,2 = between 40 and 71 (71 when pushing HARD)
9,3 = between 0 and 233 (233 when pushing hard), only triggers when from standing start, then stays 0
9,4 = 0
9,5 = 0
9,6 = 0
9,7 = 0 mostly... Spikes to 7 after coming OFF torque
9.8 = 1 (dipped to 0 for a fraction of a sec)
 
kortina said:
casainho said:
kortina said:
The Menu 9,6 - PWM duty cycle stays at 0 when I attempt to ride (any torque level that I apply)
Then something is wrong... when you apply torque on the pedals AND rotate the pedal (with the default configurations on LCD3), the duty_cycle should increase to values like at least over 50 up to 255 and then the motor should rotate.

If your torque sensor is working as you verified before, I would say is something wrong on your configurations of LCD3. Please put the full list of configurations and justify each configuration because of the hardware you have, etc, so we can review that they are correct.

Also, report here the full list values of menu 9, when no pedaling and values when you pedal with torque.

Reflashed to v14.0 (Screen and Motor)
Set the following:
1,0 = 16 (left the default, I am sure my battery can do 25A)
1,1 = 42.0 (because I have a 14cell battery and 42v / 14cells = 3.0 (which is the lowest I should take my panasonic cells)
1,2 = 14 (Because I have a 14s4p 52v battery)
1,3 = 130 (left default as I am not sure)

Diag - When stationary
9,0 = 9
9,1 = 0
9,2 = 39
9,3 = 0
9,4 = 0
9,5 = 0
9,6 = 0
9,7 = 0
9,8 = 1

Diag - When pedalling
9,0 = 9
9,1 = 0
9,2 = between 40 and 71 (71 when pushing HARD)
9,3 = between 0 and 233 (233 when pushing hard), only triggers when from standing start, then stays 0
9,4 = 0
9,5 = 0
9,6 = 0
9,7 = 0 mostly... Spikes to 7 after coming OFF torque
9.8 = 1 (dipped to 0 for a fraction of a sec)
9,4 is cadence which is 0 when you pedal, which should not happen and this justify why you have only spikes of duty_cycle.

Please enable 8.1 (Motor assistance startup without pedal rotation)!! and let's see what you get.

Did you even run this motor with original firmware? are you sure the PAS sensor do work?
 
9,4 is cadence which is 0 when you pedal, which should not happen and this justify why you have only spikes of duty_cycle.

Please enable 8.1 (Motor assistance startup without pedal rotation)!! and let's see what you get.

Did you even run this motor with original firmware? are you sure the PAS sensor do work?

Progress!

Bumping the assistance up to 9. When taking off I get a short spike of power to 140w. This lasts for about a second then dies off.

Yes I had the original 52v VLCD and 52v (750w) motor. They worked well for 400km, it was awesome to ride... but couldnt help myself to tweak it.

Did the pedal rotation sensor die when I cut the original VLCD cord (with the battery attached)...
 
kortina said:
9,4 is cadence which is 0 when you pedal, which should not happen and this justify why you have only spikes of duty_cycle.

Please enable 8.1 (Motor assistance startup without pedal rotation)!! and let's see what you get.

Did you even run this motor with original firmware? are you sure the PAS sensor do work?

Progress!

Bumping the assistance up to 9. When taking off I get a short spike of power to 140w. This lasts for about a second then dies off.

Yes I had the original 52v VLCD and 52v (750w) motor. They worked well for 400km, it was awesome to ride... but couldnt help myself to tweak it.

Did the pedal rotation sensor die when I cut the original VLCD cord (with the battery attached)...
So, your PAS sensor is not working (and I would say, as you expect, cut the electric cables with battery attached is a wrong idea!! Because there is battery power on that cable including wires that goes to sensitive parts of the motor controller!!).

What you can do, is ask to EC to prepare an option on LCD3 where the system uses only the torque sensor as input and ignores the cadence value. Torque sensor signal would be seen as a throttle signal.
I must say I would like to have this option also, use torque sensor only because on trails it may make more sense... and maybe some users may prefer that option.
Also, there are users as me that got a new TSDZ2 without torque sensor working but with PAS sensor working, would be great to have also an option to do the contrary, ignore torque sensor and use only pedal cadence.
 
casainho said:
kortina said:
9,4 is cadence which is 0 when you pedal, which should not happen and this justify why you have only spikes of duty_cycle.

Please enable 8.1 (Motor assistance startup without pedal rotation)!! and let's see what you get.

Did you even run this motor with original firmware? are you sure the PAS sensor do work?

Progress!

Bumping the assistance up to 9. When taking off I get a short spike of power to 140w. This lasts for about a second then dies off.

Yes I had the original 52v VLCD and 52v (750w) motor. They worked well for 400km, it was awesome to ride... but couldnt help myself to tweak it.

Did the pedal rotation sensor die when I cut the original VLCD cord (with the battery attached)...
So, your PAS sensor is not working (and I would say, as you expect, cut the electric cables with battery attached is a wrong idea!! Because there is battery power on that cable including wires that goes to sensitive parts of the motor controller!!).

What you can do, is ask to EC to prepare an option on LCD3 where the system uses only the torque sensor as input and ignores the cadence value. Torque sensor signal would be seen as a throttle signal.
I must say I would like to have this option also, use torque sensor only because on trails it may make more sense... and maybe some users may prefer that option.
Also, there are users as me that got a new TSDZ2 without torque sensor working but with PAS sensor working, would be great to have also an option to do the contrary, ignore torque sensor and use only pedal cadence.

@EndlessCadence
Any chance of adding the extra option so that I can keep using my motor?
I have only put 400km on it :(

Is there a chance that the cadence sensor is different on the 52v version?

I did notice that with the original firmware I needed to change gear early as the assistance would stop after about a Cadence of 65ish? rpm. Maybe is was just the torque dropping off... or maybe I never had a functioning cadence sensor and the default firmware can rely on torque only?

Thanks again for the 'Endless' work by yourself, Casainho, Jbalat who take the time to not only create awesome stuff but also help noobs (like me).
 
kortina said:
@EndlessCadence
Any chance of adding the extra option so that I can keep using my motor?
I have only put 400km on it :(

Is there a chance that the cadence sensor is different on the 52v version?

I did notice that with the original firmware I needed to change gear early as the assistance would stop after about a Cadence of 65ish? rpm. Maybe is was just the torque dropping off... or maybe I never had a functioning cadence sensor and the default firmware can rely on torque only?

Thanks again for the 'Endless' work by yourself, Casainho, Jbalat who take the time to not only create awesome stuff but also help noobs (like me).
I have an idea: on LCD3, set max pedal as being 1 or 0, maybe with zero it will work as if pedal cadence is at max value...

Cadence sensor is for sure equal/only one. What you can try is to take out the motor controller and verify if the connector of the sensor to the board is ok and mayne it is slightly removed.
 
@EndlessCadence,

Yesterday I rode using V0.14.1 and I noted some issues:

1. Max power works but seems it is at wrong scale, I need to increase maybe 10x more to get a good value. Before this feature was working well so it was some change after.

2. EEPROM reset: for some reason, still fails. I don't know if it is the resetting process or the after process of writing the default values. Maybe one important thing was to have LCD3 show installed firmware version of motor and LCD so I could assure I have installed the correct versions.

3. Startup power fails a LOT when I enable boost. Again, It was not like that when I implemented this feature.

I will give a look at code to see if I can spot the reasons for this issues.
 
casainho said:
@EndlessCadence,

Yesterday I rode using V0.14.1 and I noted some issues:

1. Max power works but seems it is at wrong scale, I need to increase maybe 10x more to get a good value. Before this feature was working well so it was some change after.

2. EEPROM reset: for some reason, still fails. I don't know if it is the resetting process or the after process of writing the default values. Maybe one important thing was to have LCD3 show installed firmware version of motor and LCD so I could assure I have installed the correct versions.

3. Startup power fails a LOT when I enable boost. Again, It was not like that when I implemented this feature.

I will give a look at code to see if I can spot the reasons for this issues.
Thanks for testing!

1. I had issues with max power since a while time, for sure also when it was in the "old" repository. I have already opened an issue on Github: https://github.com/OpenSource-EBike-firmware/TSDZ2-Smart-EBike/issues/13

2. I'm suprised, why does it fail for you? I've used it a lot recently and it worked every time, I always verified the results. It is also implemented according to the documentation and examples from ST micro.

3. What do you mean by startup power? I do not use boost as I don't like it but I've tested it and it felt exactly like the first time I ever used it...

Would be great if you could find the reason for issue 1! I've analyzed the problem a little but I can't find the reason, I agree that it must be a scaling issue.
 
EndlessCadence said:
2. I'm suprised, why does it fail for you? I've used it a lot recently and it worked every time, I always verified the results. It is also implemented according to the documentation and examples from ST micro.

3. What do you mean by startup power? I do not use boost as I don't like it but I've tested it and it felt exactly like the first time I ever used it...
2. I need to test again, but I see fields with wrong values. For instance, 2.2 (Voltage to reset Wh counter) has a value of 352.2!! I can't increase but only decrease the value.
You know, I have the code commented that at startup checks for valid ranges of values and set to defaults if the check fails. I have the code commented because last features I did in an hurry and did not want to use time to maintain it. Maybe it is a good investment, as it would solve my issue.

3. When I press the pedals, I see that I only get assist after the boot time pass... that was happening before but very few times, now happens almost always.
 
Back
Top