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

vailbiker said:
I have the 36V volt TSDZ2 that I have been using for about a year. I love the system and am really looking forward to running the open source firmware. I have hit a road block while trying to flash the LCD3. I'm using STVP 3.2.7 right now but have also tried the latest version. Every time I try to communicate the the LCD3. I get a message that says "Cannot Communicate with the device ! Check the SWIM cable connection and check all the needed pin connections on the SWIM connector." The display powers up and I am able to communicate with the ST-Link which I verified by running the upgrade ST-Link utility and clicking on device connect. It reads the firmware version as
V2.J16.S4 JTAG+SWIM Debugger.


Things I've tried so far:

Setup software and hardware on a completely different Windows 10 workstation
Replaced the clone ST-Link V2 with a new one
Shorter cables between the LCD3 and ST-Link - currently at 6 inches
Plug ST-Link directly into USB port on computer without an extension cable
Different versions of STVP
ST-Link drivers
Triple checked wiring using https://github.com/OpenSource-EBike-firmware/TSDZ2_wiki/wiki/How-to-flash-the-Flexible-OpenSource-firmware-on-KT-LCD3 and Jbalatutube's youtube video.

Does anyone have any other suggestions for troubleshooting? Thanks!

Hi,

I had similar problems when I tried to flash the open source firmware to my bike. :wink:

First of all, I have to say that the imaging in the wiki is partly incomplete and that you have to look at the plug layout carefully from several videos and sources together to get all the connections working - and maybe this is your problem as well. I do not know how complete your information is. Then it was a problem that the v2 clone was not working well. After I bought another one and tried another dealer too, I've got a different clon, that is different with the swim/gnd pin assignment. Maybe the pin assignment printing from the first clone is wrong - I've not checked it so far - just some cheap chinese scrap to throw it into trash..

I hope this helps you any further.
 
Casainho, I have run out of time today but will do the changes tomorrow and test the next day riding to work.

So my friends and I always talk ebikes on our lunch time walk and we debated this same issue

We thought the motor is going to apply power slowly but then needs to look at the cadence, if the cadence goes up then continue, if it is still going down then apply more but only based on a maximum value dependant on that cadence.

For instance 500w at a cadence of 30 will probably skip the chain and wear out the cassette but 1000w at 80 cadence is not an issue !!

Anyway if the motor keeps applying power and you hit the programmed max then just give up, the hill must be too steep, just back off the power to a nominal value and let the guy change down to a lower gear.

It’s really just emulating what you would do yourself on a bike that doesn’t have a motor.
 
Hi casainho,

Any idea when an official release will be done on the new features?
I am really curious how the new power delivery function feels. :) I could run some tests from the master branch if some more validation is needed.

Thanks for the significant effort to make this!

@jbalat I just love your videos. The Tsdz2 original review that you made is the reason I bought it :)
 
jbalat said:
Casainho, I have run out of time today but will do the changes tomorrow and test the next day riding to work.

So my friends and I always talk ebikes on our lunch time walk and we debated this same issue

We thought the motor is going to apply power slowly but then needs to look at the cadence, if the cadence goes up then continue, if it is still going down then apply more but only based on a maximum value dependant on that cadence.
On my test rides, with the current ramp code, I tested with 3 amps / second increase rate and it is clearly slow to increase the power so I do not recommend that rate, only higher values, maybe 8 amps / second or even higher.

Also, looking at ERPs value I can clearly see that it fast jumps from 0 to values like 400 as expected on the situations when the lag would happen before. So i think the lag is mostly gone but I am not the right guy to validate as that lag were not an issue to me.

I will stop the development here, if you guys want more developments you will need to do by yourself or find other developers. I will now start the color LCD firmware development and for TSDZ2 motor I just want to implement the walk assist and solve the 1 issue about startup power boost.
 
maximusdm said:
Hi casainho,

Any idea when an official release will be done on the new features?
I am really curious how the new power delivery function feels. :) I could run some tests from the master branch if some more validation is needed.
The release is around the corner, probably today? :D
I'm currently testing, preparing and writing the documentation, see: https://github.com/OpenSource-EBike...-and-configuration-of-firmware-version-0.15.x

