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

hydrinium.h2 said:
From a quick test I got:
PWM duty cycle : 254
ERPs : Fluctuated between 390-400
Also, current seems to max out around 8 Amps seated, I can get it to jump to around 12 if I start pedaling standing.
So, 254 is max PWM duty-cycle value, meaning motor coils has max battery voltage and so motor is at his limit, I think.

Can you try reduce increase the gear ratio so the ERPs get a lower value and then see if at PWM duty-cycle 254 the current increases over that 8 amps?
 
Sorry could you clarify, do you mean increase or decrease the gear ratio? I'm currently at the highest rear gear my bike has unfortunately. The front gear is a 52T single gear. Is the intent to try and get the motor to spin slower?
 
casainho said:
hydrinium.h2 said:
From a quick test I got:
PWM duty cycle : 254
ERPs : Fluctuated between 390-400
Also, current seems to max out around 8 Amps seated, I can get it to jump to around 12 if I start pedaling standing.
So, 254 is max PWM duty-cycle value, meaning motor coils has max battery voltage and so motor is at his limit, I think.
Something seems wrong with your motor. See here the example of my motor (on this example I had motor current limited to max of 12 Amps on LCD configurations, still seems it went over that a bit, which may be ok due to rounding errors, etc).

So, I got 704 watts on the motor:
2019-07-24-10-20-40.jpg


The battery voltage was around 54V, I guess:
2019-07-24-10-19-41.jpg


And the current 13 amps:
2019-07-24-10-19-58.jpg


The PWM duty-cycle 186 was not at max value, unlike in your case. I think my values makes total sense to me:
2019-07-24-10-22-12.jpg


And the ERPS 482 was higher than your value:
2019-07-24-10-22-31.jpg


I have a 50T gear plate at front and 27.5 inches wheels and with this setup I got almost 48km/h:
2019-07-24-10-19-03.jpg


So, to resume you have:
- lower ERPS, but:
- max duty-cycle
- less motor current and hence power

I am not sure but seems your motor has some issue. Is it a 48V motor or 36V motor?

I would suggest you to look at the motor to see if there is any signs of it being damage due to over heating or maybe water inside??
 
My motor is 48v, I actually just installed a temperature sensor last weekend and I didn't see any damage like the burnt looking coils you show on the wiki or any water but I can check again to see if anything is wrong. How would I be able to verify motor damage from visual inspection? If everything else is working except the duty-cycle being really high could this be due to a wiring mistake I made or incorrectly flashing the firmware?
 
hydrinium.h2 said:
My motor is 48v, I actually just installed a temperature sensor last weekend and I didn't see any damage like the burnt looking coils you show on the wiki or any water but I can check again to see if anything is wrong. How would I be able to verify motor damage from visual inspection? If everything else is working except the duty-cycle being really high could this be due to a wiring mistake I made or incorrectly flashing the firmware?
I am not expert in this but your duty-cyle higher than mine means that your coils have max voltage possible from the battery but still it pulls way less current (and this even on lower ERPS value). It is like if there is a resistor in the path of the current that don't let it flow... or it is on the motor or controller or maybe on the battery side?? -- can you use the LCD3 to find the resistance of your battery?? Even like that, maybe the battery voltage would need to drop to much for the values you have...
 
The current does spike up to around 12 when I first start pedaling from a standstill, along with the wattage, but it quickly stabilizes around 400w @ ~8 A. I tried reducing the battery resistance but I think 130 milliohms is about right. The 48v high cadence mode seems to lower the duty-cycle, as it doesn't max out at 254 as quickly compared to the regular 48v mode at the same speed/torque.
Out of curiosity, how is the duty cycle calculated? I don't really know anything about electronics, but is it from a sensor, based on voltage coming out of the battery or something else? I just wanted to make sure it was a motor hardware issue and not an issue I created from poor installation/soldering etc. for example if I damaged a connection or something
 
hydrinium.h2 said:
The current does spike up to around 12 when I first start pedaling from a standstill, along with the wattage, but it quickly stabilizes around 400w @ ~8 A. I tried reducing the battery resistance but I think 130 milliohms is about right. The 48v high cadence mode seems to lower the duty-cycle, as it doesn't max out at 254 as quickly compared to the regular 48v mode at the same speed/torque.
Out of curiosity, how is the duty cycle calculated? I don't really know anything about electronics, but is it from a sensor, based on voltage coming out of the battery or something else? I just wanted to make sure it was a motor hardware issue and not an issue I created from poor installation/soldering etc. for example if I damaged a connection or something
You just make sure the current and power limits you did configure on LCD. But my motor, with the battery charged up to 58.8 volts, can take like about 1000 watts at startup if I have max current configured to 18 amps.

