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.4 (ex2.3) #20

Open mateuszfcg opened 9 months ago

mateuszfcg commented 9 months ago

Hello. Has anyone run the disc version 2.3? At first I had a problem with uploading any batch, but I managed to do it for a while. now I have trouble starting it. when I connect the power supply, the engine only starts slightly and holds it in one position. I cannot establish communication with Arduino. I tried on different GD pins. please help. Does anyone have the file already configured for this disc? Regards

RoboDurden commented 9 months ago

This is a bad translation engine, surely not Google ?

I guess it was me who did add the 2.3 layout so i might have such a board laying aorund somewhere here. But no-one yet has begun with a defines-2_3.h file. If you start tracing the 3 hall sensor and 6 mosfet pins, i will support you. If i find my 2.3 boards i might build just another test setup. But you should do some work yourself first.

DerPinguin77 commented 9 months ago

Hi im new here but i also have one of these Hoverboards. I would love to help with finding tracing those hall sensor and mosfet pins. But im fairly inexperienced so i cant really help with programming. I have flashed one Hoverboard before but it had the more common single motherboards. I also have some other questions: Are there plans in integrating something like a PWM control and would it be possible to integrate in the version for this board? Can u use both boards standalone by just flashing both boards with the Master version?

RoboDurden commented 9 months ago

If you have a new layout, please post some hi-res photos here. I might be happy to finally program an pin-auto-detect firmware that creates a new defines_2-xy.h file. No, i will not add further control methods beside the existing uart. But i am currently working on an i2c control for our new simpleFOC firmware: https://github.com/Candas1/Split_Hoverboard_SimpleFOC/issues/11 When this is ready, people might add new Pilot classes..

Yes, slave board can be flashed with the master firmware. But it needs the CHECK_BUTTON define to be disabled whenthe slave board ist dircetly powered and has no on button:

#define CHECK_BUTTON // disable = add '//' if you use a slave board as master

DerPinguin77 commented 9 months ago

Im currently working on the pinout. Sadly the firmware woult be pretty useless to me without eiter ADC or PWM control. I dont know much about Github so i will post my results here when im done.

RoboDurden commented 9 months ago

ADC would not be a big problem. If one of the two uart rx/tx pins can work as an anlaog input (like the long cable of the gen1 board), the reading the adc value and turn it into +-1000 will only take a few lines.

PWM would need some few timing calculations to translate the high/low times to a pwm ratio..

If your board is not the layout 2.3 that this issue is dedicated to, please create your own issue and attach high res photos there so i can assign a new layout number. You can attach high-res fotos to this issue and i will

DerPinguin77 commented 9 months ago

My board has the Layout 2.3. I used your original photo and drew in the connections I tested. Hope this is enough. If not please tell me what you need and i will try to find the connections. It would be cool if you could add the few lines you need for ADC control because I dont have the knowlege to do that. Schaltplan

RoboDurden commented 9 months ago

Would be nice if you could uplad an aligned fornt/back image like 2.7 front-back Then some led pins etc can be traced on the photo.

mateuszfcg commented 9 months ago
#ifdef SLAVE    // this layout has buzzer on the slave board !
    #define BUZZER
#endif

#define TODO_PORT GPIOA             // this should be a pin that does no harm if input or output
#define TODO_PIN    GPIO_PIN_15 // B15 is not accessibla on the smaller QFN32 32 pin MCU version

#define DEBUG_LED_PIN   GPIO_PIN_1  // lerwinDE: blue led panel
#define DEBUG_LED_PORT  GPIOF               // lerwinDE: blue led panel

// LED defines
#define LED_GREEN           TODO_PIN    // lerwinDE: GPIO_PIN_14 - in conflict with flash pins DIO and CLK !!!
#define LED_GREEN_PORT  TODO_PORT   // lerwinDE: GPIOA
#define LED_ORANGE          TODO_PIN    // TODO
#define LED_ORANGE_PORT TODO_PORT   // TODO
#define LED_RED                 TODO_PIN        // lerwinDE: GPIO_PIN_13 - in conflict with flash pins DIO and CLK !!!
#define LED_RED_PORT        TODO_PORT       // lerwinDE: GPIOA

#define UPPER_LED_PIN   TODO_PIN    // TODO
#define UPPER_LED_PORT  TODO_PORT   // TODO
#define LOWER_LED_PIN   TODO_PIN    // TODO
#define LOWER_LED_PORT  TODO_PORT   // TODO