I think this will be a great release!

Unfortunately, walk assist isn't included yet. It's mostly implemented but still a bit rough, we should be able to release this soon.

I also want to revisit the offroad mode in the coming days. It's not very clear for most users and the configuration should be improved.
 
acoustics said:
First of all, I have to say that the imaging in the wiki is partly incomplete and that you have to look at the plug layout carefully from several videos and sources together to get all the connections working - and maybe this is your problem as well. I do not know how complete your information is. Then it was a problem that the v2 clone was not working well. After I bought another one and tried another dealer too, I've got a different clon, that is different with the swim/gnd pin assignment. Maybe the pin assignment printing from the first clone is wrong - I've not checked it so far - just some cheap chinese scrap to through into trash..

I hope this helps you any further.

What imaging would you ideally add? I’m nearly done with all my wiring and would be happy to supply any supplemental photos.

I spent a lot of prep time in the weeks leading up to my supplies arriving and have a lot of different posts, photos and videos stashed away in Evernote. So far the prep and tips gleaned have paid off. Would also be happy to help plus up the wiki more.
 

What imaging would you ideally add? I’m nearly done with all my wiring and would be happy to supply any supplemental photos.

I spent a lot of prep time in the weeks leading up to my supplies arriving and have a lot of different posts, photos and videos stashed away in Evernote. So far the prep and tips gleaned have paid off. Would also be happy to help plus up the wiki more.
[/quote]

I attached two pictures that helped me out. I've taken these screenshots from the videos that jbalatutube published in youtube. One that shows how to wire the connection plug coming from lcd3 to engine and the plug to flash the engine on speedconnector connection. But maybe there are meanwhile some wiring diagram in the wiki that show that also - i don't know.
 

Attachments

  • Screenshot_2.jpg
    Screenshot_2.jpg
    84.7 KB · Views: 1,717
Eremit said:
Trying to mount the Bafang Gear Shift Sensor, and it seems to work.*
But when connected, the Display gets unreadable dim. I followed the instruction for the hidden break wire sensor to get the necessary 5V - from the programmer pin. But despite of the Bafang Gear Sensor only using 0.01W, it blanks out the display.
Is the power drain to high for this 5V Pin? Is there some recommended spot on the display to get more stable 5V?

(To give the complete picture: Still using a 24V Battery wich at three quarter empty also makes a dim display. But still, the sensor only using 0.01W)