This is the piece of code that increases or decreases duty cycle and it runs every 1/0.000064 of the second:

Code:
  /****************************************************************************/


  // PWM duty_cycle controller:
  // - limit battery undervoltage
  // - limit battery max current
  // - limit motor max phase current
  // - limit motor max ERPS
  // - ramp up/down PWM duty_cycle value
  // do not execute all, otherwise ui8_duty_cycle would be decremented more than onece on each PWM cycle

  static uint8_t ui8_current_controller_counter;
  
  // do not control current at every PWM cycle, that will measure and control too fast. Use counter to limit 
  if (++ui8_current_controller_counter > 12)
  {
    // reset counter
    ui8_current_controller_counter = 0;
    
    // if battery max current or phase current is too much, reduce duty cycle
    if ((ui8_g_adc_battery_current > ui8_controller_adc_battery_max_current) || (ui8_adc_motor_phase_current > ui8_adc_target_motor_phase_max_current))
    {
      if (ui8_g_duty_cycle > 0)
      {
        // decrement duty cycle
        ui8_g_duty_cycle--;
      }
    }
  }
  else if (UI8_ADC_BATTERY_VOLTAGE < ui8_adc_battery_voltage_cut_off) // battery voltage under min voltage, reduce duty_cycle
  {
    if (ui8_g_duty_cycle > 0)
    {
      // decrement duty cycle
      ui8_g_duty_cycle--;
    }
  }
  else if ((ui16_motor_speed_erps > ui16_max_motor_speed_erps)) // if motor speed over max motor ERPS, reduce duty_cycle
  {
    if (ui8_g_duty_cycle > 0)
    {
      // decrement duty cycle
      ui8_g_duty_cycle--;
    }
  }
  else // nothing to limit, so adjust duty_cycle to duty_cycle_target, including ramping
  {
    // if brake is active, keep duty cycle target at 0
    if (ui8_motor_controller_state & MOTOR_CONTROLLER_STATE_BRAKE) { ui8_controller_duty_cycle_target = 0; }
    
    if (ui8_controller_duty_cycle_target > ui8_g_duty_cycle)
    {
      if (ui16_counter_duty_cycle_ramp_up++ >= ui16_duty_cycle_ramp_up_inverse_step)
      {
        ui16_counter_duty_cycle_ramp_up = 0;
        
        // increment duty cycle
        ui8_g_duty_cycle++;
      }
    }
    else if (ui8_controller_duty_cycle_target < ui8_g_duty_cycle)
    {
      if (ui16_counter_duty_cycle_ramp_down++ >= ui16_duty_cycle_ramp_down_inverse_step)
      {
        ui16_counter_duty_cycle_ramp_down = 0;
        
        // decrement duty cycle
        ui8_g_duty_cycle--;
      }
    }
  }



  /****************************************************************************/
 
buba said:
Can confirm I had the exact issue! Turned out I had water inside the case. Can also confirm I was hitting the temperature limiting when that happened and was generally shown abnormal motor temperature values.

Good suggestion! We should also advice the user to dry out/clean inside the case and check the wires if something like that happens. We just need to be able to properly define a non-working sensor situation and be confident it will not cause a problem. Worst case scenario is that have a real over-temperature situation and set an error for sensor fault. Thus disabling the motor temperature protection. But that is very unlikely if properly implemented.

Anyway, it is at least safe to say that a value of 140 degrees Celsius should point to sensor fault.

Will remember this and when time allows maybe the community can start a discussion of how we might implement such an error flag and what parameters are safe to use. Also what the effect of the error should be.


I can confirm that I did indeed have some water in the motor housing..
I think the culprit was a slightly squashed 'O' ring

And the water had found its way into the connector I added onto the temp sensor


Dried out now and working again.
 

Attachments

  • MVIMG_20190725_185637-600x800.jpg
    MVIMG_20190725_185637-600x800.jpg
    78 KB · Views: 1,511
  • IMG_20190725_185737-600x800.jpg
    IMG_20190725_185737-600x800.jpg
    66.4 KB · Views: 1,511
  • IMG_20190725_185646-800x600.jpg
    IMG_20190725_185646-800x600.jpg
    66.1 KB · Views: 1,511
