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
75 stars 25 forks source link

Gen2.1.12 (ex2.14) - PPM and PWM RC remote? #36

Open dexterbot80 opened 8 months ago

dexterbot80 commented 8 months ago

Hello, First of all I want to congratulate you on this project. Very useful for bringing broken hoverboards back to life.... I have two pieces of this model and would like to be able to actuate them simultaneously from an RC remote control to create a 4-motor RC platform. Have you seen this model before? Can someone guide me? Thank you GD32F GD32F130 MASTER SLAVE

RoboDurden commented 7 months ago

As i said, STM cube mostly does not work with gen2.x boards.

Install Keil IDE.

dexterbot80 commented 7 months ago

As i said, STM cube mostly does not work with gen2.x boards.

Install Keil IDE. I installed already- i need to open SRC files like this ? My eyes flassing like hoverboard leds :)

image
RoboDurden commented 7 months ago

Open the Keil project file. I think it is https://github.com/RoboDurden/Hoverboard-Firmware-Hack-Gen2.x/blob/main/HoverBoardGigaDevice/Hoverboard.uvprojx

Then F7 Then F8

dexterbot80 commented 7 months ago

Open the Keil project file. I think it is https://github.com/RoboDurden/Hoverboard-Firmware-Hack-Gen2.x/blob/main/HoverBoardGigaDevice/Hoverboard.uvprojx

Then F7 Then F8

image

Electrical consumption encrease at 0.13Ah and battery yelow led is on :)

WhatsApp Image 2023-11-29 at 20 05 52_771b827a

RoboDurden commented 7 months ago

Looking good, to guess. Make sure your layout 14 is set in config.h

Now trace the three hall pins with a diode tester.

If possible, flash the slave board. Then you can also select remoteUart and check the Esp32 serial connection to that left four pin header. Only connect tx rx and gnd. Also check that you have 3.3v on the MCU. You can measure that at the flash header...

dexterbot80 commented 7 months ago

Looking good, to guess. Make sure your layout 14 is set in config.h

Now trace the three hall pins with a diode tester.

If possible, flash the slave board. Then you can also select remoteUart and check the Esp32 serial connection to that left four pin header. Only connect tx rx and gnd. Also check that you have 3.3v on the MCU. You can measure that at the flash header...

I need to douwnload your updated project and uncomment layout 2_14 here ?

image
RoboDurden commented 7 months ago

define LAYOUT 14

Of course you need my latest changes :-(

dexterbot80 commented 7 months ago

define LAYOUT 14

Of course you need my latest changes :-( okkkk, now the battery led flashes when i rotate the wheel in all 3 colors

RoboDurden commented 7 months ago

All three led show up ? And always two Led overlap ? Then my guess for the hall pins was correct :-)

But then the motor should do something.

RemoteDummy selected in config.h ?

dexterbot80 commented 7 months ago

All three led show up ? And always two Led overlap ? Then my guess for the hall pins was correct :-)

But then the motor should do something.

RemoteDummy selected in config.h ?

https://github.com/RoboDurden/Hoverboard-Firmware-Hack-Gen2.x/assets/47325794/15f57328-bfa3-4054-8ec0-1e83bf5babf6

image

define REMOTE_DUMMY is uncommented

RoboDurden commented 7 months ago

The video made may Show only Red and Green Led. Sure you attached the led module with three led. Ah yes only the slave board has all three transistors for three led on board.

So continue with the slave board = no buzzer.

I still wonder why no motor movement at all...

RoboDurden commented 7 months ago

We may need to verify the 6 MOSFET output pins.

dexterbot80 commented 7 months ago

The wheel

We may need to verify the 6 MOSFET output pins.

Now the wheel does not oppose the resistance like when I uploaded the previous firmware But the led lights up in all three colors when I rotate, Green, Orange and Yellow And yet compared to the other side that does not have the correct firmware loaded, it oppose little resistance

RoboDurden commented 7 months ago

Slave board ?

dexterbot80 commented 7 months ago

Slave board ? This is the slave board Yes - Just on the slave board i have RX TX connector for remote

WhatsApp Image 2023-11-29 at 20 40 43_bd597975

RoboDurden commented 7 months ago

You could check with your oscilloscope if there is some pwm on the three motor phase cables. Which layout did the motor give some constant load while turning by hand ?

RoboDurden commented 7 months ago

Please remove the orange 3.3V line from flash header to flash dongle.

dexterbot80 commented 7 months ago

Please remove the orange 3.3V line from flash header to flash dongle.

You could check with your oscilloscope if there is some pwm on the three motor phase cables. Which layout did the motor give some constant load while turning by hand ?

https://github.com/RoboDurden/Hoverboard-Firmware-Hack-Gen2.x/assets/47325794/60e0dd70-e402-44ea-af4f-54772ae7091f

dexterbot80 commented 7 months ago

Please remove the orange 3.3V line from flash header to flash dongle.

image

ok, i have ths configuration now

RoboDurden commented 7 months ago

