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

Open mateuszfcg opened 10 months ago

mateuszfcg commented 10 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

mateuszfcg commented 10 months ago

Musisz otoczyć kod wieloliniowy znak ```

Dopóki nie usuniesz // oprogramowania pinów, oprogramowanie sprzętowe nie będzie z nich korzystać.

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

what are the digital pins used for when reading? I have no idea where to look for them

and regarding the ADC, I am starting to see what can be changed to get at least one ADC pin

DerPinguin77 commented 10 months ago

Mofet pins are also correct in the drawing. Tested them again right now

DerPinguin77 commented 10 months ago

@mateuszfcg Thanks for helping with that. Im done for today but tomorrow i could look up some ADC pins in the datasheet and see if they are unused on the board.

mateuszfcg commented 10 months ago

image

I Hall sensor pins are connected to the ADC. I suggest you solder the resistors 1.R75,R76 or 2.R74,R77 or 3.R73,R78 and connect one of the Hall sensors e.g. to the DATA plug via resistors.

II use of an external ADC transducer via i2C. I2C can be run on the LED pins except that resistors and transistors must be removed from the board.

All LED pins are I/O.

RoboDurden commented 10 months ago

I would not solder anything on the board. I will never accept code to this repo that needs hardware modifications. An ESP32 S2 Mini does not really cost more then an I2C ADC module: https://en.aliexpress.com/item/1005004506970676.html

DerPinguin77 commented 10 months ago

Your Link is broken somehow. Can u also use a normal esp32? Would have been nice if it was all self contained in the board but if there arent any free pins the esp will work to. Just need to learn how all of this uart stuff works

mateuszfcg commented 10 months ago

ESP is the best solution in my opinion.

mateuszfcg commented 10 months ago

@DerPinguin77 Will you send a video of how your engine works ? Maybe in my case there is something damaged in the driver mosfet because I am concerned about the operation of the BLDC motor

RoboDurden commented 10 months ago

Simply search aliexpress for esp32 s2 mini. But any ESP32 module works. The double headers of the ESP32 S2 Mini are no problem with the usual Prototype Boards

DerPinguin77 commented 10 months ago

@mateuszfcg I can send a video but i cant let it run for long or my fuse will blow. One moment

DerPinguin77 commented 10 months ago

Her is a short video of the motor running. The sudden stop isa when i released the power button and it turned off. It cant get to full speed without blowing the fuse so the porblem should be something else.

https://github.com/RoboDurden/Hoverboard-Firmware-Hack-Gen2.x/assets/145379857/2e0a0dc3-8b78-4b5b-b365-31301689fbab

mateuszfcg commented 10 months ago

I was more concerned with the low speed. In my case nothing is burning just the performance characteristics are unsatisfactory to me and I have a little concern that something is wrong with the driving of the mosfets though. I'll post my pin configuration tomorrow because I'm already going to bed, but it's strange that you're burning a fuse.

Regarding the video, those sounds are already vibrations through the high speed. Notice the sound at low speed kind of hard

mateuszfcg commented 10 months ago

I'll upload the video in a bit because I can't add it from my phone

https://youtube.com/shorts/aTL90epVnB4?si=FywE6WOq6ywhkZUI

RoboDurden commented 10 months ago

This board has a mosfet driver chip. The 2.0 layout has analog mosfet drivers made of three little smd transistors. It might be that this mosfet driver chip needs a different deadtime when turning off the high side and turning on the low side. Or some other adjustment of https://github.com/RoboDurden/Hoverboard-Firmware-Hack-Gen2.x/blob/2e3e2dbd8994b9281278be360cb46f0302034b13/HoverBoardGigaDevice/Src/setup.c#L255 I have no experience with bldc mosfet driver chips. Maybe @robcazzaro has an idea.

robcazzaro commented 10 months ago

@RoboDurden, sorry but I have no experience with high power mosfet drivers. If you have a datasheet, we can check if it needs a different signal polarity for the H and L phase, or a different deadtime.

RoboDurden commented 10 months ago

Thanks robcazzaro (=Rob ?). I remember that you were the first to notice that the low side mosfets need inverted signals. From the pdf i think that this also applies to this driver chip: grafik I have only found the Chinese datasheet: https://www.fortiortech.com/public/upload/files/20200715/20e40353f0c9715259019ff1d7ce0e54.pdf Here the google translation: https://github.com/RoboDurden/Hoverboard-Firmware-Hack-Gen2.x/blob/main/Schematics_2.3/FD6287T%20bldc%206x%20gate%20driver.zh-CN.en.pdf

I think the motors are spinning way too fast in the two videos attached/linked here. I only remember too fast rotating when the phase cables have the wrong ordering. But here the motors speed up very smoothly, so i think the phase/hall ordering is correct. Problem ist that the phase colors at the mosfets is yellow,blue,green. But with the hall cables it is yellow,green,blue. A bit confusing. But the hall pin definitions of @mateuszfcg i think compensate for that:

// 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

That is why start to think about some different pwm init parameters.. Mosfets are told to get hot !

@mateuszfcg , @DerPinguin77 in the serial feedback sent to the Arduino, there is also the speed and i think it is rpm. These hoverboard motors have a KV of about 14 rpm/V. When you change the test speed in the new remoteDummy.c to

speed = 20 * (ABS(( ((int32_t)msTicks/3+100) % 400) - 200) - 100);

The following clamp will clamp the +-2000 sine to +-1000 and you get a constant reading of the max speed in rpm. Please post that value with the voltage of your 2A constant current power supply here. With no load, one motor should reach max speed at +1000 with not more than 2A !!

Also test if this latest change in bldc.c is responsible for your high speed problems:

void SetPWM(int16_t setPwm)
{
    //  bldc_inputFilterPwm = CLAMP(setPwm, -1000, 1000);   // thanks to WizzardDr, bldc.c: pwm_res = 72000000 / 2 / PWM_FREQ; == 2250 and not 2000
    bldc_inputFilterPwm = CLAMP(1.125*setPwm, -1125, 1125);
}

Go back to

void SetPWM(int16_t setPwm)
{
    bldc_inputFilterPwm = CLAMP(setPwm, -1000, 1000);   
}
DerPinguin77 commented 10 months ago

I will try the two options you mentioned in your message. But so far i havent even connected an esp to the board. TO be honest i dont really know where to connect it. To the four pins that connect the board? Or are there other pins to connect to?

RoboDurden commented 10 months ago

Only connect GND, TX -> RX and RX to TX. If you already have some ESP or Arduino lying around, tell me the model, then i can guide you :-)

DerPinguin77 commented 10 months ago

I have some ESP 32s and esp 8266s laying around. Would be nice if you helped me with that. Where are the RX and TX pins of the Hoverboard mainboard. But i encountered antoher problem. I have been using an STM nucleo as an ST link so far. But today it just refused to connect to the chip. I habe tried both boards and 2 of the nucleo boards. I dont know what to do now because I am not able to flash the firmware. Maybe ill order an st link clone from aliexpress but this will take weeks and the nucleo worked well so far. Also i have another question. Do you connect the board to the power supply while flashing or du you only connect the 3.3V pin to the st link and power the chip like this. I have tried both ways and both didnt work but im not shure which is the right one.

mateuszfcg commented 10 months ago

@DerPinguin77 What error pops up for you when trying to flash

You can assign the RX and tx pins to the master/slave connector.

define_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
DerPinguin77 commented 10 months ago

"No target connected" and in the st link utility "Can not connect to target"

RoboDurden commented 10 months ago

Better do not connect the st link flash 3.3V with the Hoverboard 3.3V. But then you must push the onoff button (or replace with a switch) while flashing because the SELF_HOLD pin will be released while flashing. The uart header is to the left of the hall header. left pin is GND, the two middle pins are either rx,tx or tx,rx. Just like with the swd header, do not connect the fourth (right) 5V pin to your ESP 3.3V.

The rx tx pins to use on the ESP side you will find in my arduino code.

It happens to me sometimes, that i need to flash under reset. But the RST pin of these cheap st-link clones dose not work for the SWD protocol :-( It needs some soldering on these usb dongles.

I do not know how flashing works with your STM nucelo. If it offers a pin that is pulled to LOW when flashing begins.

mateuszfcg commented 10 months ago

Short circuit NRST to GND for literally a second after clicking download(f8) The NRST pin is resistor R72 as I remember correctly. I wrote about this earlier

For straightening: you contain NRST to GND click f8 and after about a second let go. And IT will go

DerPinguin77 commented 10 months ago

Thanks fot the tips. I got the Firmware flashed now. But sadly it doesent work. I tied to flash i two times but since i flashed the new firmware there is no startup beep and nothing happens. i changed the layout to 2.3 and the first line of code you suggested.

mateuszfcg commented 10 months ago

Upload your pin configuration

DerPinguin77 commented 10 months ago

Havent change anthing in the pin configutation. Just downloaded the latest zip from github, unzipped it, opened the uvprojx file, selected the 2.3 verion and flashed it. When i flash the version from two day ago it works again

mateuszfcg commented 10 months ago

Today I did not have time to sit down to it but tomorrow evening I will check what is wrong with the configuration on the git. Send your config then I will still compare with mine on disk.

DerPinguin77 commented 10 months ago

This is my config.h if thats what you mean. As i said i dindt change anything i just uncommented layout 2.3

#ifndef CONFIG_H
#define CONFIG_H

//#include "gd32f1x0.h"

// ################################################################################
// select one of the supported circuit boards and whether to compile the slave- or master board
// only the master has a buzzer :-)

// LAYOUT_2_X is used in defines.h
#ifdef GD32E230
    #define LAYOUT_2_7  // https://github.com/RoboDurden/Hoverboard-Firmware-Hack-Gen2.x/issues/16
#else
    //#define LAYOUT_2_0    // https://github.com/flo199213/Hoverboard-Firmware-Hack-Gen2
    //#define LAYOUT_2_1    // https://github.com/krisstakos/Hoverboard-Firmware-Hack-Gen2.1
    //#define LAYOUT_2_2    // motor is spinning but needs a push to startup :-/
    #define LAYOUT_2_3  // 2023/09/19 motor does not run stable (sound like skipping steps in a stepper motor but it is rotating). mosfets heating up :-(
    //#define LAYOUT_2_4    // NOT READY !!! https://github.com/RoboDurden/Hoverboard-Firmware-Hack-Gen2.x/issues/3
#endif

#define MASTER      // uncomment if firmware is for slave board

#define REMOTE_DUMMY
//#define REMOTE_UART
//#define REMOTE_CRSF

#ifdef MASTER

    #define SPEED_COEFFICIENT   -1
    #define STEER_COEFFICIENT   1

    #define CHECK_BUTTON        // disable = add '//' if you use a slave board as master
#else
    #define SLAVE                                               // Select if firmware is for master or slave board
#endif

// ################################################################################

#define PWM_FREQ                16000     // PWM frequency in Hz
#define DEAD_TIME               60        // PWM deadtime (60 = 1�s, measured by oscilloscope)

#define DC_CUR_LIMIT            15        // Motor DC current limit in amps

#define BAT_CELLS           5        // battery number of cells. Normal Hoverboard battery: 10s

//#define BLDC_WEAKENING        // some kind of field weaking added by HarleyBob for his gen2.2 firmware ?

// ################################################################################

#define DELAY_IN_MAIN_LOOP  5         // Delay in ms

#define TIMEOUT_MS          2000      // Time in milliseconds without steering commands before pwm emergency off

#ifdef MASTER
    #define INACTIVITY_TIMEOUT  8           // Minutes of not driving until poweroff (not very precise)

    // ################################################################################

    #define CELL_LOW_LVL1     3.5       // Gently beeps, show green battery symbol above this Level.
    #define CELL_LOW_LVL2     3.3       // Battery almost empty, show orange battery symbol above this Level. Charge now! 
    #define CELL_LOW_DEAD     3.1       // Undervoltage lockout, show red battery symbol above this Level.

    #define BAT_LOW_LVL1     BAT_CELLS * CELL_LOW_LVL1
    #define BAT_LOW_LVL2     BAT_CELLS * CELL_LOW_LVL2
    #define BAT_LOW_DEAD     BAT_CELLS * CELL_LOW_DEAD

    /*
    #define BAT_LOW_LVL1     35.0       // Gently beeps, show green battery symbol above this Level.
    #define BAT_LOW_LVL2     33.0       // Battery almost empty, show orange battery symbol above this Level. Charge now! 
    #define BAT_LOW_DEAD     31.0       // Undervoltage lockout, show red battery symbol above this Level.
    // ONLY DEBUG-LEVEL!!!
    //#define BAT_LOW_LVL1     29.0
    //#define BAT_LOW_LVL2     28.0
    //#define BAT_LOW_DEAD     27.0
    */

    // ################################################################################
#endif

// ###### ARMCHAIR ######
#define FILTER_SHIFT 12                         // Low-pass filter for pwm, rank k=12

#endif
DerPinguin77 commented 10 months ago

And this is my defines 2.3.h

// from https://github.com/RoboDurden/Hoverboard-Firmware-Hack-Gen2.x/issues/20

#ifdef MASTER   // this layout has buzzer on the master 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 TODO_PORT   GPIOF       // this should be a pin that does no harm if input or output
#define TODO_PIN    GPIO_PIN_4  // PF4 is only accessible on the largest GD32F130Rx LQFP64 pinouts mcu

// 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

// 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      // channels G=green and Y=yellow swopped compared to 2.0
#define TIMER_BLDC_GH_PORT  GPIOA
#define TIMER_BLDC_GL_PIN       GPIO_PIN_13
#define TIMER_BLDC_GL_PORT  GPIOB
// Channel B
#define TIMER_BLDC_CHANNEL_B TIMER_CH_1
#define TIMER_BLDC_BH_PIN       GPIO_PIN_9
#define TIMER_BLDC_BH_PORT  GPIOA
#define TIMER_BLDC_BL_PIN       GPIO_PIN_14
#define TIMER_BLDC_BL_PORT  GPIOB
// Channel Y
#define TIMER_BLDC_CHANNEL_Y TIMER_CH_0
#define TIMER_BLDC_YH_PIN       GPIO_PIN_10
#define TIMER_BLDC_YH_PORT  GPIOA
#define TIMER_BLDC_YL_PIN       GPIO_PIN_15
#define TIMER_BLDC_YL_PORT  GPIOB

// 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
// 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

// Usart master slave defines
//#define USART_MASTERSLAVE USART1  // robo no second uart port for this board
#ifdef USART_MASTERSLAVE
    #define USART_MASTERSLAVE_TX_PIN    TODO_PIN
    #define USART_MASTERSLAVE_TX_PORT   TODO_PORT
    #define USART_MASTERSLAVE_RX_PIN    TODO_PIN
    #define USART_MASTERSLAVE_RX_PORT   TODO_PORT
#endif

// 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
    #define USART_STEER_COM_TX_PORT GPIOB
    #define USART_STEER_COM_RX_PIN  GPIO_PIN_7
    #define USART_STEER_COM_RX_PORT GPIOB
#endif

// ADC defines
//#define VBATT_PIN GPIO_PIN_0      // uncomment this line when you have verified the pin/port
#define VBATT_PORT GPIOA            
#define VBATT_CHANNEL ADC_CHANNEL_17
//#define CURRENT_DC_PIN    GPIO_PIN_1  // uncomment this line when you have verified the pin/port
#define CURRENT_DC_PORT GPIOA
#define CURRENT_DC_CHANNEL ADC_CHANNEL_2

// 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

#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

// 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

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

Ok. Tomorrow night I will check what could be wrong and let you know

DerPinguin77 commented 10 months ago

ok thanks

RoboDurden commented 10 months ago

@DerPinguin77 i feel sorry when my latest github update no longer works for you :-( As you had problems with flashing i suggest that you unzip your older download again to see if my code changes are the cause of your problem. There is also another user working on the 2.7 layout at the moment. This compiles on the GD32E230 target: grafik So it might happen that i wrongly update my github not with our default GD32F130 target :-(

I now have tested my latest firmware with my 2.0 master dummy 5s config and it works. Uploaded it to my github in case i had the wrong target last time.

mateuszfcg commented 10 months ago
// 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_3      // 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_4          // robo, based on Herleybob:defines.h
#define BUTTON_PORT GPIOA                       // robo, based on Herleybob:defines.h

this is the only difference between the defines_2-3.h file, maybe that's why it doesn't start for you.

RoboDurden commented 10 months ago

When you say difference you need to quote two sources. My defines_2-3.h has

#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

taken from what you posted earlier above.

mateuszfcg commented 10 months ago

https://github.com/RoboDurden/Hoverboard-Firmware-Hack-Gen2.x/assets/83178714/9ab651f7-ec5f-4465-af5c-e6855b55ce88

this is not the correct operation, the hall sensors are 100% well assigned. Maybe it's a matter of reversing the signals to the mosfet driver

RoboDurden commented 10 months ago

this is not very informative. Please make a video of the RemoveDummy with the original

speed = 3 * (ABS(( ((int32_t)msTicks/3+100) % 400) - 200) - 100);

And then

speed = 10 * (ABS(( ((int32_t)msTicks/3+100) % 400) - 200) - 100);

And in both cases post the log output of the Arduino.

mateuszfcg commented 10 months ago

Speed=3

https://youtube.com/shorts/OZeQWUJgRek?si=XlLNZiZQuTQsuqt7

https://github.com/RoboDurden/Hoverboard-Firmware-Hack-Gen2.x/assets/83178714/f2787704-b8b6-49ff-bf27-6f2b33570dd8

Speed=10

https://youtube.com/shorts/pPWQjdwFYdE?si=_VlsPuYDR2YQrP19

https://youtu.be/KbFg7VUdYGc?si=PIf7mGa2FImwEcHm

As you could see, the engine has no torque at all. Something is wrong with the steering.

Reading from the uart does not bother at all. I want the engine to start running stably. Videos I have to upload to YT because they are too heavy

RoboDurden commented 10 months ago

At +-300, the motor should move faster and more smoothly. That indeed looks like that hall sensor ordering is wrong. If you have a 2A cc power supply, it should be okay to simply test all 6 combinations of

#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

Could you please verfiy the colors of

#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

Then you could let the three led blink when the 3 hall sensors are read in bldc.c:197

 // Read hall sensors
hall_a = gpio_input_bit_get(HALL_A_PORT, HALL_A_PIN);
hall_b = gpio_input_bit_get(HALL_B_PORT, HALL_B_PIN);
hall_c = gpio_input_bit_get(HALL_C_PORT, HALL_C_PIN);
RoboDurden commented 10 months ago

If have pushed this to my github:

    // Read hall sensors
    hall_a = gpio_input_bit_get(HALL_A_PORT, HALL_A_PIN);
    hall_b = gpio_input_bit_get(HALL_B_PORT, HALL_B_PIN);
    hall_c = gpio_input_bit_get(HALL_C_PORT, HALL_C_PIN);

    /*
    gpio_bit_write(DEBUG_LED_PORT, LED_GREEN, hall_a);
    gpio_bit_write(DEBUG_LED_PORT, LED_ORANGE, hall_a);
    gpio_bit_write(DEBUG_LED_PORT, LED_RED, hall_a);
    */

When you remove the / and / the led should already "rotate" when you rotate the motor manually :-)

mateuszfcg commented 10 months ago
 // Read hall sensors
hall_a = gpio_input_bit_get(HALL_A_PORT, HALL_A_PIN);
hall_b = gpio_input_bit_get(HALL_B_PORT, HALL_B_PIN);
hall_c = gpio_input_bit_get(HALL_C_PORT, HALL_C_PIN);

Can I find this configuration somewhere or do I have to add something? and in which file, so that I don't have to search

RoboDurden commented 10 months ago

read my post again :-)

mateuszfcg commented 10 months ago

and sorry I didn't read it :)

mateuszfcg commented 10 months ago

the colour scheme doesn't match because I only have red green and a separate blue board, but I'll assign each colour to a pin and let you know

RoboDurden commented 10 months ago

Normaly one board only has two leds and the other board has 3 leds.

mateuszfcg commented 10 months ago

u mnie jest inaczej chociaż nie wiem dlaczego.

a tak ma to wyglądać

po odkomentowaniu linijki do sprawdzenia czujników nic sie nie zmienia.Zielona LED świeci cały czas inne nie reagują

odkomentowałem LED debug żeby czerwona nie mrugałą

// LED defines, colors probably mismatch !
#define LED_GREEN           GPIO_PIN_3      //3b
#define LED_GREEN_PORT  GPIOB
#define LED_ORANGE          GPIO_PIN_4   //5b
#define LED_ORANGE_PORT GPIOB
#define LED_RED                 GPIO_PIN_15 //15a
#define LED_RED_PORT        GPIOA

#define UPPER_LED_PIN   GPIO_PIN_13
#define UPPER_LED_PORT  GPIOC
#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
RoboDurden commented 10 months ago

Well if this will stop the red led:

//#define DEBUG_LED_PIN     LED_RED
//#define DEBUG_LED_PORT    LED_RED_PORT

then try

#define DEBUG_LED_PIN   LED_GREEN
#define DEBUG_LED_PORT  LED_GREEN_PORT

and change

#define LED_GREEN           GPIO_PIN_3      //3b
#define LED_GREEN_PORT  GPIOB

until the green led lights up.

mateuszfcg commented 10 months ago

https://github.com/RoboDurden/Hoverboard-Firmware-Hack-Gen2.x/assets/83178714/69c2641c-49ed-4bdd-99ca-b6aed5e618be

no response to turning the motor

RoboDurden commented 10 months ago

I can not help you with every little step. Why is the led blinking ? You should find out yourself. This led-panel is the 2-led panel. You should have a 3-led panel from the other side of the hoverboard.

mateuszfcg commented 10 months ago

I just pulled out the master page. on the other side there is actually a panel with 3 leds. i didn't pay attention to it but i managed by soldering a separate led :) the led blinks when it is assigned to debug mode, maybe you need to disable it ?

RoboDurden commented 10 months ago

i do not have time at the moment to check my suggestions with my test setup. I think you have to disable this function in main.c by adding a return;

void ShowBatteryState(uint32_t pin)
{
    return;

    if(pin == LED_ORANGE){
        #ifdef THIRD_LED