// Mosfet output
// seems to be an ordinary LED output ?
// led.c:91 gpio_bit_write(MOSFET_OUT_PORT, MOSFET_OUT_PIN, counter_Blue >= setValue_Blue ? RESET : SET); 
#define MOSFET_OUT_PIN TODO_PIN     // TODO
#define MOSFET_OUT_PORT TODO_PORT   // TODO

// Brushless Control DC (BLDC) defines
#define TIMER_BLDC_PULLUP   GPIO_PUPD_PULLUP    // robo, based on Herleybob:defines.h
// Channel G
#define RCU_TIMER_BLDC RCU_TIMER0
#define TIMER_BLDC TIMER0
#define TIMER_BLDC_CHANNEL_G TIMER_CH_2
#define TIMER_BLDC_GH_PIN GPIO_PIN_8        // GPIO_PIN_8   robo, based on Herleybob:defines.h
#define TIMER_BLDC_GH_PORT GPIOA                // GPIOA robo, based on Herleybob:defines.h
#define TIMER_BLDC_GL_PIN GPIO_PIN_13       // robo, based on Herleybob:defines.h
#define TIMER_BLDC_GL_PORT GPIOB                // robo, based on Herleybob:defines.h
// Channel B
#define TIMER_BLDC_CHANNEL_B TIMER_CH_1
#define TIMER_BLDC_BH_PIN GPIO_PIN_9        // robo, based on Herleybob:defines.h
#define TIMER_BLDC_BH_PORT GPIOA                // robo, based on Herleybob:defines.h
#define TIMER_BLDC_BL_PIN GPIO_PIN_14       // robo, based on Herleybob:defines.h
#define TIMER_BLDC_BL_PORT GPIOB                // robo, based on Herleybob:defines.h
// Channel Y
#define TIMER_BLDC_CHANNEL_Y TIMER_CH_0
#define TIMER_BLDC_YH_PIN GPIO_PIN_10       // robo, based on Herleybob:defines.h
#define TIMER_BLDC_YH_PORT GPIOA                // robo, based on Herleybob:defines.h
#define TIMER_BLDC_YL_PIN GPIO_PIN_15       // robo, based on Herleybob:defines.h
#define TIMER_BLDC_YL_PORT GPIOB                // robo, based on Herleybob:defines.h

// Timer BLDC short circuit emergency shutoff define
// Is initialized here but never used somewhere else in code.
// setup.c:176  gpio_mode_set(TIMER_BLDC_EMERGENCY_SHUTDOWN_PORT , GPIO_MODE_AF, GPIO_PUPD_NONE, TIMER_BLDC_EMERGENCY_SHUTDOWN_PIN);  
#define TIMER_BLDC_EMERGENCY_SHUTDOWN_PIN TODO_PIN  // TODO
#define TIMER_BLDC_EMERGENCY_SHUTDOWN_PORT TODO_PORT        // TODO

// Hall sensor defines
#define HALL_A_PIN GPIO_PIN_1   // robo, based on Herleybob:defines.h A = U ?
#define HALL_A_PORT GPIOA               // robo, based on Herleybob:defines.h A =  U ?
#define HALL_B_PIN GPIO_PIN_2   // robo, based on Herleybob:defines.h B = V ?
#define HALL_B_PORT GPIOA               // robo, based on Herleybob:defines.h B = V ?
#define HALL_C_PIN GPIO_PIN_0       // robo, based on Herleybob:defines.h C = W ?
#define HALL_C_PORT GPIOA               // robo, based on Herleybob:defines.h C = W ?

// Usart master slave defines
#define USART_MASTERSLAVE USART1    // robo no second uart port yet.
#ifdef USART_MASTERSLAVE
    #define USART_MASTERSLAVE_TX_PIN GPIO_PIN_6     // lerwinDE :-)
    #define USART_MASTERSLAVE_TX_PORT GPIOB             // lerwinDE :-)
    #define USART_MASTERSLAVE_RX_PIN GPIO_PIN_7 // lerwinDE :-)
    #define USART_MASTERSLAVE_RX_PORT  GPIOB                // lerwinDE :-)
#endif

