Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Electric Motors and Controllers
e3s   10 W

10 W
Posts: 76
Joined: Jan 08 2018 12:40pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by e3s » Oct 17 2019 11:42am

There's runtastic

Aquakitty   100 W

100 W
Posts: 150
Joined: Jun 10 2017 3:07pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by Aquakitty » Oct 19 2019 1:23pm

Hey all I'm pretty confused about what version works with what. Should the latest hex for TSDZ2 work with Alpha 0.19.12? I see you all are talking about higher versions, but for the life of me I can't find them. The link in the wiki goes here: https://github.com/OpenSource-EBike-fir ... /releases/

But if you click that repo name it says that project is deprecated. The reason I ask is I am getting a "motor not connected?" error on the SW102 (flashing it went fine) but I don't think it's my soldering.
Rans Enduro Sport w/Sturmey-Archer XFRD8, TSDZ2 open source mod 48v
GT Verb Comp f/s TSDZ2 open source 48v
Diadora Ampio bargain f/s TSDZ2 48v
2020 Diamant 247 belt drive 1000w 9C 48v
Hardtail made from random bits I had laying around, ginormous old Marzocchi fork, BBS02

casainho   1.21 GW

1.21 GW
Posts: 3907
Joined: Feb 14 2011 2:43pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by casainho » Oct 19 2019 1:28pm

Aquakitty wrote:
Oct 19 2019 1:23pm
Hey all I'm pretty confused about what version works with what. Should the latest hex for TSDZ2 work with Alpha 0.19.12? I see you all are talking about higher versions, but for the life of me I can't find them. The link in the wiki goes here: https://github.com/OpenSource-EBike-fir ... /releases/

But if you click that repo name it says that project is deprecated. The reason I ask is I am getting a "motor not connected?" error on the SW102 (flashing it went fine) but I don't think it's my soldering.
You need the latest stable version of TSDZ2 firmware, v0.19.x.
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

Aquakitty   100 W

100 W
Posts: 150
Joined: Jun 10 2017 3:07pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by Aquakitty » Oct 19 2019 1:28pm

casainho wrote:
Oct 19 2019 1:28pm
Aquakitty wrote:
Oct 19 2019 1:23pm
Hey all I'm pretty confused about what version works with what. Should the latest hex for TSDZ2 work with Alpha 0.19.12? I see you all are talking about higher versions, but for the life of me I can't find them. The link in the wiki goes here: https://github.com/OpenSource-EBike-fir ... /releases/

But if you click that repo name it says that project is deprecated. The reason I ask is I am getting a "motor not connected?" error on the SW102 (flashing it went fine) but I don't think it's my soldering.
You need the latest stable version of TSDZ2 firmware, v0.19.x.
Thank you.
Rans Enduro Sport w/Sturmey-Archer XFRD8, TSDZ2 open source mod 48v
GT Verb Comp f/s TSDZ2 open source 48v
Diadora Ampio bargain f/s TSDZ2 48v
2020 Diamant 247 belt drive 1000w 9C 48v
Hardtail made from random bits I had laying around, ginormous old Marzocchi fork, BBS02

geeksville   10 W

10 W
Posts: 80
Joined: Aug 02 2019 6:44pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by geeksville » Oct 21 2019 6:18pm

The the latest sw102 firmware is here. You want 0.19.17: https://github.com/OpenSource-EBike-fir ... D/releases

It has many improvements vs that old tree.

And you may be using a 0.19 version of the motor firmware. If you are using 0.20 motor firmware all of the current sw102 releases will show that message.

NoClassic   10 µW

10 µW
Posts: 5
Joined: Aug 28 2019 10:35am

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by NoClassic » Oct 22 2019 2:40pm

I currently have an SW102 display within an existing system and was hoping there was a way to get it functioning with a new KT controller upgrade that I recently purchased. Is this something that is possible given the open firmware available?

casainho   1.21 GW

1.21 GW
Posts: 3907
Joined: Feb 14 2011 2:43pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by casainho » Oct 22 2019 2:43pm

