Lishui "Open Source Firmware" project / KingMeter 5S

Is the process described somewhere?
It't quite easy.
1. Install the STM32 Workbench and import the project like described in the wiki
2. Compile the code once by a click on the hammer icon.
3. Create a new debug configuration with the default settings (drop down menue next to the bug icon).
4. Start a debug session by clicking the bug icon.
5. Set breakpoints at interested parts and start the execution with the play button.
6. Pause the code with the pause button, to see which part of the code is processed at the moment
7. Check variable values in pause mode with "mouse over" or by expressions.

See the screenshot in this thread, it's from the CubeIDE, not from the STM32 Workbench, but both are Eclipse based, so they are very similar.
 
Last edited:
I tried flashing the firmware in Eclipse. The problem was the overcurrent protection tripping and going into an infinite loop.
C:
if(q31_i_q>(PH_CURRENT_MAX<<2)){
        CLEAR_BIT(TIM1->BDTR, TIM_BDTR_MOE);        //disable PWM if overcurrent detected
        while(1){}                        //stay here until hard reset
    }
I looked at the Master branch. The current calculation and current protection algorithms there differ from the new-generation 12FET branch. Could you explain these differences in general terms?

Questions:

Are you currently using the new generation 12FET controllers?

I understand that the hardware differences between the new generation 12FET controllers aren't that significant or fundamental? The pins are slightly different, 64-128 KB of memory instead of 32 KB. My LSW12G-USAMK-F V1.03 1mOhm board also has 1mOhm phase shunts.

I'm wondering if it might be worth adapting the firmware from the Master branch for the new generation of 12FET controllers?

I would like to hear the author's detailed comments on these issues.

Thanks in advance.

And I kindly ask you to answer all the questions if possible, and not just the last one.:)
 
Last edited:
Could you explain these differences in general terms?
In the master this safety measure simply doesn't exist. I added it to the sensorless branch some day and when I added the sensorless feature to the NewGeneration branch, I copied it with the rest of the sensorless stuff.

Are you currently using the new generation 12FET controllers?
Sure, my wife uses it on her NCM C7 :cool:
Obviously your controller needs quite long until the ADC inputs have stabilized, so you get wrong offset readings from time to time?
 
Obviously your controller needs quite long until the ADC inputs have stabilized, so you get wrong offset readings from time to time?
I thought so too, but now I see that with a delay greater than 500 milliseconds, the torque sensor offset is calculated correctly. Mine is around 900, which corresponds to about 1500 millivolts.

Does your wife's bike have a board with 1 milliOhm shunts?
 
Does your wife's bike have a board with 1 milliOhm shunts?
Yes, I have not seen a Lishui controller with a different shunt value yet. But of course the shunt value is just one part, The backloop resistor on the opamp defines the calibration factor for the phase current in the same way. But this isn't related to your issue, I think.
 
Yes, I have not seen a Lishui controller with a different shunt value yet. But of course the shunt value is just one part, The backloop resistor on the opamp defines the calibration factor for the phase current in the same way. But this isn't related to your issue, I think.
You're probably right. But there may be other differences.

And still, please answer how much better the firmware from the master branch is debugged.
I'm wondering if it might be worth adapting the firmware from the Master branch for the new generation of 12FET controllers?
 
I'm wondering if it might be worth adapting the firmware from the Master branch for the new generation of 12FET controllers?
There are only very slight differences. The master has less possibilities for options like sensorless control, as it is really near at the memory limit of 26kB (32kB Flash, 4kB for the bootloader, 2kB for the virtual EEPROM). The only thing, you should think about is the watchdog, that is implemented in the master only. This would let your controller reboot automatically, if it hangs at startup (if you start the watchdog before the code stucks).

 
This bike continues to torment me in the same way. I set up data transfer in debug mode via the UART-HM10 to my phone and measured the actual voltage of the torque sensor output. It's the sensor that's glitching in the cold. While it's warm, 22-25 degrees Celsius, everything works fine. As it cools outside, it first gives the correct signal, then hovers at the offset level. Then, when turned on, it immediately gives a signal well above the offset and the motor spins without any pedal input. Then, it dies completely, with a signal at the offset level. Can you imagine the sensor's circuit diagram? Is there any point in messing with it? The stationary electronics are encased in plastic. The problem could be with the rotating part, as sometimes the sensor's state changes when I pedal backwards, or sometimes the issue occurs at a certain pedal position. But that's not certain. Your comments are welcome.
 
I also forgot to ask. Which inexpensive compatible screens would you recommend that are more informative than the EN-06? So they can show current and power.
 
Этот велосипед продолжает меня мучить тем же самым образом. Я настроил передачу данных в режиме отладки через UART-HM10 на свой телефон и измерил фактическое напряжение на выходе датчика крутящего момента. Проблема в том, что датчик глючит на холоде. Пока тепло, 22-25 градусов Цельсия, всё работает нормально. По мере охлаждения на улице он сначала выдаёт правильный сигнал, затем зависает на уровне смещения. Затем, при включении, он сразу же выдаёт сигнал значительно выше смещения, и двигатель вращается без какого-либо нажатия педалей. Затем он полностью глохнет, оставляя сигнал на уровне смещения. Можете себе представить схему датчика? Есть ли смысл с ним возиться? Стационарная электроника заключена в пластиковый корпус. Проблема может быть в вращающейся части, так как иногда состояние датчика меняется, когда я кручу педали назад, или иногда проблема возникает в определённом положении педалей. Но это не точно. Ваши комментарии приветствуются.
 
Back
Top