RoboDurden / Hoverboard-Firmware-Hack-Gen2.x

with different defines_2-x.h for different board layouts :-) Compiles with Keil version 6
GNU General Public License v3.0
73 stars 24 forks source link

Gen2.1.7.1 (ex2.6.1) #49

Open AILIFE4798 opened 6 months ago

AILIFE4798 commented 6 months ago

I have a board very close to layout 2.6 I'm not sure if I can use that or to open another one If it is needed I can help trace wire pinout I really want support asap Here is some as clear as I can get pictures because phone camera quality is bad IMG_20240104_013702 IMG_20240104_013749 IMG_20240104_014006 Master board is with power button and Bluetooth and slave board is with buzzer

Mcu:gd32f130c6t6(I heard that the rom is too small so it cannot support this firmware?) Imu:854lc1(no info on Google) Gate driver: eg2131

The board is got from the cheapest most common brand hoverboard in China called AERLANG(please don't buy it the quality of the wheel is very bad it only have 3 parallel wire but I got mine for free)

I have some follow up question to ask because I want to make a robot with 6 wheel and I have 2 gen 1 hoverboard and this cheapo one is there any way to control these together because it's very hard to buy gen 1 hoverboard

AILIFE4798 commented 6 months ago

@RoboDurden and how can I use your server to build gen 2 firmware I can only find option to use gen 1 and I've successfully flashed gen1 with uart mode

RoboDurden commented 6 months ago

For this firmware you need to install Keil ide if you need to compile a new binary.

C6 only has 32 kB but this is enough for this simple gen2.x firmware :-)

Please trace the three hall pins and make sure that the 6 monsfet pins are the standard configuration. See defines_2-0.h

2.6 has not been traced yet.

But if you have the three hall sensors and the six mosfet and maybe the green and red led I will add a defines_2-19.h for you and you could start testing.

But you should by all means use a constant current power supply with 1-2 A max ! Simple dcdc step down converter could also do.

RoboDurden commented 6 months ago

Please add photos of the housing / outside so people can see from the outside what is inside.

What do you mean with 'the wheel is very bad it only have 3 parallel wire " ? Please describe with a photo :-)

RoboDurden commented 6 months ago

Yes this is likely compatible with the 2.6 board which is labeled as v1.5 whereas yours is labeled as v1.5.1. I have uploaded your photos to the 2.6 folder. If you trace the following pins, i will add a defines_2-6-h file for you: grafik

The upper left 4 pin header might be PB6 and PB7, the lower right 4 pin header might go to PA2 and PA3 the three resistors driver the three transistors which might drive the three color led module. The six mosfet outpins seem to be the default ones. With the three hall pins traced, you might already get the motor spinning.

Keil is easy to install.

AILIFE4798 commented 6 months ago

@RoboDurden this is the reverse enginered schematic hoverV2 6 1_compressed i think i have missed quite a few connections but its all i can find

AILIFE4798 commented 6 months ago

IMG_20240105_020440 This is the wheel from the hoverboard and as you can see it's all plastic and there is only 3 parallel copper wire for the winding so it's probably only rated 150w or something like that way less then the normal aluminum wheels

AILIFE4798 commented 6 months ago

i am hardware guy thats why im here looking for code from more intelegent people like you can you please compile firmware for me i am afraid to use keil to compile my self if not for your server i will not attempt this project so thanks allot

i have got a stlink v2 adapter but i have taken it apart and it is fake with apm32 insted of stm32 is there any way to repair it or where can i get a proper one i have used it to flash gen 1 board but its stm board insted of gd32 so idk if it will still work with fake stlink

i have a lab bench power supply so i am ready to test firmware and btw the battery is also of low quality its only 1 cell in parallel one of the worst ive seen so i will use lab bench power supply im intrested why to use constant current because with dedicate gate driver it should not be able to create a short circuit even if the mcu tries to because of wrong pinout

AILIFE4798 commented 6 months ago

Some additional closeup picture increase you needed it as the full picture is very blurry

IMG_20240105_022512

IMG_20240105_022536 IMG_20240105_022618

IMG_20240105_022554 IMG_20240105_022609

AILIFE4798 commented 6 months ago

updated schematic hoverV2 6 1_compressed_fix1

RoboDurden commented 6 months ago

Good job . I will compile a binary the next two days. But I might need 10+ compilations until every pin is correct.