// ADC defines
//#define VBATT_PIN GPIO_PIN_0              // robo, no gpio_mode_set() inHerleybob:setup.c
#define VBATT_PORT GPIOA                        // robo, no gpio_mode_set() inHerleybob:setup.c
#define VBATT_CHANNEL ADC_CHANNEL_17    // robo, based on Herleybob:setup.c: adc_regular_channel_config(2,ADC_CHANNEL_17,ADC_SAMPLETIME_13POINT5);
//#define CURRENT_DC_PIN    GPIO_PIN_1  // robo, no gpio_mode_set() inHerleybob:setup.c
#define CURRENT_DC_PORT GPIOA               // robo, no gpio_mode_set() inHerleybob:setup.c
#define CURRENT_DC_CHANNEL ADC_CHANNEL_2    // robo, maybe adc_buf_t:adc is potentiometer input

// Self hold defines
// important pin keeps the mosfet open after the on/off button got pushed !
// main.c:306: gpio_bit_write(SELF_HOLD_PORT, SELF_HOLD_PIN, SET); 
// and turns off power on Shutdown:
// main.c:513:   gpio_bit_write(SELF_HOLD_PORT, SELF_HOLD_PIN, RESET); 
#define SELF_HOLD_PIN GPIO_PIN_13       // lerwinDE: master: A11 is used a hold bin, slave: A11 is buzzer pini
#define SELF_HOLD_PORT GPIOA                // TODO

// Button defines
// on/off (POW) push-button. So also a connection (i guess with some smd resistor in between) to a MCU pin.
// main.c:457: if (gpio_input_bit_get(BUTTON_PORT, BUTTON_PIN)) 
#define BUTTON_PIN GPIO_PIN_2           // robo, based on Herleybob:defines.h
#define BUTTON_PORT GPIOB                       // robo, based on Herleybob:defines.h

// Usart steer defines
#define USART_STEER_COM USART0                  
#define USART_STEER_RCU RCU_USART0          
#define USART_STEER_AF  GPIO_AF_0               
#define USART_STEER_COM_TX_PIN GPIO_PIN_11      // lerwinDE :-) 11
#define USART_STEER_COM_TX_PORT GPIOB               // lerwinDE :-)
#define USART_STEER_COM_RX_PIN GPIO_PIN_10  // lerwinDE :-) 10
#define USART_STEER_COM_RX_PORT GPIOB               // lerwinDE :-)

//#ifdef BUZZER
    // Buzzer defines
    #define BUZZER_PIN GPIO_PIN_11      // robo, based on Herleybob:defines.h
    #define BUZZER_PORT GPIOA               // robo, based on Herleybob:defines.h
//#endif

#ifdef MASTER

    // Charge state defines
    // This seems to be a digital input that hast to be high in order to enable the motors. 
    // main.c:381: chargeStateLowActive = gpio_input_bit_get(CHARGE_STATE_PORT, CHARGE_STATE_PIN);
    // If not found it should be okay to simply comment this line because chargeStateLowActive in initialised as set = true
    #define CHARGE_STATE_PIN GPIO_PIN_0     // TODO
    #define CHARGE_STATE_PORT GPIOF             // TODO
#endif

// Debug pin defines - seems to be never used in code.
#define DEBUG_PIN TODO_PIN  // TODO
#define DEBUG_PORT TODO_PORT            // TODO`

Above is the code of my configuration but not everything is ok -UART does not work -Motor does not run stably (sound like skipping steps in a stepper motor but it is rotating) mosfets are heating up -Starting the board requires a jumper all the time -buzzer works as soon as I change to SLAVE in config

any ideas ?

Sorry for the translation but I have a hard time with languages :)

RoboDurden commented 9 months ago

Always use a CC constant current power supply with max 2A when testing new boards !!!!!!!!!

mateuszfcg commented 9 months ago

I powered it initially via inverters to limit the current.

DerPinguin77 commented 9 months ago

These are the best images i could get in the dark. I acidentally photographed the Slave board and i forgot to remove the sticker on the back. If its not good enoungh i can try again tomorrow FrontBack

RoboDurden commented 9 months ago

Thank you. I mirrored the backside vertically and added it to the 2.3 folder. The 5 led pins should be no problem: 5 transistors for 5 leds

21:15 here in Germany, i go to bed.

RoboDurden commented 9 months ago

@DerPinguin77 i do not see a seconde uart header on this layout :-/ The primary uart header normally is needed to connect master with slave. Without at least one additional input pin for speed, you would need an additional Arduino or Esp anyway to calculate speedL and speedR and send them via the only UART to the two boards.

