Improving original firmware - TongSheng TSDZ2 mid drive motor

casainho said:
So this LCD seems a dead end, right? Or you still hope to optimize code size and use it?
Well, it is obvious not the best platform for future development.
But on the other hand, I (and probably many other TSDZ2 owners) already have it.
So I think I will try to see if it is usable...
 
hurzhurz said:
casainho said:
So this LCD seems a dead end, right? Or you still hope to optimize code size and use it?
Well, it is obvious not the best platform for future development.
But on the other hand, I (and probably many other TSDZ2 owners) already have it.
So I think I will try to see if it is usable...
Ok I see. Would be sad to no be able to implement the features configurations because lack of memory.

Maybe in future we can find a color display and that is widely available on online shops and cheap. Kungeng has a new color LCDs KT-LCD8S and LCD8H, they are kind of cheap but not yet on online shops -- maybe they will have the success of previous models. But, no point if they use the same STM8 with 32kbytes flash memory only...
 
Yeah, would be sad if it fails because of the memory.

Unfortunately my tries to reduce the size by not using arduino/sduino failed.
After I managed to get it compiled, it still had almost 30k. And it didn't even work (but I still haven't much experience with STM8).
But I made another approach to strip down the UTFT library by commenting out unused functions or code parts that are not used for this controller type.
Now I have 5k left!

These color displays you mentioned don't look like they are possible with just 32k, so good chances they use something better.

By the way, I'm thinking about using the XH18LCD just as a dumb serial display:
Pumping up the baud rate to the maximum and just letting it display what something else (ESP32 or so) tells it.
 
hurzhurz said:
By the way, I'm thinking about using the XH18LCD just as a dumb serial display:
Pumping up the baud rate to the maximum and just letting it display what something else (ESP32 or so) tells it.
Seems a good idea but that will not work for TSDZ2 motor controller. Let's see what you can get with that 5Kbytes.
 
this mid drive works also with bafang (750c 850c...) displays,
@ casainho: lcd8h is already in commerce, shipping fee included it costs around 60$, without shipping fee 45-50$
 
Nice work on the XH18, hurzhurz!

@hurzhurz, @casainho: what features does a display need? I did not look into full details of the code for the LCD3, but the most features
i can see is to set lot of options with a numbers-only LCD and push them to the motor controller. The other features like ODO and cunsumed watts should not be as complex to fill the flash of the XH18, do they?

I like the idea of a dumb display/buttons hardware with a more powerful controller like the ESP32!!
 
e3s said:
this mid drive works also with bafang (750c 850c...) displays,
@ casainho: lcd8h is already in commerce, shipping fee included it costs around 60$, without shipping fee 45-50$
I would like to k on it now more about that LCD8H but I do not want to spend money, just to try and see the internals. Someone must go ahead and take pictures of the inside, so we known the microcontroller and his memory and also how difficult is to program.
 
shaddi said:
Nice work on the XH18, hurzhurz!

@hurzhurz, @casainho: what features does a display need? I did not look into full details of the code for the LCD3, but the most features
i can see is to set lot of options with a numbers-only LCD and push them to the motor controller. The other features like ODO and cunsumed watts should not be as complex to fill the flash of the XH18, do they?

I like the idea of a dumb display/buttons hardware with a more powerful controller like the ESP32!!
Thanks! :)

Yeah, looks like there are many configuration options with the LCD3 and the opensource firmware.
I have flashed my motor with it today and started to adapt my XH18 firmware.
I can't tell for sure yet, but I think I can implement all or most of the configuration options.
Most problematic for the flash space is displaying data in a nice way. Fonts and symbols (like for the headlight) can be huge.
I will see how far I get... though, another problem is, I'm not very imaginative in how to arrange things that it looks good and is practical ;)

Maybe I will also try the ESP32 concept. I'm not sure yet whats the best way to transmit display data to the LCD over the serial interface.
For the baud rate, about 625k could be possible... and an additional 9.6k soft serial to the motor should be easy for a ESP32.

Oh, and I have ordered this one in the 1.8 inch version:
https://de.aliexpress.com/item/TTGO-TS-v1-0-v1-4-esp32-1-44-1-8-TFT-MicroSD-card-slot-speakers/32847643640.html
Maybe it can be fitted in the XH18 case.
Button arrangement could be a problem and it doesn't bring a buck converter and power latching circuit...
 
I've created another updated original firmware, based on your information you shared before.
In this firmware in the communication message the torque initial, actual and the error code is replaced by battery voltage, current and pedal cadence.
I've reached this with updating 7 bytes in the original firmware. Here's my github page about:
https://github.com/wptm/voamca
 