Keil is really very simple. Install Open the project file Hit f7 to compile Hit f8 to upload to gd32

You might have more problems installing the bin file.. That plastic wheel looks awful indeed. Please upload.photos of the housing / box / outside so others won't buy it Unless it is less the $60 new ;-)

Yes, gate driver chips should prevent a short cut. But not a continuous current from mosfet a-hi to b-lo.

With new binaries it is really recommended to start with 1-2 Ampere max.

RoboDurden commented 6 months ago

You have PB5 for two different led: temp

You might be able to solder a tx cable to the lower side of the PB7 RX smd resistor and a rx cable to the lower side (the MCU side) of the PB6 TX smd resistor: temp

I have set the three hall sensors to

// Hall sensor defines
#define HALL_A  PB11
#define HALL_B  PA1
#define HALL_C  PC14

But it might need to test all six possible permutation until the vibration of the motor turns into a smooth spinning. I am not really willing to do all these many compilations for you. Download Keil IDE.

The led will also need many permutations until all colors are correct:

// LED defines
#define LED_GREEN PA15
#define LED_ORANGE PB3
#define LED_RED PB4

#define UPPER_LED   PB5 
#define LOWER_LED   TODO_PIN

The adc input pins will also need some pin testing until voltage and current is logged correctly to ESP32:

// ADC defines
#define VBATT   PA4     // robo just guessing
#define CURRENT_DC  PA7 // robo just guessing, next guess would be PB0

If your pin tracing was correct, the onoff button an power-hold transistor might already work:

// Self hold defines
#define SELF_HOLD   PB2     // robo: called latch on the pin tracing ?

// Button defines
#define BUTTON  PA5     // robo: called BTN detect on the pin tracing image ?

#ifdef HAS_BUZZER
    // Buzzer defins
    #define BUZZER  PB9
#endif

Otherwise you will have to constantly power the board until pin definitions are correct.

Start with BinariesToTest/hoverboard 2.6 master Dummy.bin and see if the motor is vibrating or spinning. With hoverboard 2.6 master Uart.bin you can already get serial log data on PB6/PB7

AILIFE4798 commented 6 months ago