In the bottom left i see a 4 pin header with GND | DATA | 5V. But on the photo i see that the two DATA pins are connected. So at best one input pin.

The 4 pin header to the top right i guess is the charging connector ? The 2 pin header to the right is the on/off button ? With the slave, this header would not have any function as it is powered directly over the uart cable ? Then the slave board might have that DATA pin and the BUTTON pin to receive speed and steer data.

I stick to my understanding that adding a cheap ESP S2 Mini with bluetooth and wlan is always the better choice.

RoboDurden commented 9 months ago

@mateuszfcg i have added your defines_2-3.h to my repo and updated the defines.h and config.h. If you want to make changes to the code (main.c , setup.c , bldc.c , etc.), please fork this repo by clicking on grafik Then you can make change to your own copy of this repo and start a "pull request" so i can incooperate your changes with a single click :-)

@DerPinguin77 if you have a constant current power supply it would be great if you start testing the new defines_2-3.h

I will check the defines later this day if they confirm with your drawing.

P.S. the two photo sensors (light barriers) on the backside could be used as digital inputs. The last board i tested allowed one input to be used as analog input.

RoboDurden commented 9 months ago

okay i updated https://github.com/RoboDurden/Hoverboard-Firmware-Hack-Gen2.x/blob/main/HoverBoardGigaDevice/Inc/defines_2-3.h

Am not sure if the ordering is right:

// Hall sensor defines
// mateuszfcg tested with PA1,PA2,PA0 
#define HALL_A_PIN  GPIO_PIN_1
#define HALL_A_PORT GPIOA
#define HALL_B_PIN  GPIO_PIN_2
#define HALL_B_PORT GPIOA
#define HALL_C_PIN  GPIO_PIN_0
#define HALL_C_PORT GPIOA

I added the led pins by looking on the photo:

// LED defines, colors probably mismatch !
#define LED_GREEN           GPIO_PIN_15
#define LED_GREEN_PORT  GPIOA
#define LED_ORANGE          GPIO_PIN_14
#define LED_ORANGE_PORT GPIOA
#define LED_RED                 GPIO_PIN_3
#define LED_RED_PORT        GPIOB

#define UPPER_LED_PIN   GPIO_PIN_4
#define UPPER_LED_PORT  GPIOB
#define LOWER_LED_PIN   GPIO_PIN_5
#define LOWER_LED_PORT  GPIOB

#define DEBUG_LED_PIN   LED_RED
#define DEBUG_LED_PORT  LED_RED_PORT

I disabled both uart ports.

//#define USART_MASTERSLAVE USART1  // robo no second uart port yet.
//#define USART_STEER_COM USART0                    

Please someone check the rx tx pins of the white uart header below the GD32 MCU :-)

DerPinguin77 commented 9 months ago

Hi, came home from work just now. I think it would not be a problem if each of those boards only had one free input pin. It isnt as nice but you could just use the one pin of each board to control the motor connected to it. I can understand that for robotic projects the esp uart thing is much more practical, but I would prefer to use the board standalone without any extra stuff, cause I just need basic speed control. I can start testing later this day but it could take a while until i figure out how to flash and compile all of this. Do i need the esp for testing or is there some kind of test mode? I will continue to test the header you have asked for and i will also test the pins od the infrared gates. Also i have another question. Will there be a way to calibrate the end points of the adc? On the other firmware i have used, you could press the powerbutton for a long time and you would enter calibration mode. There you could move the pot to the max and min positions. I am also from Germany btw. :)

RoboDurden commented 9 months ago

This nice guy just today added rc remote control which i will implement tomorrow: https://github.com/RoboDurden/Hoverboard-Firmware-Hack-Gen2.x/pull/24

Then there will already be two different control methods. So adding adc now looks appealing to me. Adding calibration would just mean some 10 lines of code..

Indeed you are correct, if we only have one input pin per board, the slave could transmit the steer value to the master, the master calculates the speedL and speedR and send the speedR back to the slave :-)

Be sure to use a 2A cc power supply (or a dc dc step down or up converter with cc).

DerPinguin77 commented 9 months ago

Hi i probed all the other mentioned pins now. Here is the updated picture:

Schaltplan

Also the steering feature is not really impotant to me. I just need to be able to control the different motors speeds seperately, so they dont even have to be connected via uart. The ELRS feature is definetly very interesting. For compiling i need this right? https://www.keil.com/demo/eval/arm.htm#/DOWNLOAD I am relatively new to all this compiling stuff so i dont really know what to do to get the bin file i can flash