NoClassic wrote:
Oct 22 2019 2:40pm
I currently have an SW102 display within an existing system and was hoping there was a way to get it functioning with a new KT controller upgrade that I recently purchased. Is this something that is possible given the open firmware available?
Would be possible if the developers of the OpenSource firmware for KT, would want to support the SW102 running our OpenSource firmware -- please ask on the KT firmware thread.
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

Doohickey   10 µW

10 µW
Posts: 5
Joined: Sep 30 2019 3:04am

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by Doohickey » Oct 27 2019 6:51am

Hi all,

Just to confirm, the wiki page for wiring it says that red wire is GND on the sw102. Is this correct?

Just seems a bit odd that they'd do that, so just checking because I don't want to fry it...

geeksville   10 W

10 W
Posts: 80
Joined: Aug 02 2019 6:44pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by geeksville » Oct 27 2019 7:16am

Yes that is correct. The red wire scared me also but it is correct.

Steph   10 µW

10 µW
Posts: 5
Joined: Nov 13 2018 5:50pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by Steph » Nov 01 2019 9:42am

Hello,

As mentioned in the early posts of this thread, there is a way to backup the original firmware before tinkering with the device.
The method (also described here: https://blog.includesecurity.com/2015/1 ... nique.html in a way that I found clearer) involves locating a load instruction and looping on it.

To save time for those interested in backing up their unit, there is a such a load instruction at address 0x6B2.
Then, the dump script should be:
base = 0
loop on 256k
- set R3 = base
- set PC = 0x6B3
- step the core
- get value of R3 and save it (this is the word value @ base)
- base += 4
(I'm not using open ODC, so I cannot reproduce the actual commands, just the pseudo-script)

Sorry if this has been covered in a previous post, I somehow missed the updates here. It will take me time to read them through and I only planned for a quick visit today.

I'm also working on this display for my project (I plan to code a controller as well as the display) so I will make sure not to miss updates anymore.

Cheers,

Stephane

gatorsean   1 mW

1 mW
Posts: 16
Joined: Jun 12 2019 1:28am

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by gatorsean » Nov 01 2019 12:10pm

Is there currently a problem with the SW102 firmware version 19.17 and using the throttle?

I assumed a problem with the throttle would be in the drive controller firmware, but others have it working it seems.

In the technical menu, I see the ADC values change with the throttle, but the motor does not spin. It does spin with walk assist, so the motor and controller are working. My bike is still on the build rack so I can't quite ride it yet...

Someone else mentioned it could be overvotlage cutoff. I charge to 58.8V, but the display shows 59.6V Is there a way to adjust the cutoff or the adc calibration in the display or should I look to fix it in the code?

Thanks!

geeksville   10 W

10 W
Posts: 80
Joined: Aug 02 2019 6:44pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by geeksville » Nov 01 2019 9:48pm

Btw I made this article into a tool I used when I was doing the solderless update work: https://github.com/geeksville/nrf51-extractor
Steph wrote:
Nov 01 2019 9:42am
Hello,

As mentioned in the early posts of this thread, there is a way to backup the original firmware before tinkering with the device.
The method (also described here: https://blog.includesecurity.com/2015/1 ... nique.html in a way that I found clearer) involves locating a load instruction and looping on it.

To save time for those interested in backing up their unit, there is a such a load instruction at address 0x6B2.
Then, the dump script should be:
base = 0
loop on 256k
- set R3 = base
- set PC = 0x6B3
- step the core
- get value of R3 and save it (this is the word value @ base)
- base += 4
(I'm not using open ODC, so I cannot reproduce the actual commands, just the pseudo-script)

Sorry if this has been covered in a previous post, I somehow missed the updates here. It will take me time to read them through and I only planned for a quick visit today.

I'm also working on this display for my project (I plan to code a controller as well as the display) so I will make sure not to miss updates anymore.

Cheers,

Stephane

casainho   1.21 GW

1.21 GW
Posts: 3907
Joined: Feb 14 2011 2:43pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by casainho » Nov 02 2019 12:13am

gatorsean wrote:
Nov 01 2019 12:10pm
Is there currently a problem with the SW102 firmware version 19.17 and using the throttle?

I assumed a problem with the throttle would be in the drive controller firmware, but others have it working it seems.

In the technical menu, I see the ADC values change with the throttle, but the motor does not spin. It does spin with walk assist, so the motor and controller are working. My bike is still on the build rack so I can't quite ride it yet...

Someone else mentioned it could be overvotlage cutoff. I charge to 58.8V, but the display shows 59.6V Is there a way to adjust the cutoff or the adc calibration in the display or should I look to fix it in the code?

Thanks!
Look at git log recent commits, I did enable throttle on 850C, see if the same need to be done on SW102.

It would be very strange your motor controller to measure such wrong value of 59.6V when it is 58.8V. I also charge my 3 ebikes with 58.8V and all the 3 motor controllers measure well.
And I don't remember if the motor controller is limiting due to high voltage, if so, we need to make an error code for that situation and show to user on display.
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

gatorsean   1 mW

1 mW
Posts: 16
Joined: Jun 12 2019 1:28am

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by gatorsean » Nov 02 2019 2:59am

casainho wrote:
Nov 02 2019 12:13am
gatorsean wrote:
Nov 01 2019 12:10pm
Is there currently a problem with the SW102 firmware version 19.17 and using the throttle?

I assumed a problem with the throttle would be in the drive controller firmware, but others have it working it seems.

In the technical menu, I see the ADC values change with the throttle, but the motor does not spin. It does spin with walk assist, so the motor and controller are working. My bike is still on the build rack so I can't quite ride it yet...

Someone else mentioned it could be overvotlage cutoff. I charge to 58.8V, but the display shows 59.6V Is there a way to adjust the cutoff or the adc calibration in the display or should I look to fix it in the code?

Thanks!
Look at git log recent commits, I did enable throttle on 850C, see if the same need to be done on SW102.

It would be very strange your motor controller to measure such wrong value of 59.6V when it is 58.8V. I also charge my 3 ebikes with 58.8V and all the 3 motor controllers measure well.
And I don't remember if the motor controller is limiting due to high voltage, if so, we need to make an error code for that situation and show to user on display.
It looks like this should be the line of code to change to enable throttle? &1 is for temp, &3 is for throttle?
case 8:
// motor temperature limit function or throttle
ui8_g_usart1_tx_buffer[5] =
l2_vars.ui8_temperature_limit_feature_enabled & 3;

casainho   1.21 GW

1.21 GW
Posts: 3907
Joined: Feb 14 2011 2:43pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by casainho » Nov 02 2019 3:09am

gatorsean wrote:
Nov 02 2019 2:59am
casainho wrote:
Nov 02 2019 12:13am
gatorsean wrote:
Nov 01 2019 12:10pm
Is there currently a problem with the SW102 firmware version 19.17 and using the throttle?

I assumed a problem with the throttle would be in the drive controller firmware, but others have it working it seems.

In the technical menu, I see the ADC values change with the throttle, but the motor does not spin. It does spin with walk assist, so the motor and controller are working. My bike is still on the build rack so I can't quite ride it yet...

Someone else mentioned it could be overvotlage cutoff. I charge to 58.8V, but the display shows 59.6V Is there a way to adjust the cutoff or the adc calibration in the display or should I look to fix it in the code?

Thanks!
Look at git log recent commits, I did enable throttle on 850C, see if the same need to be done on SW102.

It would be very strange your motor controller to measure such wrong value of 59.6V when it is 58.8V. I also charge my 3 ebikes with 58.8V and all the 3 motor controllers measure well.
And I don't remember if the motor controller is limiting due to high voltage, if so, we need to make an error code for that situation and show to user on display.
It looks like this should be the line of code to change to enable throttle? &1 is for temp, &3 is for throttle?
case 8:
// motor temperature limit function or throttle
ui8_g_usart1_tx_buffer[5] =
l2_vars.ui8_temperature_limit_feature_enabled & 3;
3 options there: temperature, throttle and all disabled. Yes, must be the &3 and not &1 as was previously.
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

Nfer   100 mW

100 mW
Posts: 42
Joined: Sep 17 2019 6:51am

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by Nfer » Nov 05 2019 9:43am

I bought the SW102 but I am not sure if there is a way to flash with the Bluetooth for the first time without open it. Is it safe? I read some post a while ago

casainho   1.21 GW

1.21 GW
Posts: 3907
Joined: Feb 14 2011 2:43pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by casainho » Nov 05 2019 9:52am

Nfer wrote:
Nov 05 2019 9:43am
I bought the SW102 but I am not sure if there is a way to flash with the Bluetooth for the first time without open it. Is it safe? I read some post a while ago
Follow the wiki.
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

Nfer   100 mW

100 mW
Posts: 42
Joined: Sep 17 2019 6:51am

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by Nfer » Nov 05 2019 10:04am

casainho wrote:
Nov 05 2019 9:52am
Nfer wrote:
Nov 05 2019 9:43am
I bought the SW102 but I am not sure if there is a way to flash with the Bluetooth for the first time without open it. Is it safe? I read some post a while ago
Follow the wiki.
I see. The wiki only describes the open method. I wish I can help you guys to develop and test the bluetooth metod but I have no clue of anything related to this stuff.
https://github.com/OpenSource-EBike-fir ... -using-SWD

Edit: I found the no-need-to-open discussion. It is still under development
https://github.com/OpenSource-EBike-fir ... /issues/35

Nfer   100 mW

100 mW
Posts: 42
Joined: Sep 17 2019 6:51am

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by Nfer » Nov 09 2019 8:43am

Nfer wrote:
Nov 05 2019 10:04am
casainho wrote:
Nov 05 2019 9:52am
Nfer wrote:
Nov 05 2019 9:43am
I bought the SW102 but I am not sure if there is a way to flash with the Bluetooth for the first time without open it. Is it safe? I read some post a while ago
Follow the wiki.
I see. The wiki only describes the open method. I wish I can help you guys to develop and test the bluetooth metod but I have no clue of anything related to this stuff.
https://github.com/OpenSource-EBike-fir ... -using-SWD

Edit: I found the no-need-to-open discussion. It is still under development
https://github.com/OpenSource-EBike-fir ... /issues/35
I tried to open the sw102 cutting the glue at sides of the keypad and I killed the down button contact. It was my fault, instructions are good.
Is it possible to use the display without the down button?

windburner   100 mW

100 mW
Posts: 39
Joined: Sep 24 2019 3:45pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by windburner » Nov 09 2019 11:13am

Nfer wrote:
Nov 09 2019 8:43am
I tried to open the sw102 cutting the glue at sides of the keypad and I killed the down button contact. It was my fault, instructions are good. Is it possible to use the display without the down button?
The Down button is critical for the configuration process, as well as adjusting the Assist Level, so, I'd say no. Can you solder in a wire or something to bridge the break? (I know it is tight working, as I hope to never have to mess about inside my SW102 again.)
TerraTrike Rover Tandem - TSDZ2 48V 750W - 13AH Batteries - VLCD6-->SW102 with v0.6.5 OSF

geeksville   10 W

10 W
Posts: 80
Joined: Aug 02 2019 6:44pm

New SW102 release 0.5.0-beta4

Post by geeksville » Nov 09 2019 9:54pm

Hi ya'll,

The 0.19.17 was pretty solid, but I released it for the gang before I was on a long hiking trip. This new release pulls in the great work by @casainho and @lowPerformer. Note: I've switched to the naming system they constructed for versions, so this new version is 0.5.0-beta-4. It is what we recommend if you have a SW102. Currently we do releases on a per device basis, but it is fairly likely that soon releases will include both SW102 and 850C binaries for each release build.

Major changes in this release:

* SOC calculations now work! (kudos @lowPerformer)
* Automatic power off interval is now correct (kudos @lowPerformer)

A full list of changes is [here](https://github.com/OpenSource-EBike-fir ... 5.0-beta-4)

The initial install (mainly getting access to the programming pins) is a bit of a hassle but we've written [instructions](https://github.com/OpenSource-EBike-fir ... re-install) to make it easier. Every installation after that is very painless via our bluetooth bootloader software-update.

If you are upgrading from a previous release, you can upgrade over bluetooth. The procedure is:

* Install "nRF Connect" from your appstore of choice (Google Play or whatever)
* Download our [sw102-otauptdate-xxx.zip](https://github.com/OpenSource-EBike-fir ... D/releases) file onto your phone (do not unzip)
* Press and hold the M key on the SW102, then press and hold the power button. Keep both buttons pressed down for at least eight seconds. You can then release the buttons. You will know you are in the bootloader if the screen stays dark.
* Run the "nRF Connect" app. You should see "SW102 DFU" list, click on Connect
* On this new pane you will see a small DFU icon in the upper right of the screen. Click on it.
* Select our "application bundle" and our zip file.
* The update should start and show progress as it progresses
* After the upload completes turn your bike completely off
* Then start your new SW102 load as normal (a long press on the power button)

Future releases will include release notes, but for now here's a link to our [TODO list](https://github.com/OpenSource-EBike-fir ... re/TODO.md). If you encounter bugs please open as issue [here](https://github.com/OpenSource-EBike-fir ... LCD/issues). Make sure you mention you were using a SW102 and include as much information as possible.

We look forward to your reports of great success (or failure, ahem) in this [thread](viewtopic.php?f=30&t=99698).

windburner   100 mW

100 mW
Posts: 39
Joined: Sep 24 2019 3:45pm

Re: New SW102 release 0.5.0-beta4

Post by windburner » Nov 10 2019 12:05am

geeksville wrote:
Nov 09 2019 9:54pm
This new release ...
Thanks all for the work this represents.

Can you confirm that the ability remains to revert to 0.19.17 via bluetooth should we encounter a disabling condition with 0.5.0-beta-4?
TerraTrike Rover Tandem - TSDZ2 48V 750W - 13AH Batteries - VLCD6-->SW102 with v0.6.5 OSF

geeksville   10 W

10 W
Posts: 80
Joined: Aug 02 2019 6:44pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by geeksville » Nov 10 2019 1:18am

alas - the bootloaders that we have out in the field now can't go backwards (there are various pros cons to letting that happen). So I can't change that choice we made without pushing out new bootloaders (which I'm loathe to do without a really good reason). Historically our releases have been pretty good (though the .13ish era was a bit rough because I was testing sans bike). I've been using this build on my bike for a couple of days and it seems pretty good (and the SOC stuff is great).

If there is a big problem with this release I'll quickly push out a new build (even if it means just bumping the version number from an old source tree).

geeksville   10 W

10 W
Posts: 80
Joined: Aug 02 2019 6:44pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by geeksville » Nov 10 2019 1:20am

windburner wrote:
Nov 09 2019 11:13am
Nfer wrote:
Nov 09 2019 8:43am
I tried to open the sw102 cutting the glue at sides of the keypad and I killed the down button contact. It was my fault, instructions are good. Is it possible to use the display without the down button?
The Down button is critical for the configuration process, as well as adjusting the Assist Level, so, I'd say no. Can you solder in a wire or something to bridge the break? (I know it is tight working, as I hope to never have to mess about inside my SW102 again.)
If you do need to fix your button, you can try removing the PCB (it comes out with a little connector on the back - just flip the black tab up to release the cable). This should give you better access to plug in a jumper. But if that won't work, yeah you'll need to plunk down another $35.

bikelpl   10 µW

10 µW
Posts: 6
Joined: Jul 09 2019 1:52am

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by bikelpl » Nov 10 2019 12:49pm

Hello, i've sucesfully flashed my SW102.
I did it in quite clean way so i want to share some photos with You.
I just cut small hole at side panel..
After this operation, all should be still waterproof.
Image

Key to sucesfull solder thin wires is to make thin soldering iron tip.
I did it from one single wire from 10mm2 cable.
After all i glued it with hot gun glue.
Excessive gluea i removed by cutting it.
You can use heat gun at the end or lighter to "polish" cutted hot gun glue.

You can download bigger photos from here: http://bikel.pl/pliki/TSDZ2/SW102/sw102-proces.zip

What do you think?

Post Reply