I hope I didn't got too many pin wrong so it'll work in few try Where do I connect the stlink to flash it Can keil work with fake st link and how to unlock gd32 without nrst Pb5 really is connected to 2 led in parallel(the led have it's own MOSFET but the gate series resistor is connected together I am not 100% sure the power button and latch pin is correct but we'll see when I test the firmware later

RoboDurden commented 6 months ago

PA14 = SWCLK and PA13 = SWDIO

cheap clones flash just as nicely as stLink. Try the autoflash.bat in the readytoflash/ folder !

And run windows St-Link-Utility to unlock the bootloader and enable all option bits..

plastic wheel might be good when weight is a problem. Like robot arm..

RoboDurden commented 6 months ago

There might be a little smd led on board that is not yet traced:

// Mosfet output, little onboard led
#define MOSFET_OUT  TODO_PIN
RoboDurden commented 6 months ago

what is this sot-8 chip to the very left ? grafik

AILIFE4798 commented 6 months ago

I will try to flash when I'm home Plastic wheel indeed is very light weight but I'm not sure how much power it can handle is it really worth it I cannot find smd led can you circle it out in the picture I only find in gen1 board The 8 pin ic is likely audio amplifier for Bluetooth speaker

RoboDurden commented 6 months ago

no you test a board that you have not yet flashed to see if some little red led shows up. If not then we do not have such a little led. no problem.

There are applications like lawn mover, where 350+ Watt are not needed anyway. Only thre copper wires might mean more windings and better efficiency at low power :-) Or the plastic stator needs more space so less copper available for windings :-( Please share photos of how such a plastic hoverboard looks like ! What is the price to buy new ?

AILIFE4798 commented 6 months ago

i have tested board with original fw no led is found i have alr taken the hoverboard apart and its not going back together so look elsewhere for the picture it cost abt $80 new you may be able to find other ones for even cheaper

AILIFE4798 commented 6 months ago

i have just tested the remote dummy firmware when i push the button the turn signal lighting continuely when i release the button the power latch works and the board keep on the motor is locked up and when i force it by hand the 3led board start spinning with 1~2 led on at same time when i reverse 2 of the motor phase wire the motor starts spinning back and forth so i think my pinout is mostly correct the slave board have no sign of life at all because it does not have 15v buck regulator so i think i will need to modify it

RoboDurden commented 6 months ago

Which two phases did you need to swap ? The slave board is powered via the master slave uart cable if no dcdc is on the slave board.

Try connecting the esp32 to PB6 and pb7

AILIFE4798 commented 6 months ago

i swapped yellow and green the pinout of rotating led is 15v,orange(master only),green,red why not use pa2 pa3 as serial as its ment to do i can solder the pin to smd resistor no problem just curious

RoboDurden commented 6 months ago

With only one uart header you can use my uartBus protocol to control each single motor by esp32. Normally you use RemoteUart and send steer + speed to the master which then controls it's slave. Will be easier as you need the master slave cable of pa2 pa3 to power the slave.

AILIFE4798 commented 6 months ago

I have connected to the uart and when I connect USB to serial and baud 19200 it send something that is not humanly readable I tried to connect to esp(which I can't believe took forever since esp32 is known territory for me) and it kinda works now but not really the checksum keep failing for some reason idk https://media.discordapp.net/attachments/1148619676297986150/1192882399298727986/image.png?ex=65aab14e&is=65983c4e&hm=fabc14e1066a40484bbf7238feab07a60a530f08a01f7870bfe5afda74bd10ec&

AILIFE4798 commented 6 months ago

image-6 Image failed to attach

AILIFE4798 commented 6 months ago

Is the serial protocol compatible with gen1 board so I can connect all tx in parallel so they move at same speed or is there a better way to control multiple gen1/2 boards with one esp

RoboDurden commented 6 months ago

no my protocol is not compatible to gen1 I have updated the binaries with this hall configuration:

// Hall sensor defines
#define HALL_A  PC14
#define HALL_B  PA1
#define HALL_C  PB11

your esp32 log output does not really makes sense to me. The hover message should begin with CD AB ( or AB CD) and not end with it.

And it looks as if the checksum at the end of the transmitted message is always 0 (tmpFeedback.checksum).

But as i do see CD AB, you indeed do seem to receive the hoverboard data.

Sorry i will not be able to help you with this in the next days. I am living outdoors and -8°C coming..

AILIFE4798 commented 6 months ago

ok i will test the new hall mapping tomorrow

i am using the testspeed example but modify the serial to serial2 because serial1 does not exist on esp32... the one you have is esp32s2 not the original esp32 but i dont think it matters anyways as it can receive the data the CDAB at the end actually can cchange to something else when i turn the wheel and it is reproduceablebut its only these two combination no other random chracter

have you change the led pin because it seems to be wrong it should be

#define LED_GREEN PB3
#define LED_ORANGE PA15

is there any more pins that seems to be missing i need to check to make it fully support or sth else if no ill wait patiently when you are free to help me

RoboDurden commented 6 months ago

when log data is correct you can verify battery voltage and current DC.

Sorry, no more compilations from me today. As i said, you better install Keil :-)

Good night from Germany.

AILIFE4798 commented 6 months ago

where can i download keil without log in i downloaded st link utilities from third party i will try to mess around with the serial to see whats wrong hopefully ill figure out soon enough not on a hurry any more now

goodnight from China

RoboDurden commented 6 months ago

Oh it is an honor for me to have someone from China here on my GitHub project !!

Yes it needs an email to receive the official download link for the Keil IDE..

Then of course I will happily compile as many binaries for your as you need :-)

Just please remember that I currently live outdoors with my solar camper kleine gute Tat zu viel Regen laesst Buchen kippen

I will try to upload the Windows 64 bit Keil Installation file to my server at the next free WLAN hotspot.

Does the latest binary with swapped hall a and c work for you ?

Otherwise I will upload all six binaries with the six possible permutations.

Good morning :-)

AILIFE4798 commented 6 months ago

morning

id expect allot more people from China here because all the latest and cheapest tech is made and first sold here so well often need to create custom layout anyways if you need support about chinese datasheet etc i can probably help add me on discord as ailife

i will try keil if you can provide installation file because after all you do not learn if you dont try new thing and can you also provide stlink driver because my desktop cannot install stlink it says the driver is not signed but i have disabled force signing i have to use my laptop to flash maybe linux is better after all

the new hall mapping can make the motor spin but not smooth and only in one direction i need to help it to spin other direction swap phase wire does not help i think we are closer

and the serial issue have been resolved now i just made stupid mistake of not commenting out remote uartbus it certainly didnt help to have no documentation but well im a hardware guy