RoboDurden commented 9 months ago

yes i think that is the correct download. You may also need st-link-utility to unlock the MCU. It looks like the red DATA pin is either pulled to 3.3V or GND. Then it is not that useful for adc Any idea what the yellow pin you added is for ? Might be analog read of battery voltage. To later also make use of the coming SimpleFOC firmware, you also need the two adc outputs of this dual op-amp:

grafik

DerPinguin77 commented 9 months ago

The yellow wire is the pin of the second Infrared thingy. I think it would be possible to remove the resistor that pulls the red pin high. I will test the pins of the opamp later/tomorrow Right now i am trying to get the firmware running on one of my boards. Is it possible to directly flash the firmware with the keil software?

RoboDurden commented 9 months ago

yes, but i am not sure if Keil will be able to unlock the MCU. Watch my youtube tutorial for that firmware. If you only want to control one motor with a potentiometer, one of the uart pins might do. But please confirm the

    #define USART_MASTERSLAVE_TX_PIN    GPIO_PIN_6
    #define USART_MASTERSLAVE_TX_PORT   GPIOB
    #define USART_MASTERSLAVE_RX_PIN    GPIO_PIN_7
    #define USART_MASTERSLAVE_RX_PORT   GPIOB

Then i will look in the MCU user manual to see if one of these pins can also do adc.

mateuszfcg commented 9 months ago

@DerPinguin77 1. unlock the GD32 via ST-LINK Utility (this will remove the preloaded firmware)

  1. Start keil and upload the firmware directly from keil. If you don't want to load (e.g. "no target conection" message pops up) you have to short NRST pin to GND and after approx. 1sec after pressing DOWNLOAD let go. The second option instead of manually connecting to GND is to add a transistor to ST-LINK to the RST pin. Resistor R72 closer to the white connector. Good luck

And getting back to the topic of the UART the white connector is: TX=PB6 RX=PB7

So far I have established a connection to the Arduino with these pins.

I still have a problem with VBat and IAMP. No matter what voltage I put on the power supply it is still Iamp=0.42, IVolt 36.0 in the serial monitor.

Another issue is the hold up when a button is pressed. The button is definitely on PB2

@RoboDurden image are not ADC pins

RoboDurden commented 9 months ago

Thanks, so no adc on these pins.

So you use

    #define USART_STEER_COM_TX_PIN  GPIO_PIN_6
    #define USART_STEER_COM_TX_PORT GPIOB
    #define USART_STEER_COM_RX_PIN  GPIO_PIN_7
    #define USART_STEER_COM_RX_PORT GPIOB

and #define USART_STEER_RCU RCU_USART0 i guess.

RoboDurden commented 9 months ago

0.42 is because of bldc.c :

// Calculate current DC
    #ifdef CURRENT_DC_PIN
        currentDC = ABS((adc_buffer.current_dc - offsetdc) * MOTOR_AMP_CONV_DC_AMP);
    #else
        currentDC = 0.42;   // testing with no CURRENT_DC_PIN yet
    #endif
RoboDurden commented 9 months ago

36V also set in bldc.c

    // Calculate battery voltage every 100 cycles
    #ifdef VBATT_PIN
        if (buzzerTimer % 100 == 0)
            batteryVoltage = batteryVoltage * 0.999 + ((float)adc_buffer.v_batt * ADC_BATTERY_VOLT) * 0.001;
    #else
        batteryVoltage = BAT_CELLS * 3.6;       // testing with no VBATT_PIN yet
    #endif
RoboDurden commented 9 months ago

If you indeed have serial connection between arduino and hoverboard please post your new values of:

// Usart steer defines
//#define USART_STEER_COM USART0                    
#ifdef USART_STEER_COM
    #define USART_STEER_RCU RCU_USART0          
    #define USART_STEER_AF  GPIO_AF_0               
    #define USART_STEER_COM_TX_PIN  GPIO_PIN_11
    #define USART_STEER_COM_TX_PORT GPIOB
    #define USART_STEER_COM_RX_PIN  GPIO_PIN_10
    #define USART_STEER_COM_RX_PORT GPIOB
#endif
mateuszfcg commented 9 months ago

defines_2-3.h