Of you see pwm on any of the three phases to gnd then the six MOSFET poms should be correct. If you also see pwm between two phases, the motor must move...

No 3.3v on flash header please

dexterbot80 commented 7 months ago

Of you see pwm on any of the three phases to gnd then the six MOSFET poms should be correct. If you also see pwm between two phases, the motor must move...

No 3.3v on flash header please

I uploaded Layout 10 and motor moves for 2 seconds

RoboDurden commented 7 months ago

Study the differences to defines_2-10.h

RoboDurden commented 7 months ago

Deactivate the two analog inputs. The two pins probably are wrong and the wrong readings disables the motors from spinning. So add // here

// ADC defines
//#define VBATT PA4                 // todo
//#define CURRENT_DC    PA6     // todo
dexterbot80 commented 7 months ago

Deactivate the two analog inputs. The two pins probably are wrong and the wrong readings disables the motors from spinning. So add // here

// ADC defines
//#define VBATT   PA4                 // todo
//#define CURRENT_DC  PA6     // todo

In layout 14 ?

RoboDurden commented 7 months ago

Of course with 14 compiling

dexterbot80 commented 7 months ago

Of course with 14 compiling

If i comment this 2 lines i receive an error when i try to flash

image
RoboDurden commented 7 months ago

When F7 succeeds, the code is not the problem. I need to drive the next 30 minutes to find a nice place for the night.

dexterbot80 commented 7 months ago

When F7 succeeds, the code is not the problem. I need to drive the next 30 minutes to find a nice place for the night.

When F7 succeeds, the code is not the problem. I need to drive the next 30 minutes to find a nice place for the night.

This move is with Layout 10 code compiled But with the layout 10 just the Green led flashes when i rotate by hand

https://github.com/RoboDurden/Hoverboard-Firmware-Hack-Gen2.x/assets/47325794/bc8dba93-266c-4171-bd7c-2cec586e73d0

dexterbot80 commented 7 months ago

When F7 succeeds, the code is not the problem. I need to drive the next 30 minutes to find a nice place for the night. Target not created.

image
RoboDurden commented 7 months ago

Copy the two adc pin definitions from defines_2-10.h

Sorry, I go to sleep.

You can still try remote_uart and get the Esp32 serial working ..

dexterbot80 commented 7 months ago

Copy the two adc pin definitions from defines_2-10.h

Sorry, I go to sleep.

You can still try remote_uart and get the Esp32 serial working .. Good night @RoboDurden , I discovered some settings that make the engine move more :) Also, my boards are equipped with the GD32F130C6 microcontroller and GD323230 was defined in the code. I also discovered here that the battery was defined as 36V - I changed the code lines for 24V (I have a 24V battery)

image
image

Now the motor seriously vibrates when I load Layout 14

RoboDurden commented 7 months ago

The target must be GD32F130C8 for the C6 variation as well. C6 only has 32 kB but code compiles as well.

Battery cells are defined to be 6 which is even less then 24 V

In this line, the code execution is put on hold until the onoff button is released: https://github.com/RoboDurden/Hoverboard-Firmware-Hack-Gen2.x/blob/98d683380cdbe42aa894859dd9e262247d8eeb7d/HoverBoardGigaDevice/Src/main.c#L333

Disabling it here might help you: https://github.com/RoboDurden/Hoverboard-Firmware-Hack-Gen2.x/blob/98d683380cdbe42aa894859dd9e262247d8eeb7d/HoverBoardGigaDevice/Inc/config.h#L48

Motor heavily vibrating is good. But only with the gd32f130 target selected.

Then you simply have to test all six possible pin permutations of

// Hall sensor defines
#define HALL_A  PA0     // robo just guessing !
#define HALL_B  PA1     // robo just guessing !
#define HALL_C  PC14    // robo just guessing !

Acb,bac,cab,cba,bca One of them should get you smooth rotation.

Don't mess with wrong layouts and wrong target !

You should also check that the led colors are correct:

#define LED_GREEN PA15  // robo from photo
#define LED_ORANGE PB3  // robo from photo
#define LED_RED PB4         // robo from photo

Set this to

#define LED_GREEN PA15  // robo from photo
#define LED_ORANGE TODO_PIN // robo from photo
#define LED_RED TODO_PIN            // robo from photo

and check if indeed the green led is still blinking.if red is blinking then set led_red to be pa15, etc. Do that for all three known led pins.

Post your final pin definitions for the three led and the three hall pins here so I can update the defines_2-14.h file.

dexterbot80 commented 7 months ago

Hello @RoboDurden // Hall sensor defines LAYOUT 14

define HALL_A PA1 // 3.3K -> CONNECTOR ->YELLOW WIRE

define HALL_B PB11 // 3.3K -> CONNECTOR ->GREEN WIRE

define HALL_C PC14 // 3.3K -> CONNECTOR ->BLUE WIRE

define LED_RED PA15 // 3.3K -> TRANSISTOR-> 0.1K ->CONNECTOR BLACK WIRE

define LED_GREEN PB3 // 3.3K -> TRANSISTOR-> 0.1K ->CONNECTOR GREEN WIRE