the battery voltage is close enough (24.3 vs 23.6) the current is random value i have tried to unplug motor phase and it didnt change anything image IMG_20240106_152142

AILIFE4798 commented 6 months ago

oh and i have seen your solar camper project on youtube its really cool imo wish i would do sth like this in the future

AILIFE4798 commented 6 months ago

This is how to solder pin header to access serial for those that don't know IMG_20240106_193026

RoboDurden commented 6 months ago

nice header! the left pin ist GND ? I have uploaded all six permutaions as Master_Dummy to https://github.com/RoboDurden/Hoverboard-Firmware-Hack-Gen2.x/tree/main/HoverBoardGigaDevice/BinariesToTest

One of the hoverboard_ABC.bin should make the motor spin forward and backwards nicely.

All three led are blinking ? You already mention the overlap of two led while the motor is rotating which is as it should be. The led blinking is activated with this define in config.h

define TEST_HALL2LED // led the 3-led panel blink according to the hall sensors

Still no free wlan hotspot nearby. And still 48 km to drive home to my train station. So i guess it will be tomorrow afternoon to have unrestriced internet connection.

AILIFE4798 commented 6 months ago

ok i will test hall sensor layout first and report back yes the led is blinking in circle and overlapping yes the left serial header is GND take your time ill wait for ur support

RoboDurden commented 6 months ago

Here is a download link for the STM32-ST-Link-Utility maybe it includes such a driver you asked for: https://www.robosoft.de/forums/en.stsw-link004.zip

The Keil IDE ( https://www.keil.com/demo/eval/arm.htm ) will have to wait. The Demo is limited to 32 kB but this is all this simple firmware needs anyway.

AILIFE4798 commented 6 months ago

the layout is BCA

AILIFE4798 commented 6 months ago

thanks the st link utilities i downloaded is too old yours worked just fine

RoboDurden commented 6 months ago

Okay i have uploaded new binaries with BCA. So you can now control with ESP and als test conecting the slave to master. Only current adc pin is still wrong i guess. When putting a hand on the rotating motor you should see an increasse of 1-2 Amps. Will also need some try and error binaries. But that can wait until i am home :-)

Battery chared to full at free eBike charging station so i continue my ride/drive :-) Roland and off.

AILIFE4798 commented 6 months ago

i have tested the master uart with correct motor wiring and its working now the slave also working only theres no power off melody like on gen1 the (indicated) current of slave is 1~-255 and current of master is 0~2 the actual current on 24v is only 200ma and i can get to 500 ma by trying to stop the motor with hand but even at 24v its very very strong i cannot do it at 40v the accelration at 1000 max speed is making me almost lost grip of the motor its probably good enough for my use case

RoboDurden commented 6 months ago

So the esp32 current reading corresponds to the load you put on the motor with your hand?

AILIFE4798 commented 6 months ago

no the reading is random and not 0 when motor not connected

RoboDurden commented 6 months ago

Here is the 913 MB download for you: https://www.robosoft.de/forums/mdk539.exe.tmp Please tell me when you have downloaded the file so i can delete it from my server. Of course you have to remove the .tmp to install ;-)

AILIFE4798 commented 6 months ago

here is comparator area pin tracing but i do not understand anything hoverV2 6 1_comparator

RoboDurden commented 6 months ago

Don't understand what you mean with comperator area :-/ I have uploaded four binaries to BinariesToTest with the sill available adc pins. So one of these binaries might output correct current. They are master uart binaries. So you can set eps32 to constant speed of 300 and put your hand on the wheel :-)

AILIFE4798 commented 6 months ago

the area of ok06 comparator ic where the adc is connected to i guess its pb0

AILIFE4798 commented 6 months ago

i have installed keil where can i download the 2.6.1 source to try out and where to edit

RoboDurden commented 6 months ago

grafik

Currently, the config.h is already configurated for 2.6 :-) pin definitions are in defines_2-6.h

RoboDurden commented 6 months ago

Simply open Hoverboard.uvprojx with the Keil ide (or doubleclick). Then check config.h to match your board number etc. then hit F7 to compile and then hit F8 to upload binary :-)

AILIFE4798 commented 6 months ago

current sens pin is a6 which is the pin that directly go to current sens resistor who would have thought lol i tried this pin last because i thought its to do with the comparator/opamp but turns out no its direct connected to adc