// Usart steer defines
#define USART_STEER_COM USART0                  
#ifdef USART_STEER_COM
    #define USART_STEER_RCU RCU_USART0          
    #define USART_STEER_AF  GPIO_AF_0               
    #define USART_STEER_COM_TX_PIN  GPIO_PIN_6//11
    #define USART_STEER_COM_TX_PORT GPIOB
    #define USART_STEER_COM_RX_PIN  GPIO_PIN_7//10
    #define USART_STEER_COM_RX_PORT GPIOB
#endif

commsStering.c

#ifdef MASTER
#define USART_STEER_TX_BYTES 2   // Transmit byte count including start '/' and stop character '\n'
#define USART_STEER_RX_BYTES 7   // Receive byte count including start '/' and stop character '\n'
...

However, I would like to know the current and voltage reading of the current

RoboDurden commented 9 months ago

Then you need to find the correct adc pins:

// ADC defines
//#define VBATT_PIN GPIO_PIN_0
#define VBATT_PORT GPIOA            
#define VBATT_CHANNEL ADC_CHANNEL_17
//#define CURRENT_DC_PIN    GPIO_PIN_1  
#define CURRENT_DC_PORT GPIOA       
#define CURRENT_DC_CHANNEL ADC_CHANNEL_2    
RoboDurden commented 9 months ago

Why did you uncomment

//#define USART_STEER_TX_BYTES 2 // Transmit byte count including start '/' and stop character '\n'

it is no longer used in my code.

mateuszfcg commented 9 months ago
// ADC defines
//#define VBATT_PIN GPIO_PIN_0              // robo, no gpio_mode_set() inHerleybob:setup.c 17 A
#define VBATT_PORT GPIOA                            // robo, no gpio_mode_set() inHerleybob:setup.c
#define VBATT_CHANNEL ADC_CHANNEL_17    // robo, based on Herleybob:setup.c: adc_regular_channel_config(2,ADC_CHANNEL_17,ADC_SAMPLETIME_13POINT5);
//#define CURRENT_DC_PIN    GPIO_PIN_1  // robo, no gpio_mode_set() inHerleybob:setup.c
#define CURRENT_DC_PORT GPIOA                   // robo, no gpio_mode_set() inHerleybob:setup.c
#define CURRENT_DC_CHANNEL ADC_CHANNEL_2    // robo, maybe adc_buf_t:adc is potentiometer input

I have tried all the ADC pins and there are still no readings

RoboDurden commented 9 months ago