define LED_ORANGE PB4 // 3.3K -> TRANSISTOR-> 0.1K ->CONNECTOR YELLOW WIRE

iN THIS CONNECTOR I HAVE FRONT LEDS - ONE LED ON MASTER BOARD AND ONE ON THE SLAVE BOARD ALTHOUGH THERE ARE 3 PINS IN THE CONNECTOR THE LED CONNECTED HERE ONLY HAVE TWO WIRES THE PIN IN THE MIDDLE OF THE CONNECTOR IS IN THE AIR

define UPPER_LED PB5 //FRONT LED CONNECTOR 1

define LOWER_LED PC13 // THIS PIN IS IN THE AIR

Now I will try to see how to identify the 3 phases

RoboDurden commented 7 months ago

Pb11 ? Then you should have seen only two Led blinking

dexterbot80 commented 7 months ago

Pb11 ? Then you should have seen only two Led blinking

Pb11 ? Then you should have seen only two Led blinking It's true, when I turned the battery LED by hand, it lit up in three colors

Considering that the PC13 pin reaches the middle of the connector where I have the LEDs that light up in front - which pin do I define for #define MOSFET_OUT ???? ​

image
RoboDurden commented 7 months ago

If you are not sure of a pin then set it to TodoPin

dexterbot80 commented 7 months ago

If you are not sure of a pin then set it to TodoPin

I was 90% sure that this is what you will say and I set PF4 I'm making a video so you can see what happens Something is still not right

https://github.com/RoboDurden/Hoverboard-Firmware-Hack-Gen2.x/assets/47325794/0e1eee3b-69c8-4949-8cf8-1363cf3ba701

dexterbot80 commented 7 months ago

I have to learn how to identify the pins of the 6 mosfets and the #define MOSFET_OUT pin

THIS IS WORKING BUT THE SOUND IS NOT VERRY WELL

image

https://github.com/RoboDurden/Hoverboard-Firmware-Hack-Gen2.x/assets/47325794/adc8e2c9-da45-4dfc-98cf-ea62dceb1719

I am not sure if that #define MOSFET_OUT PF4 is the correct one

RoboDurden commented 7 months ago

I don't see anything happening in your video

MOSFET_OUT is just a tiny onboard led

Get the three colors right. And the three hall cables until vibrating turns into smooth spinning.

RoboDurden commented 7 months ago

meine Welt

RoboDurden commented 7 months ago

Check my 2.0 MOSFET tracing jpg.

dexterbot80 commented 7 months ago

Check my 2.0 MOSFET tracing jpg.

https://github.com/RoboDurden/Hoverboard-Firmware-Hack-Gen2.x/assets/47325794/8eda1263-1c45-4dd0-8c71-c13b880f7563

dexterbot80 commented 7 months ago

I don't know if it's ok, the consumption without load is somewhere around 3.5A Here I have no idea if it's good - the mosfets get pretty hot

image

Might different values be needed considering that I have 24V motors?

RoboDurden commented 7 months ago

It should only be 0.7A. Check phase to phase with oscilloscope. Have you tried all six hall permutations ? 24V is okay . I currently drive my solar car with 24v

dexterbot80 commented 7 months ago

It should only be 0.7A. Check phase to phase with oscilloscope. Have you tried all six hall permutations ? 24V is okay . I currently drive my solar car with 24v

Maybe this #define DEAD_TIME 60 is not right but I don't know how to measure it

RoboDurden commented 7 months ago

No layout so far needed such a timing adjustment . Check master board.

dexterbot80 commented 7 months ago

No layout so far needed such a timing adjustment . Check master board.

I agree with you, but I don't think it's ok to heat up the motor and mosfets without load. So I think something needs to be finished here

RoboDurden commented 7 months ago

I do not like to repeat myself . Especially when I'm driving in my Solar car and it is frozen cold

dexterbot80 commented 7 months ago

No layout so far needed such a timing adjustment . Check master board.

https://github.com/RoboDurden/Hoverboard-Firmware-Hack-Gen2.x/assets/47325794/6e99c596-3fcd-4269-81c2-befab8b34228

I have now uploaded the firmware to the master board and you can hear how it sounds. Maybe I'm doing something wrong here, but I don't know what - I have another hoverboard exactly like this one and with the original firmware, you can barely hear it when it was working. I will keep trying until I get the hang of it :) Thank you @RoboDurden

RoboDurden commented 7 months ago

Awful noise. Have you tested all six hall permutations ????????????

Have you verified that all three phase to phase oscilloscope readings look alike ????

Maybe the hall sensor positions inside the motor are non standard and indeed another timing is needed for these bldc motors. But we have already tested dozens of different hoverboard motors.

I will need to rewrite the ADC pin code to disable curreentDc ADC. Wrong readings might kill the timing.

You can also try all six phase cable permutations! Should be the same as swapping the hall cables. But with non standard hall sensor positions, this might be good to test.

Now recharging 1 kWh for the 55 km trip today at a free E-Bike charging station.