(*it looks like the brake symbol coming up when I move a wire in the sensor, but because of the almost unreadable Display I'm not quiete sure)

Hi,

could you please explain how you have connected the bafang gear shit sensor to lcd3? Some pictures would be helpful
I'am interested a lot, and maybe i can help you with soldering stable 5V connection.
 
:!:

I've just released version 0.15.0 and I think you'll all love this version! I certainly do. You should all thank casainho, he has put a lot of effort into this version!

It's available here: https://github.com/OpenSource-EBike-firmware/TSDZ2-Smart-EBike/releases/tag/v0.15.0

The documentation: https://github.com/OpenSource-EBike-firmware/TSDZ2_wiki/wiki/Usage-and-configuration-of-firmware-version-0.15.x
The configuration documentation should be complete and correct, the ODO field isn't documented yet. I'll do this soon.

Summary of the biggest changes:

  • Assist levels (default 5) and power boost levels are now simple multipliers of human pedal power.
  • Added protection for stalled wheel
  • Human pedal power is now shown on display (ODO field)
  • Pedal cadence on display is now filtered and more reliable
  • Reorganized ODO field on display. Use ON/OFF to cycle through the main menus. Use click+long click (UP) (no time in between) to cycle through the submenus. Use click+long click (DOWN) and hold the long click to reset the trip counter.
  • Improved display of battery state of charge (SOC).

Your data memory (configuration) should be reset automatically when programming this firmware. When there is a configuration issue after programming, please first reset your configuration manually, use configuration menu 6.3 to reset to factory defaults.
 
casainho said:
I implemented the current ramp but I could not test in detail because lack of time. But for my tests, most the lag is gone although there is still some that I think is because of torque sensor low pass filter on hardware.

There is some tweaking that can be done, I put low conservative values and I didn´t had time to find good final ones. Jabalat or others, please test and change the parameters and report.

config.h file on motor controller sources:
First, I did lower the duty_cycle ramp values (maybe they could be even lower??):
Code:
#define PWM_DUTY_CYCLE_RAMP_UP_INVERSE_STEP 20
#define PWM_DUTY_CYCLE_RAMP_DOWN_INVERSE_STEP 20

And now the configuration for the ramp current step, that I did for 5 amps per second. For instance, using half of the value 1953 will increase to 10 amps per second. This value will give the acceleration of torque/current, higher values should put higher stress on gears... but what is a god value??
Code:
// Target: ramp 5 amps per second
// every second has 15625 PWM cycles interrupts
// 1 ADC battery current step --> 0.625 amps
// 5 / 0.625 = 8 (we need to do 8 steps ramp up per second)
// 15625 / 8 = 1953
#define ADC_BATTERY_CURRENT_RAMP_UP_INVERSE_STEP 1953

And here the new piece of code that makes the current ramp (no need to change), runs at 1/15625 second (PWM cycles interrupts):

Code:
  /****************************************************************************/
  // Implement ramp up ADC battery current
  if (ui8_adc_target_battery_max_current > ui8_controller_adc_battery_max_current)
  {
    if (ui16_counter_adc_battery_current_ramp_up++ >= ADC_BATTERY_CURRENT_RAMP_UP_INVERSE_STEP)
    {
      ui16_counter_adc_battery_current_ramp_up = 0;
      ui8_controller_adc_battery_max_current++;
    }
  }
  else if (ui8_adc_target_battery_max_current < ui8_controller_adc_battery_max_current)
  {
    // we are not doing a ramp down here, just reducing to the target value
    ui8_controller_adc_battery_max_current = ui8_adc_target_battery_max_current;
  }
  /****************************************************************************/

Hi Casainho,
I'm trying to implement this but it looks like you havent posted all your code
Code:
ebike_app.c:277: error 20: Undefined identifier 'ui16_counter_adc_battery_current_ramp_up'
ebike_app.c:279: error 20: Undefined identifier 'ui16_counter_adc_battery_current_ramp_up'
ebike_app.c:280: error 20: Undefined identifier 'ui8_controller_adc_battery_max_current'
ebike_app.c:283: error 20: Undefined identifier 'ui8_controller_adc_battery_max_current'
ebike_app.c:286: error 20: Undefined identifier 'ui8_controller_adc_battery_max_current'
make: *** [Makefile_windows:85: ebike_app.rel] Error 1
 
jbalat said:
Hi Casainho,
I'm trying to implement this but it looks like you havent posted all your code
Code:
ebike_app.c:277: error 20: Undefined identifier 'ui16_counter_adc_battery_current_ramp_up'
ebike_app.c:279: error 20: Undefined identifier 'ui16_counter_adc_battery_current_ramp_up'
ebike_app.c:280: error 20: Undefined identifier 'ui8_controller_adc_battery_max_current'
ebike_app.c:283: error 20: Undefined identifier 'ui8_controller_adc_battery_max_current'
ebike_app.c:286: error 20: Undefined identifier 'ui8_controller_adc_battery_max_current'
make: *** [Makefile_windows:85: ebike_app.rel] Error 1
Seems you are trying to add the piece of code I did show?? No, it is already there on motor.c. You just need to adapt the default value if you feel it is to slow for you:

Code:
#define ADC_BATTERY_CURRENT_RAMP_UP_INVERSE_STEP 1953
 
Oh... oops
 
This morning while driving to work I found two bugs with the new 0.15.0 version, I've reported them here:

Stall protection kicks in on startup (quite annoying actually, major issue)
https://github.com/OpenSource-EBike-firmware/TSDZ2-Smart-EBike/issues/50

Buttons become unresponsive when pressed too long in the configuration menu
https://github.com/OpenSource-EBike-firmware/TSDZ2-Smart-EBike/issues/51
 
EndlessCadence said:
Stall protection kicks in on startup (quite annoying actually, major issue)
https://github.com/OpenSource-EBike-firmware/TSDZ2-Smart-EBike/issues/50
Solved, see the new pull request.
 
I love how 0.15 behaves. Kudos to all those involved!!!

One small point: what is the concept behind resetting the trip meter to zero at start up? i think this can make sense if you make your total trip without interruption and do not forget to note the km before turning off the display. But is that really realistic? I make many stops on my rides...be it making errands or a break etc...when i am back home, i want to know how many km i did...i think this is quite normal, no? But the way the tripmeter is still implemented, it is not possible. I understand there is now a button combination to reset the ODO, but frankly: is this what one wants? I mean: i would never want to reset my total counter. I would want to know how many km i did from the earliest possible time (obviously here it will not be sooo long due to the frequent updates). But to leave the trip meter on its last value until a button combo is pressed...that would make alot of sense to me...
 
andyme said:
I understand there is now a button combination to reset the ODO, but frankly: is this what one wants? I mean: i would never want to reset my total counter. I would want to know how many km i did from the earliest possible time (obviously here it will not be sooo long due to the frequent updates). But to leave the trip meter on its last value until a button combo is pressed...that would make alot of sense to me...

Piggybacking on this, is there a way to manually set the ODO? Would be nice to carry over mileage from stock firmware to have a running total of miles on the motor. I remember there being conversation about this a while back, but am unsure of where it wound up.
 
Question re. power management:

I think with the new approach, there may be an unneccessary conflict of interest with the max power limitation (the one with the power/up)

Could it make sense to have this setting become a part of assist level setup? Introduce a max value per assist level? this way one could be sure not to exceed what one wants.

So you could say: level 1 cannot be more than 200W, but level 2 can go up to 300 etc whatever.

The general concept of multiplying the torque/human power is excellent i think, but i also believe it calls for a possibility for individual upper limits...? this will force you to either shift down or to increase the assist level in certain situations, and i think this comes closer to the actual bicycle experience. And since this remains just an additional option, there should not be any harm in implementing this...
The power/up combo can still remain as a general upper limit if one wants to not exceed a certain value in any case.
so, e.g. one could program 100, 200, 300, 400, 500 in the setup and if one wants to make sure in a given situation that 300 is not exceeded in what ever assist level one may be, then this is being entered in the power/up field, and then you have max values of 100, 200, 300, 300, 300
makes sense? (to me it does so far...;))
 
