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

EndlessCadence said:
kortina said:
Hi Guys,
Received all of my gear to upgrade my TSDZ2. I have made the cables, flashed the KT-LCD3 OK.

When I attempt to flash my TSDZ2 I get an error:

Code:
> Loading file C:\Users\Michael\Downloads\TSDZ2-v0.13.1.hex in PROGRAM MEMORY area  ...
< File successfully loaded. File Checksum 0x19D1EE
> Programming  PROGRAM MEMORY area...
Error : Problem while trying to Reset swim and device. Apply a Power On Reset
< PROGRAM MEMORY programming completed.
> Verifying PROGRAM MEMORY area...
Error : Problem while trying to Reset swim and device. Apply a Power On Reset
< PROGRAM MEMORY successfully verified.

I have attempted the EEPROM reset:
To use the reset to factory defaults feature (it's no longer necessary to program the data memory!):
- Enter configuration menu 6
- Go to submenu 3
- Press the UP button 10 times, a counter on the display will be incremented anytime you do this
- The display will turn off
- Turn it on again and it will reset your configuration to the factory defaults!

The KT-LCD lights ups, and shows the correct voltage. (52v battery, fully charged showing 57.7).

The issue that I get is that 0 watts of power are applied to the motor.

Any ideas what I can do to finish this off, and get the bike running again?

Kind Regards
Hi kortina, the resets you're talking about aren't related to each other in any way. The EEPROM reset clears your data memory (the firmware configuration). You seem to have issues with the programmer and communication with the device. Is the reset signal (RST) of the programmer properly connected? Basically your device isn't properly programmed right now...

Btw ST Visual Programmer 3.4.1 is the correct tool, you don't need ST Link Utility at all.

Hi EC,

After double and triple checking my cables, I decided to try another laptop... no more errors!

But... Still the same behaviour.

I have flashed to 0.14 (screen and motor), used menu 6,3 and cleared.
Set my details for 52v setup.

I still have no power.

However, if I start pedaling just after switching on, I get a quick burst for about 0.5sec !?

Any ideas what I should try next?
 
kortina said:
I have flashed to 0.14 (screen and motor), used menu 6,3 and cleared.
Set my details for 52v setup.

I still have no power.

However, if I start pedaling just after switching on, I get a quick burst for about 0.5sec !?

Any ideas what I should try next?

What's your distance between speed sensor and magnet? Try a few distances of at least 5mm (up to 1cm?). I had this issue too and my speed on the display quickly jumped to around 99 km/h.
 
EndlessCadence said:
What's your distance between speed sensor and magnet? Try a few distances of at least 5mm (up to 1cm?). I had this issue too and my speed on the display quickly jumped to around 99 km/h.

Hi EC,
I just tested again, played with the sensor. It was reading accurate, then I adjusted it to a bad position, then back to accurate.

It seems fine reading between 0-16km/h that I tested it to.

It almost seems like the issue some users had with a 52v battery on the stock 48v motor (where they get no power until < 55v)?

I am running the 52v (750w) motor, and a 52v battery. (Currently at 57.4 volts).

Should I send you a copy of the 'data memory' tab?
Could the data be corrupt?

Thanks again.
 
I had similar issues at the start, it’s just bad flashing and mixed memory.

Try using the new 14 firmwares, both lcd and tsdz2
Mine started working properly after I tried the 13beta versions.

Open the stvp and flash the program tab and memory tabs with zeroes.
Then switch back to program tab open the hex file and flash it
Do the same for both motor and lcd

Before you start Make sure you have unplugged your battery and press the on/off button to drain residual voltage from the lcd. Unplug the lcd from the motor too if you can.

Go into config, setup no. Of cells and of course the minimum cutoff voltage and the number of max amps. If these are wrong then you will get nothing. Also use top and middle buttons and make sure you have at least 200w.

If you find there are random values in the wrong menus or the assist levels aren’t setup then it’s another bad flash...
 
Just wanted to report that the temp sensor worked a treat today, i was able to reach 64 degrees going up a slight incline with around 420w. Thanks Casainho :D
Good to know I can keep an eye on the temperature
 
jbalat said:
Also use top and middle buttons and make sure you have at least 200w.
Please don't do this. Leave the target battery power setting (button ON/OFF + UP) to zero, this will you give you the best performance. See the release notes for more details.

Using default settings and only configure the specific battery settings the motor should work great, I've tested this a few times.
 
jbalat said:
Also use top and middle buttons and make sure you have at least 200w.
Please don't do this. Leave the target battery power setting (button ON/OFF + UP) to zero, this will you give you the best performance. See the release notes for more details. I've created the following issue: https://github.com/OpenSource-EBike-firmware/TSDZ2-Smart-EBike/issues/13

Using default settings and only configure the specific battery settings and motor type (if 36v) the motor should work great, I've tested this a few times.

jbalat said:
Just wanted to report that the temp sensor worked a treat today, i was able to reach 64 degrees going up a slight incline with around 420w. Thanks Casainho :D
Good to know I can keep an eye on the temperature
Nice!
 
Hi EC,

Last night I was wondering how you can test the engine in the steep mountains if you live in a completely flat country like the Netherlands?

:D :D :D

Or do you live on the border with another more mountainous country?

Regards

:p :p :p
 
Well my premature excitement has come to an abrupt end ☹️
Haven’t got past the second stage, I.e. flashing the TSDZ2 from the ST Link via the speed sensor...keeps saying Swim comms error. I’ve changed the wires in different pins on the speed sensor (going to TSDZ2) and no change...I read that one has to use the speed sensor extension cable but was reticent to cut it up. I also have a standard speed sensor (not the twin output version), both have 6 pins. Spent a day and a half soldering, resoldering and getting knowhere 😞.
If no other suggestions will have a go at cutting up my speed sensors...in the meantime I’ve flashed the 0.14 release to the LCD3.
 
casainho said:
EndlessCadence said:
:!: Everyone, after a day full of testing I'm confident to release version 0.14.0. You can find it here, including an overview of the changes and open issue(s):
Good work!! I hope to test it on next days.
Thanks! I'm very interested what you think of it after testing.

So, with all the bugs and things we want to implement, I think would be a good investment for you to debug with JTAG, will be faster for inspecting the code "in real time", see the variables values on break points, etc (I guess you are not doing JTAG debug).

To do JTAG debug you don't need any extra hardware, it is just STLinkV2 connected as you have to flash the firmware. In terms of software, I use Eclipse, OpenOCD and GDB and here is a screenshot of STM8 code debug session:

30-9.png


Here are the instructions I wrote for being able to JTAG debug: https://opensourceebikefirmware.bitbucket.io/development/Development_tools--Linux--Step-by-step_tutorial_development_tools--(optional)_Tools_to_debug_the_firmware.html
You've guessed right :D
I have experience with OpenOCD and GDB from the past but didn't have time yet to try it. I'm that experienced that I don't need debugging :p

Thanks for the instructions, will try it! I'm wondering how you test the behaviour and feel of the bike in a stationary situation? I don't even have throttle... But for debugging configuration and communications (UART) I think it is very useful.

In the meantime I was thinking about the temperature sensor. Can't we use a digital temperature sensor with SPI/I2C or even one wire interface? Maybe you have a drawing or overview of all the free pins of the STM8? For my Bluetooth experiments I also need a way to communicate with the STM8.
 
AZUR said:
Hi EC,

Last night I was wondering how you can test the engine in the steep mountains if you live in a completely flat country like the Netherlands?

:D :D :D

Or do you live on the border with another more mountainous country?

Regards

:p :p :p
LOL :D I can't :p We have some hills here and bridges and viaducts of course.
And when I go to real mountains (Pyrenees, Alps) I take my unassisted road bike with me to enjoy the suffering :p
 
EndlessCadence said:
casainho said:
EndlessCadence said:
:!: Everyone, after a day full of testing I'm confident to release version 0.14.0. You can find it here, including an overview of the changes and open issue(s):
Good work!! I hope to test it on next days.
Thanks! I'm very interested what you think of it after testing.

So, with all the bugs and things we want to implement, I think would be a good investment for you to debug with JTAG, will be faster for inspecting the code "in real time", see the variables values on break points, etc (I guess you are not doing JTAG debug).

To do JTAG debug you don't need any extra hardware, it is just STLinkV2 connected as you have to flash the firmware. In terms of software, I use Eclipse, OpenOCD and GDB and here is a screenshot of STM8 code debug session:

30-9.png


Here are the instructions I wrote for being able to JTAG debug: 0ⁿhttps://opensourceebikefirmware.bitbucket.io/development/Development_tools--Linux--Step-by-step_tutorial_development_tools--(optional)_Tools_to_debug_the_firmware.html
You've guessed right :D
I have experience with OpenOCD and GDB from the past but didn't have time yet to try it. I'm that experienced that I don't need debugging :p

Thanks for the instructions, will try it! I'm wondering how you test the behaviour and feel of the bike in a stationary situation? I don't even have throttle... But for debugging configuration and communications (UART) I think it is very useful.

In the meantime I was thinking about the temperature sensor. Can't we use a digital temperature sensor with SPI/I2C or even one wire interface? Maybe you have a drawing or overview of all the free pins of the STM8? For my Bluetooth experiments I also need a way to communicate with the STM8.
DS18B20 sensor, and I bought 2 units to test but as you will see on the datasheet, it needs fast timmings to communicate and that would colide with motor control timmings. Also, would be a bit more complex to wire to motor controller so would have an even bigger barrier.
Also, it needs an IO input and there are 2 near the throttle header but those have a low pass filter (capacitor + resistor) so could even not work for fast communications??

So yes, there are 2 digital pins with low pass filters, like if those could be used for gear shift sensor, etc.
 
casainho said:
DS18B20 sensor, and I bought 2 units to test but as you will see on the datasheet, it needs fast timmings to communicate and that would colide with motor control timmings. Also, would be a bit more complex to wire to motor controller so would have an even bigger barrier.
Also, it needs an IO input and there are 2 near the throttle header but those have a low pass filter (capacitor + resistor) so could even not work for fast communications??

So yes, there are 2 digital pins with low pass filters, like if those could be used for gear shift sensor, etc.
Are there only two IO's left? That means I have to use the UART for bluetooth (and others) and basically break the connection with the display?

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.
 
When will you be releasing the non-throttle version soon ? is it worth me holding off a couple of days from installing ver 14..

BTW I tried setting zero power in version 12 and it gives me zero power LOL.. I guess you just implemented disabling that feature in 14...

Casainho, I got to 78degrees on a casual ride home, it's 26 degrees outside. I had just finished coming up a hill. Btw the display was not flashing ??? should it be ???
 
BTW I have just loaded up rev 14 and disabled the quick power setting you mentioned. I was able to hit about 625w setting the assist level to 5000w and max current to 18A, this is about right since my battery was down to 37v.
(I would still prefer to use a torque multiplier of 5.0 and quick set the power to 700w instead, rather than relying solely on the assist level for power as well, it feels like I'm playing lotto not knowing what power I'm going to get next)

I have done some changes to up the cadence which works well.

I tried fixing that 2 second delay but changing this line in ebike_app_c did absolutely nothing
Code:
  // now count 2 seconds
    case STATE_STARTUP_PEDALLING:
    if (ui8_rtst_counter++ > 4) // 0.4 seconds JB
 
jbalat said:
BTW I have just loaded up rev 14 and disabled the quick power setting you mentioned. I was able to hit about 625w setting the assist level to 5000w and max current to 18A, this is about right since my battery was down to 37v.
(I would still prefer to use a torque multiplier of 5.0 and quick set the power to 700w instead, rather than relying solely on the assist level for power as well, it feels like I'm playing lotto not knowing what power I'm going to get next)

I have done some changes to up the cadence which works well.

I tried fixing that 2 second delay but changing this line in ebike_app_c did absolutely nothing
Code:
  // now count 2 seconds
    case STATE_STARTUP_PEDALLING:
    if (ui8_rtst_counter++ > 4) // 0.4 seconds JB
Nice! That's some good news. If you download this branch you'll have the non-throttle version (not released yet).
https://github.com/OpenSource-EBike-firmware/TSDZ2-Smart-EBike/tree/non_throttle_version

The compile and "compile and flash" scripts build the non-throttle version by default. In the releases folder you can find the precompiled version.
 
jbalat said:
Open the stvp and flash the program tab and memory tabs with zeroes.
Then switch back to program tab open the hex file and flash it
Do the same for both motor and lcd

Before you start Make sure you have unplugged your battery and press the on/off button to drain residual voltage from the lcd. Unplug the lcd from the motor too if you can.

Go into config, setup no. Of cells and of course the minimum cutoff voltage and the number of max amps. If these are wrong then you will get nothing. Also use top and middle buttons and make sure you have at least 200w.

If you find there are random values in the wrong menus or the assist levels aren’t setup then it’s another bad flash...

Thanks jbalat

Still no luck :(


I disconnected the battery, then attempted to turn the system on to drain the residual power.
I disconnected the LCD, then reflashed all zeros (program and data).
I then flashed v14 to the LCD (program)

I then flashed all zeros to the motor (program and data)
I then flashed v14 to the Motor (program)

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.
 
That sucks bro. Maybe you can try a few older versions and see how you go. I was in your situation for a while but got it going in the end. Don’t give up.
 
kortina said:
jbalat said:
Open the stvp and flash the program tab and memory tabs with zeroes.
Then switch back to program tab open the hex file and flash it
Do the same for both motor and lcd

Before you start Make sure you have unplugged your battery and press the on/off button to drain residual voltage from the lcd. Unplug the lcd from the motor too if you can.

Go into config, setup no. Of cells and of course the minimum cutoff voltage and the number of max amps. If these are wrong then you will get nothing. Also use top and middle buttons and make sure you have at least 200w.

If you find there are random values in the wrong menus or the assist levels aren’t setup then it’s another bad flash...

Thanks jbalat

Still no luck :(


I disconnected the battery, then attempted to turn the system on to drain the residual power.
I disconnected the LCD, then reflashed all zeros (program and data).
I then flashed v14 to the LCD (program)

I then flashed all zeros to the motor (program and data)
I then flashed v14 to the Motor (program)

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.
If I understand correctlty you're able to program the display and controller without issues? Try reading the option bytes tab for the controller? I had an issue with the option bytes (corrupted) once.
 
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??
 
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?
 
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.
 
Hi guys,

i think i found the right thread ;)

i restructured (cleaned) the ebike_control_motor today.
added the safety feature logic at the end.

it compiles but i didnt have to time to test (still in the office)
code is here:
maybe someone wants to look over it an merge it?

cu
vscope
 
jbalat said:
Casainho, I got to 78degrees on a casual ride home, it's 26 degrees outside. I had just finished coming up a hill. Btw the display was not flashing ??? should it be ???
You should remember that previous code would flash as soon you hit the min limit temperature value and that also indicates it starts to reduce motor/battery current. You can quick test again, you just need to lower limit temperature value to your lower current temperature value.

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.
 
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.
 
Back
Top