You need to surround multi line code with ```

As long as you do not remove the // bevor the pin defines, firmware will not make use of them.

//#define VBATT_PIN GPIO_PIN_0 -> #define VBATT_PIN GPIO_PIN_0

mateuszfcg commented 9 months ago

Dlaczego odkomentowałeś

//#define USART_STEER_TX_BYTES 2 // Transmit byte count including start '/' and stop character '\n'

nie jest już używany w moim kodzie.

communication with the arduino without it did not work at all

RoboDurden commented 9 months ago

please repeat your test and put the // again before #define USART_STEER_TX_BYTES 2 I guess you have made multiple changes at the same time..

mateuszfcg commented 9 months ago

ok you are right. it works after uncommenting the above line

RoboDurden commented 9 months ago

grafik

// photo diodes / light barriers on the backside
#define PHOTO_L_PIN     GPIO_PIN_15
#define PHOTO_L_PORT    GPIOC
#define PHOTO_R_PIN     GPIO_PIN_14
#define PHOTO_R_PORT    GPIOC

So the photo sensors on the backside seem to be digital io only.

RoboDurden commented 9 months ago

Same goes for the DATA pin to the bottom right:

grafik

DerPinguin77 commented 9 months ago

Hi, I got the Firmware flashed and the motor ran pretty well. Sadly my battery wasnt charged up so i couldnt get to full speed until the bms switched it off. My cc powersupply cant supply enough current. I put my battery on the charger and i will test again tomorrow after work. The only issue i had was with the power latch. The mainboard would instantly turn off if if released the powerbutton so i had to hold it. Idk if this was intended or if youre supposed to install a switch instead of the original pushbutton.

DerPinguin77 commented 9 months ago

@RoboDurden So all of the pins I tested wont work for adc? Maybe u could use the pins currently used for the uart. And some of the digital pins for the uart. Or it could be an option in the software so you could comment out and choose between uart and ADC Or are there any other unused analog pins of the chip that could be used? Maybe the led pins on the 3 pin header?

mateuszfcg commented 9 months ago

Tomorrow I will check what pins can be used and let you know. For now, good night because it's late.

RoboDurden commented 9 months ago

no, the uart pins are also digital only. the led pins are driven by a smd transistor, so not available for adc. Beware of the 15V on the led header, they will kill the MCU.

You can find the adc capable pins in GD32F130xxDatasheetRev3.7.pdf . Simply search for adc_ The Hall sensor can do adc :-/

Would be nice if you could check all possible adc pins. The two adc inputs of the dual-opamp must be two of them. Same goes for the yet missing VBAT pin and the DC_CURRENT pin.

If you have identified these 4 adc pins, then maybe you also have found a free adc pin to be used for a potentiometer.

But again i want to suggest that you should think bigger and go for an ESP32 S2 Mini.

RoboDurden commented 9 months ago

If the power gets off wenn releasing the onoff button, this pin definition is wrong:

#define SELF_HOLD_PIN       GPIO_PIN_13
#define SELF_HOLD_PORT  GPIOA       

This HOLD pin should go to a big mossfet to the lower right..

RoboDurden commented 9 months ago

2A should be well enough to spin the motor freely. If more current is drawn (and the mosfet get hot), there might be something wrong with the 6 mosfet pin definition or the 3 hall pins !

RoboDurden commented 9 months ago

@mateuszfcg if you are from Poland, you are 1 hour ahead of us ? Here in Bavaria it is 22:38 and i also turn off the lights :-)

DerPinguin77 commented 9 months ago

@RoboDurden Tried spinning the motor again right now with a full battery. The motor span up pretty fast. It was so fast that the tire started warping, so i removed it. After a frew seconds at full speed it span back down. After that the fuse of my battery blew up(10A) while the motor wasnt spinning. Idk of this is an issue with the mosfet or hall pins but i will try to test all of them again. I will also try to test the other pins you have mentioned. Do u know what this opamp is for? I can see two of them on the board. The button pin/ power latch should not be hard so find so i will begin with that. With the current and voltage pins i dont really have an know were to begin but i will try.

mateuszfcg commented 9 months ago

@DerPinguin77 The double operational amplifier is certainly from the current, from the voltage may also be although it is rather done on the voltage divider. By the hour I also sit down further to look for pins.

DerPinguin77 commented 9 months ago

These are the new pins i tested: Schaltplan Hope this is enough if i should test morte please tell me

RoboDurden commented 9 months ago

Today i have published the first running I2c-SimpleFoc firmware and impelemented the new EspressLRS support (CRSF decoder) method that @WizzardDr contributed so i am done for today:

NOW rc EspressLRS support (CRSF decoder) !!! https://github.com/RoboDurden/Hoverboard-Firmware-Hack-Gen2.x/issues/26

One dual opamp for sure is to measure two low-side currents of two phases. This is needed for the FOC. Not needed for this simple bldc.c here.

DerPinguin77 commented 9 months ago

Will the FOC also work with this board? I also continuewd to test arount the hall sensors. Myabe this hepls to fix the poroblem with me motor. Btw. I didnt habe problems with the motor skipping. Cant say anithing about the mosfet temp because i only hat it on for a few secs. This is the again updated version: Schaltplan

RoboDurden commented 9 months ago

Would be nice if you only update jpg files and not png files. Yes your board has an GD32F130C8 and not C6 (which only has 32 kb Flash). You would have to add the defines_2.3.h in the arduino format like the others. But that SimpleFOC firmware is way more complex and you should be sure that the hall/mosfet pins are correct.

DerPinguin77 commented 9 months ago

I think the hall pins are correct because the motor ran smoothly in my case. I have tested them again and couldnt find any errors but I also dont 100 percent understand what im doing there so there might be something wrong. The only poblem i had was that the motor wouldnt start spinning again and the fuse blew after the first time of cycling between min and max speed(I think this happend when it wanted to go in reverse)

I can also test the connections of the mosfet driver again. Maybe the "error" is there. The only thing i dind't test for today is the voltage sens pin. I couldnt really locate the voltage divider you talked about so i dont really know where to start. Maybe i acidentally found it with the 3 traces i tested for the power latch pin.

Would be cool if the FOC firmware would run on the board somtime in the future. Im doing my best to help with finding all the pins.

I will use the jpg fomat from now on.