• Hello ES! We could use some help to get us past the finish line on building the new knowledgebase for the forum.
    Can you donate? Please see our fundraising page. Thank you!

Lishui "Open Source Firmware" project / KingMeter 5S

Sorry, you're starting to get really annoying. Read the wiki three times before you ask questions here!
I’m sorry, maybe I was not able to express my thoughts correctly.

I can confirm that the brake input is indeed connected to the CAN_RX contact.

I will continue investigating and trying to understand how everything works.

Could you please tell me if there is a forum thread about configuring the controller through the Lishui Programmer Configurator application? Maybe there I could find answers to my questions.

I still have a question about how to make the controller work correctly with the No.2 protocol, including the throttle handle and PAS system.

I don’t remember — do I need to configure all of this through the Lishui Programmer Configurator, or do I need to make changes directly in the firmware files?

Thank you very much. Have a nice evening.
 
I still have a question about how to make the controller work correctly with the No.2 protocol, including the throttle handle and PAS system.
- choose No2 protocol in the display setting.
- uncheck the torquesensor button
- activate throttle override (is already activated)

Autodect has only to be run once. The found configuration is stored in the virtual EEPROM and read in at the next start up automatically.
All this information can be found in the Wiki.
 
- choose No2 protocol in the display setting.
- uncheck the torquesensor button
- activate throttle override (is already activated)

Autodect has only to be run once. The found configuration is stored in the virtual EEPROM and read in at the next start up automatically.
All this information can be found in the Wiki.
I repeated all these steps again.

Here is what I have now:
The display protocol is working. If I rotate the motor wheel by hand, the speed is shown on the display. If I press the brake, the brake icon appears on the display. So the communication protocol seems to be working correctly.

The next issue is that when I press the throttle, the wheel makes one full rotation and then stops. After about 5 seconds, it makes another rotation again, and this repeats.

My throttle is connected to SP, GND, and 5V.

It feels like there is still something missing or something is not configured correctly.
27722.jpg27721.jpg
 
The rotation power also depends on how much I turn the throttle. This means the controller understands the throttle signal level correctly.

But why does it make these jerks every 5 seconds? It feels like some kind of protection is being triggered.

I could record a video to show the behavior more clearly, if that would help with troubleshooting.
 
Code:
#define ЛЕГАЛЬНЫЙ ФЛАГ

The legal flag is set (if you wouldn't use Cyrillic letters, I would have seen that earlier ;))

With the legal flag active the throttle supports up to 6kph only. So the throttle accelerates the motor without load far faster than 6kph. So the assistance is switched off. When the display shows something below 6kph, it accelerates again...

But I don't know which parameter switches this flag in the Java tool, as said, the GUI was updated by other users.
 
Code:
#define ЛЕГАЛЬНЫЙ ФЛАГ

The legal flag is set (if you wouldn't use Cyrillic letters, I would have seen that earlier ;))

With the legal flag active the throttle supports up to 6kph only. So the throttle accelerates the motor without load far faster than 6kph. So the assistance is switched off. When the display shows something below 6kph, it accelerates again...

But I don't know which parameter switches this flag in the Java tool, as said, the GUI was updated by other users.
Thank you very much for helping me. :))

Let’s assume the speed limitation issue can be solved later. We can leave it for now.

According to the instructions, to start the autodetect procedure, I need to hold the brake and throttle, and then the controller should start the automatic detection.

But in my case, this does not happen. The autodetect procedure does not start.

I’m not sure what I am missing.
 
I changed the legal flag to:

// #define LEGAL_FLAG

in both files, "main" and "config", in the project folder.

However, there are no changes. The behavior remains the same.
 
According to the instructions, to start the autodetect procedure, I need to hold the brake and throttle, and then the controller should start the automatic detection.
?! Why do you want to start it again?!

Autodect has only to be run once. The found configuration is stored in the virtual EEPROM and read in at the next start up automatically.
All this information can be found in the Wiki.

But I don't know which parameter switches this flag in the Java tool, as said, the GUI was updated by other users.
You would have a look into the code of the Java tool, to find the line, where the legal flag is written to the config.h

Edit:
OK, @consp has hardcoded that line, so you can't disable the legal flag, if you use the GUI of the recent master.
 
Last edited:
?! Why do you want to start it again?!




You would have a look into the code of the Java tool, to find the line, where the legal flag is written to the config.h

Edit:
OK, @consp has hardcoded that line, so you can't disable the legal flag, if you use the GUI of the recent master.
I deleted the line related to the legal flag at line 347 in the Java file.

I also removed all references to the legal flag in the "config" and "main" files.

After that, I flashed the controller again, but the speed is still limited to 6 km/h.

What am I doing wrong?
 
What am I doing wrong?
You have to make a new jar file from the edited Java project. Just editing the source file does not update the executable jar file.
There is a batch file in the main folder called Start_ohne_GUI.bat
I have not used it for ages and I don't know, if it still works, but you can try it. Just edit the config.h manually and then double click this batch file without using the Java Tool. This avoids that the config.h is overwritten by the GUI.
 