hurzhurz said:
I have now started a collection for information that are needed to develop custom firmware for the XH18LCD:
https://github.com/hurzhurz/xh18lcd
THANKS!!! I am looking at your code to understand how LCD works and I think I will reuse your UTFT C library to the Bafang Color LCD I am working on -- I got the signal from the LCD, I think I know which is the write strobe, chip select and command/data, like this:

Bafang_LCD_850C-write_strobe_signal-02.bmp.bmp


All the data I got from this LCD: https://github.com/OpenSource-EBike-firmware/Color_LCD/wiki/Bafang-850C

casainho said:
I connected the STLinkV2 clone to Bafang LCD 850C and I was able to flash and debug (run step by step and add breakpoints) a test firmware that toggles a pin. Here is the debug session on Eclipse:


And the pin signal on oscilloscope:


I am sharing the firmware here: https://github.com/OpenSource-EBike-firmware/Color_LCD/tree/master/Bafang_LCD_850C_firmware

And technical notes about the LCD: https://github.com/OpenSource-EBike-firmware/Color_LCD/wiki/Bafang-850C

As now I have all the wiring from the microcontroller to LCD, next step is try to initialize and write to LCD. The issue is that I don't know which LCD driver it uses... but I guess it is something popular, something that uses 16 data lines + some control lines.

 
casainho said:
All the data I got from this LCD: https://github.com/OpenSource-EBike-firmware/Color_LCD/wiki/Bafang-850C

Hmm, so there is no marking that tells the LCD model?

Do you know (or can you guess) the resolution?
Then you could try to lookup if UTFT could give you a clue about if it does support it and which controller it might be:
https://github.com/hurzhurz/UTFT-STM8S/blob/master/UTFT.c#L72
https://github.com/hurzhurz/UTFT-STM8S/blob/master/UTFT.h
 
hurzhurz said:
casainho said:
All the data I got from this LCD: https://github.com/OpenSource-EBike-firmware/Color_LCD/wiki/Bafang-850C

Hmm, so there is no marking that tells the LCD model?

Do you know (or can you guess) the resolution?
Then you could try to lookup if UTFT could give you a clue about if it does support it and which controller it might be:
https://github.com/hurzhurz/UTFT-STM8S/blob/master/UTFT.c#L72
https://github.com/hurzhurz/UTFT-STM8S/blob/master/UTFT.h
The LCD on his back has some numbers like some serial number (I searched on google but nothing). Also has a date of 2018/04/20.

I think it is 320x240, 3.5 inches LCD.

I finalized the code for STM32F103, it runs as expected but still the LCD shows nothing :-(

Here his the code, with your UTFT version and the changes I had to do.

I tested all 16 bits controllers and I got a black background after init this: UTFT_SER(ILI9341_16); // background get dark after init

The LCD has a backlight that I enable before init and the LCD keeps all white. After init, it stays always black (other drivers keep the background always white...).

Can you please confirm that after UTFT_InitLCD (); the LCD get's full black color?

Here is the code, would be great if you could give a look: https://github.com/OpenSource-EBike-firmware/Color_LCD/tree/master/Bafang_LCD_850C_firmware
 
casainho said:
I tested all 16 bits controllers and I got a black background after init this: UTFT_SER(ILI9341_16); // background get dark after init
Interesting is that it get's dark only after this line: UTFT_LCD_Write_COM(0x11); //Exit Sleep

If I comment the previous lines before that one, it will not get dark...
 
hurzhurz said:
I did a quick test with the XH18LCD and its ST7735S:
After UTFT() the LCD is still white and after UTFT_InitLCD() it switches to a random noise picture (or the last displayed image if still in the memory of the LCD).
I have the same experience (white and then random noise/last image) with KMR-1.8 SPI TFT and Arduino. So, then it's not related to microcontroller but TFT.
 
Thank you guys.

I was almost quitting until I tried to read some key registers and found that register driver ID of ILI 9335 does return the correct ID of 0x9335.

UTFT still is not working but maybe is the problem of my code. I will need to keep looking at it. Because if it is ILI9335, I have the datasheet of it and I should be able to make it working with more or less work :)
 
Hi guys,

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.
code is here:
maybe someone wants to look over it an merge it?

cu
vscope
 
vscope said:
Hi guys,

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.
code is here:
http://www.vscope.at/tsdz2/ebike_app.c
maybe someone wants to look over it an merge it?

cu
vscope
Seems you wrote on the wrong thread
 
The new information I got about other popular color LCD:

casainho said:
Color LCD:Kunteng KT LCD8H VS Bafang 850C