casainho said:
buba said:
Definitely! This is why I removed the startup-assistance-without-pedal-rotation! I burned a phase wire and destroyed a motor this way during testing. Now on the 0.20.0 I only enable motor if the motor shaft rotates at least 4 revolutions per second so it is never enabled when stand still!

NOTE: I have improved everything else so the startup is basically instant even though we do not have startup-assistance-without-pedal-rotation! It will still startup much, much faster than before so I hope no one feels the removal is bad. It is just that much safer as you can rest your feet on the pedals and when you want to go it is instant! If you use the double cadence it will startup perfectly and the standard cadence is also really fast!
Startup-assistance-without-pedal-rotation is a feature I did implement and I use daily. Please put it back or I will have to do it.

There is no problem to have motor starting if we don't rotate the pedals, the throttle works just like that.

What others asked is an offset and I was thinking in having a configurable offset in kgs, where the user could see on advanced tecnhical data the value in kgs of weight done on the pedals (as we will have this to calibrate the torque sensor). I am looking at the calibration of the torque sensor and looking at the torque sensor ADC values, I can see that the weight of my leg resting on the pedal is near 10 kgs. I could setup a value of like 15 kgs or 5 kgs, depending in what I prefer. For me, could be the 5 kgs because I like to get immediate assistance as soon I release the brakes.

By the way, 10 kgs is +14 ADC 8 bits units on my recent bought torque sensor, which I think is plenty to be safe as an offset to avoid unwanted startups.

The torque sensor needs more love from us: we need to add calibration and also show to user the force on it in kgs. This my torque sensor, as we use it now, can only measure (wrongly!) up to about 120 watts of human power at my natural cadence while it should be able to measure up to 500 watts of human power (because it can only measure up to 25 kgs but calibrate will measure up to 110 kgs).

I agree that we should add more options for users that want to calibrate the torque sensor but regarding the assistance without pedal rotation:

I think it is best to discuss this after you test my changes. There is a slight chance you will like the changes and then it would be unnecessary to add assistance without pedal rotation. If you and others like the changes and it basically works as good as before it would also be much safer and with one less configuration item. I understand you do not want to change anything that you have made and I am certainly not forcing you to do anything. You can always add assistance without pedal rotation to Power Assist later on. If the community wants it we should definitely keep it. Due to many development reasons I have removed it but would have no problem putting it back if the community wishes it after testing the 0.20.0. The same logic applies to Startup Boost as many users feel it is not needed if the system is more responsive. But this does not mean we are going remove it if there are some that still think it is needed after testing the 0.20.0. I will always respect that.

If anyone is afraid I am going to remove something I just want to say that it is absolutely not the case. I am not developing the riding modes and the improvements for myself. It is for the community. Therefore I have no gain in making the experience lesser for anyone. I would never want a single user to feel left behind and because of this I was at times ready to make custom firmwares to users so they can get a little bit more from the experience.

So when the 0.20.0 beta is released I look forward to discussions so we can make it even better! I will happily listen to feedback and develop the 0.20.0 beta until everyone is satisfied and we can have a stable version.
 
I just wanted to share a new small issue that has happened to my motor as a result of the water ingress and how I diagnosed the issue in the hope it may help someone else fault find a similar issue.

A couple of posts ago you can see I had discovered that my motor housing has a small amount of moisture in it, literally a couple of drops, however this had made its way into the temperature sensor cable join that I added (I did it this way so I could easily switch between the temp sensor and throttle if needed). However since I put everything back together I started to have a think about the other issue I was seeing that I hadn't really noticed until now.

My battery voltage was jumping up and down a bit even at standstill. Maybe be 1-2 volts. It was also reading lower than I expected it to as i recently fully charged it and had not ridden more than a few miles and it appeared almost empty.

So I got out my Power meter to check the voltage on the actual battery.

IMG_20190725_192236-600x800.jpg
Sure enough 51.74v but at the Screen...

IMG_20190725_192240-800x600.jpg
45.4Volts?

I began by measuring the voltage at each connector from the motor to the screen.. (in effect unplugging the screen)

8pin connector = 51.4v
Display 5 pin connector = 51.2v

So you would think that the issue must be within the screen?