You have to make a new jar file from the edited Java project. Just editing the source file does not update the executable jar file.
There is a batch file in the main folder called Start_ohne_GUI.bat
I have not used it for ages and I don't know, if it still works, but you can try it. Just edit the config.h manually and then double click this batch file without using the Java Tool. This avoids that the config.h is overwritten by the GUI.
I tried this method, but the speed is still the same — 6 km/h (((

I even tried to erase the chip completely using ST-Link Utility and then flash it again through “Start ohne GUI”.

Nothing helps.

Most likely, the 6 km/h limitation is some kind of protection that is located deeper in the firmware or somewhere else.
 
So, the PAS assistant is working. The speed is always 25 km/h, regardless of the assistance level (1, 2, or 3).

The throttle is limited to 6 km/h. The next steps are to remove the speed limit and check whether the PAS assistance levels can be adjusted.

The brakes are working correctly.

The speed is displayed correctly on the display.
 
The next steps are to remove the speed limit and check whether the PAS assistance levels can be adjusted.
Without load you will get always max speed, as the motor current is controlled, not the speed. You will notice the differences in the assist levels only with load.
The speed limit is activated with the legal flag. So you have to define something like 100kph for the limit or you have to disable the legal flag. I've just updated the Jar file, but I have not tested it. So download the new JavaConfigurator.jar file from the repo and try it.

1783934604743.png
 
The display No.2 shows this error.
This has to do something with your local installation. I just compiled with No.2 protocol by the github actions, it works without errors. Perhaps you should newly download the whole repo.

Building target: LishuiFOC_01.elf
Invoking: MCU GCC Linker
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -mfloat-abi=soft -L Drivers/CMSIS -specs=nosys.specs -specs=nano.specs -T"STM32F103C6Tx_FLASH_Bootloader.ld" -Wl,-Map=output.map -Wl,--gc-sections -o "build/EBiCS_Firmware.elf" @"objects.list" -larm_cortexM3l_math -lm
Finished building target: LishuiFOC_01.elf

make --no-print-directory post-build
Generating hex and Printing size information:
arm-none-eabi-objcopy -O ihex "build/EBiCS_Firmware.elf" "build/EBiCS_Firmware.hex"
arm-none-eabi-objcopy -O binary "build/EBiCS_Firmware.elf" "build/EBiCS_Firmware.bin"
arm-none-eabi-size "build/EBiCS_Firmware.elf"
text data bss dec hex filename
25304 120 2928 28352 6ec0 build/EBiCS_Firmware.elf
 
Last edited:
This has to do something with you local installation. I just compiled with No.2 protocol by the github actions, it works without errors. Perhaps you should newly download the whole repo.
I found the problem! The solution was that I had to copy the entire content from the file displayNo2.c in the Src folder and paste it into the main.c file.

After that, everything compiled and flashed successfully. Now both the throttle handle and the PAS assistant are working at 25 km/h :)))

I am so happy!!! A huge thank you to you!!!

You are a genius!!! :)

Making a controller work with displays it was not originally designed for is truly amazing!
 
I also tried changing the speed limit in the GUI from 25 km/h to 50 km/h, but the controller still does not go faster than 25 km/h.

Is there any way to remove this limitation?
 
This is no limitation of the firmware, but the characteristics (Kn constant) of your motor. You will have to increase the battery voltage to get higher speeds.
You can check this with your lab power supply easily by varying the voltage at full throttle.
I understand now. Once again, thank you so much!!! This is an amazing project!!! :)

Sorry for bothering you with so many silly questions. But I managed to get it working! :)
 
This is no limitation of the firmware, but the characteristics (Kn constant) of your motor. You will have to increase the battery voltage to get higher speeds.
You can check this with your lab power supply easily by varying the voltage at full throttle.
I have one more question. I also have a bicycle with a Sino Wealth controller.

The bicycle is also 36V, but in unlocked mode it can reach a speed of up to 36 km/h. So this means that the 25 km/h limit is probably just a software restriction.

And another question: do you think this Sino Wealth chip could be flashed using the same principle as your method?
 
25028.jpg
I have one more question. I also have a bicycle with a Sino Wealth controller.

The bicycle is also 36V, but in unlocked mode it can reach a speed of up to 36 km/h. So this means that the 25 km/h limit is probably just a software restriction.

And another question: do you think this Sino Wealth chip could be flashed using the same principle as your method?
 
No. As far as I can read from your photo, this is a SH79F64xxx (8051, 8bit, 16MHz) processor. This is completely different from the STM32F103 (ARM Cortex-M3, 32bit, 64MHz).
Good day! I found another controller with an STM32G071 chip. I'm not completely sure I've identified the marking correctly, so I've attached a photo.
Do you think it could also be flashed using your method?
Thank you for your reply!27791.jpg27792.jpg27793.jpg
 
Back
Top