Guys please help I am half way to work it was working fine now I turn off get assistance for a few seconds then no assistance and flashing 1 on the screen
Plenty of volts left and set minimum voltage.
Help
Help
Latest version 15.0
 
jbalat said:
Guys please help I am half way to work it was working fine now I turn off get assistance for a few seconds then no assistance and flashing 1 on the screen
Plenty of volts left and set minimum voltage.
Help
Help
Latest version 15.0
See how to avoid on issue trcaaker.
 
Yes I did lose power at stop lights with feet on pedals but I was expecting that.

This was due to my speed sensor malfunction due to me flashing the motor too many times the pins do not make good contact anymore and speed was measured as zero
This had the effect of cutting out the motor
So not related to 0.15. :(
 
@ Cas
I run today 0.15 with current ramp for lag. In my opinion the fix is solid even when starting in 8th gear. Previously the lag was 2s +.

The power delivery is solid gold, bike is very responsive. I can hit 45km/h with 0.4 assist using 220w.
 
maximusdm said:
@ Cas
I run today 0.15 with current ramp for lag. In my opinion the fix is solid even when starting in 8th gear. Previously the lag was 2s +.

The power delivery is solid gold, bike is very responsive. I can hit 45km/h with 0.4 assist using 220w.

Max,
I couldnt find where to make the change so I just set the inverse ramp again down to 20 which works well for me...
I looked in motor.c and motor.h but couldnt find where to set the current ramp ?
Yeh I think the new assist levels work well, just need a bit of tweaking as they are too powerful for me :)

Casaiho,
since when has the code been reliant on the wheel speed ? Is this new ?
 
Back
Top