luckily I had another screen on another bike so i could quickly test that and exactly the same the screen shows around 45.5V and jumps around a couple of volts. Also you could clearly see the back light would flicker and dim when the battery voltage was dropping (still st 44v)

Hrm..

So I suspect the motor end , I mean i had just discovered water in the motor so its likely the same issue, and after further investigation i found the culprit...
IMG_20190725_220105-600x800.jpg

So the Blue cable (Battery voltage) wire had a small kink in it where it exited the motor housing and water must have made its way in and rusted to the core. Not to the point it was broken right through but enough to introduce a high resistance into the cable that would create a voltage drop of a few volts when the screen was attached drawing some current. More current with higher brightness.

In my case by flexing the cables gently within the motor housing the week spot soon broke clean through and it was obvious.

So I re-soldered the cable and used some heat shrink to fix it and its perfect again.

IMG_20190725_220600-600x800.jpg
So why share this?

Well now knowing this there are some good tests you can perform if you see weird issues with the screen, to hopefully pinpoint any cable issue like this that is not as clear cut as an open circuit.

1) check voltages at the battery, don't just trust what the screen tells you
2) check the voltage at the screen or as close to the screen as possible when screen is disconnected
3) check the voltage at the screen when attached and on

If there is a difference in voltage with the screen on and off then its likely you have a bad cable between the motor and the screen and start measuring resistance for the battery power and Gnd cable to see which has a higher resistance, then inspect the suspect cable to pinpoint the issue.

Hopefully may help someone else.
 
I had this kind of issue too, not a wire broken but c ontroleur work fine but impossible to program it ...
i changed the controleur to use OSF

you can see that many water came inside
was a big mountain bike trip with many water ;)oxydation suite a entrée d eau 1.jpgesterel avec nils et morgan et beaucoup d eau.jpg
 
Personally I follow only one rule with the ebike (all also with the Turbo levo) never make fords in the rivers if you want the bike to have no problems. when my colleagues go to the rivers I abandon them. The turbo levo for example has two concentric shafts without any oil seal and from there the water enters ... In the tsdz2 it can pass everywhere, from the torsimeter, (it runs along the two cables of the torsimeter up to the control unit) from the small main gear to arrive at the blue gear and give it to the engine, in short, everywhere
 
At the very least consider using silicone dielectric grease on all your connectors. It's commonly used on automotive connectors like spark plug boots etc to keep moisture out.
 
famichiki said:
At the very least consider using silicone dielectric grease on all your connectors. It's commonly used on automotive connectors like spark plug boots etc to keep moisture out.

Oh I agree, for connectors that's a very good idea and something i will be doing, but in this case the water worked it's way down the outside and between the cables that go into motor housing, on my motor all that was stopping this was a rubber bung around the cables. also my O-ring seal was crushed slightly so it may have come in that way as well. I have now sealed both the rubber cable bung and o-ring with additional Silicon sealant to try and fill in the gaps as best I can.
 
elem said:
I had this kind of issue too, not a wire broken but c ontroleur work fine but impossible to program it ...
i changed the controleur to use OSF

you can see that many water came inside
was a big mountain bike trip with many water ;)oxydation suite a entrée d eau 1.jpgesterel avec nils et morgan et beaucoup d eau.jpg

Wow yes that's just a bit more water! :shock:
 
So I was messing with the max current of the battery and it let me keep going past 18 Amps even though the documentation says it should be limited to 18. This is on 0.19.x. Can anyone double check if this is the case for them or if maybe my install is funky and I should try reflashing the lcd.
 
hydrinium.h2 said:
So I was messing with the max current of the battery and it let me keep going past 18 Amps even though the documentation says it should be limited to 18. This is on 0.19.x. Can anyone double check if this is the case for them or if maybe my install is funky and I should try reflashing the lcd.
For how much it goes over? What is the value?
 
I gues that my 850C display
V2.1C60
201804180097
has the correct processor GD32F103RE
P850C_V2.1C60_201804180097.jpg

GD32F103RE_P850C_V2.1C60_201804180097.jpg

I left skool 31 years ago and the electronics have evolved. My question is, what interface do I need to program it? Can this be done with an USB to serial programmer or do I need something other?
 
bwb said:
I gues that my 850C display
V2.1C60
201804180097
has the correct processor GD32F103RE
Seems you have the version that will work.

bwb said:
My question is, what interface do I need to program it? Can this be done with an USB to serial programmer or do I need something other?
Did you read the wiki "How to install"??
 