I got the Kunteng KT LCD8H color LCD and here are a picture of the main board:
Kunteng_KT-LCD8H-02.jpg


And a picture of ¨Bafang 850C¨ (http://www.aptdevelop.com) color LCD main board:
Bafang_850C_board-01.jpg


The KT LCD is cheaper but also lacks some piece of hardware that is relevant to me: 1. RTC real time clock (although seems the board was development for it, components were not assembled); 2. USB charger. Also, Bafang LCD has 512kb flash memory while Kunteng LCD has half, 256kb.

Kunteng_KT-LCD8H-05.jpg


Kunteng_KT-LCD8H-06.jpg


I can´t understand how a so powerful microcontroller 32 bits 72MHz with 256kb flash memory has a so poor interface, it just replicate LCD3 interface :-( -- seems this companies are just putting fast undeveloped products to market, in this case color LCDs just because seems popular to have a color LCD!!

As for development, the programming/flash/debug header is available the the microcontroller is the same as on Bafang 850C LCD. This are very popular microcontrollers!! very good for development. The big issue is equal to both LCDs, no documentation for which LCD driver is used so until we find out what version is, firmware can simple be developed.

If I had to choose, I would go with Bafang 850C because it has RTC. Also with double of memory, we would be able to implement advanced features for sure.

More pictures and info:
- Bafang 850C: https://github.com/OpenSource-EBike-firmware/Color_LCD/wiki/Bafang-850C
- Kunteng KT-LCD8H: https://github.com/OpenSource-EBike-firmware/Color_LCD/wiki/Kunteng-KT-LCD8H
 
hurzhurz said:
I did a quick test with the XH18LCD and its ST7735S:
After UTFT() the LCD is still white and after UTFT_InitLCD() it switches to a random noise picture (or the last displayed image if still in the memory of the LCD).
I got it working. After buying and use for the first time a logic analyzer :)

Also took me a lot of time to understand that PB3 and PB4 pins of STM32F103 does not work as GPIO after reset, so wonder why it never worked...

hurzhurz, I think I will look at your code and take it as a reference, since compared to your hardware, I just have a larger LCD...


casainho said:
Finally I got Bafang 850C color LCD working!!!

My plan is to make it working for the TSDZ2 mid drive motor running our flexible OpenSource firmware (see here), as I did for KT-LCD3. But I think would be great if other developers want to join and use this LCD for other motor controllers.

- firmware is here: https://github.com/OpenSource-EBike-firmware/Color_LCD/tree/master/Bafang_LCD_850C_firmware
- wiki page with tecnhical details: https://github.com/OpenSource-EBike-firmware/Color_LCD/wiki/Bafang-850C





 
casainho said:
I got it working. After buying and use for the first time a logic analyzer :)

Also took me a lot of time to understand that PB3 and PB4 pins of STM32F103 does not work as GPIO after reset, so wonder why it never worked...

hurzhurz, I think I will look at your code and take it as a reference, since compared to your hardware, I just have a larger LCD...

Great, congratulations! :)

Strange, but yeah, logic analysers are nice tools!
I had a situation where one helped me to understand why a serial communication that I wanted to analyse looked like garbage...

Sure, if you can use some of my code, feel free to use it...
Unfortunately I hadn't time to continue working on it... but I hope I will find some time next week to at least adapt the serial communication part to the newer motor firmware version...
 
hurzhurz said:
Sure, if you can use some of my code, feel free to use it...
Well, after I decided to go with uGUI, has it seems a bit more complete (has windows): https://embeddedlightning.com/ugui/

Well, I decided to go with the design of the original firmware of this LCD, so a bit different from your design. I do not have the limitations of memory ;)
 
hurzhurz said:
Wow, from a first look, uGUI seems pretty neat!
If possible, definitely the way to go!

I’m curious, how much memory does it cost? ;)

And what about the performance?
It was a bit troublesome on the XH18 that writing on the LCD can take a lot of time and so hold up the main routine...
Fast:

Write strobe is very fast as you can see!!
Bafang_LCD_850C-write_strobe_signal-01.bmp


GDF32F103RET6
This is a 32 bits ARM Cortex M3 that should be very similar to STM32F103.

GDF32F103RET6 main characteristics:

Maximum Speed Up to 108MHz
Flash Memory: 512K
RAM: 64K
Package: LQFP64

https://github.com/OpenSource-EBike-firmware/Color_LCD/wiki/Bafang-850C#GDF32F103RET6
 
Misunderstand your questions. I don know how much memory takes uGUI, but it is small compared to other I tested.
 
Back
Top