casainho said:
bwb said:
My question is, what interface do I need to program it? Can this be done with an USB to serial programmer or do I need something other?
Did you read the wiki "How to install"??
Sorry, I just saw that only the page of KT-LCD3 mentions the ST-LinkV2. I just did a copy to the page of 850C display so please go there and read -- also give a look to KT-LCD3 as the process is similar.
 
casainho said:
hydrinium.h2 said:
So I was messing with the max current of the battery and it let me keep going past 18 Amps even though the documentation says it should be limited to 18. This is on 0.19.x. Can anyone double check if this is the case for them or if maybe my install is funky and I should try reflashing the lcd.
For how much it goes over? What is the value?
It stops at 100
 
hydrinium.h2 said:
casainho said:
hydrinium.h2 said:
So I was messing with the max current of the battery and it let me keep going past 18 Amps even though the documentation says it should be limited to 18. This is on 0.19.x. Can anyone double check if this is the case for them or if maybe my install is funky and I should try reflashing the lcd.
For how much it goes over? What is the value?
It stops at 100
Ah I understand now. The motor controller firmware should limit to 18 amps, even if on display you setup an higher value. It possible for anyone to change that limit of 18 amps on the motor controller firmware and so the display does not limit.
 
Finally we own the TSDZ2 torque sensor!!

Up to now we were reading the torque sensor in a wrong way and it could only measure up to 25 kgs. Also there is a big different from the values read on left or right pedal. This are the output values of my torque sensor (that I bought 3 weeks ago):

image.png


I implemented the linearization of the torque sensor measures and it can now measure up to at least 102 kgs (which is my weight). I also implemented a linearization based on a table with values for left and right pedal and it works very well: before my right pedal was measuring the 102 kgs of my weight but left pedal would measure only 70 kgs, now both pedals measure the same values.

Before my display was showing to me a value of pedal human power of a bit more than 100 watts, no matter the force I did and now, I can go up 400 watts for short peaks. I think strong cyclists will love to see their real pedal human power on the display!!

And by the way, I am pretty sure there is no need to calibrate the sensor as I did before, no need to open the motor and adjust the hall sensor position of the torque sensor.

Calibration process

1. user put values on right pedal, starting at 5 kgs, in steps of 5 kgs up to about 30 kgs. Finally put itself on the pedal with his known weight value. The pair of weight and torque sensor ADC value should be registered and later user will need to decide for 5 points only, 1 at start, other at the last value and 3 values near the knee on the graph, as shown on the graphs.
2. Repeat for left pedal.
3. Put the pair values of weight and torque sensor ADC values, for each pedal, on the specific LCD configuration menu.

One important thing for all this work is that at system power up, the right pedal should be pointing to ground -- as there is the need to identify which pedal we are doing the force and there is no way to identify them, I decided to do like this, having the pedal at a known position at startup and after that everything will work well.

I have the code working on my bicycle and I can see on the LCD the weight value in kgs on the LCD. The tables for linearization are for now hardcoded on the firmware, I can't setup them yet on LCD. When we have the next version of firmware I can add this feature to it.
 
850C display firmware can be installed without open it

Our firmware can be flashed on 850C by connecting a cable to the motor connector - this is for a new 850C from factory:



There are 2 tools needed for this: a specific Windows software from APT (the manufacturer) and "special box" also from the manufacturer.

For what I could understand:

1. The "special box" is just a USB<->UART 3.3V converter like the popular and very cheap ones used on Arduino. Also it powers the LCD but this can be done with the battery power.

2. The software, someone shared with the me but I do not have permission to share with others. I hope this is a simple software to communicate with the bootloader, probably using any shared bootloader by ST and so I hope we can find how it works and then make our own software.

Anyone available to investigate and help on this???

And know I have the graphs working very well and here is an example of a real riding I did, pulling about 13 amps from my battery that is the max it can handle.

As you can see, the duty-cycle and the motor ERPS values were not at their max values (255 and 525 respectively) but if I was using the max cadence or the max motor power for the battery available, the motor hits his limit even if I pedal harder/use higher assist level. Because of this, I would like to show some warning to user when the motor power hits the limit, maybe changing the power power number from white to orange or something like that.





















 
casainho said:
850C display firmware can be installed without open it


Now that's more like it. No way was I going to break open a very expensive sealed display but this is an entirely different kettle of fish :)
 
Back
Top