Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gen2.1.7.1 (ex2.6.1) #49

Open
AILIFE4798 opened this issue Jan 3, 2024 · 72 comments
Open

Gen2.1.7.1 (ex2.6.1) #49

AILIFE4798 opened this issue Jan 3, 2024 · 72 comments

Comments

@AILIFE4798
Copy link

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
Copy link
Author

@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
Copy link
Owner

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
Copy link
Owner

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
Copy link
Owner

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
Copy link
Author

@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
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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
Copy link
Author

updated schematic
hoverV2 6 1_compressed_fix1

@RoboDurden
Copy link
Owner

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
Copy link
Owner

RoboDurden commented Jan 5, 2024

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
Copy link
Author

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
Copy link
Owner

PA14 = SWCLK and PA13 = SWDIO

  • GND. Better not contact 3.3V but bridge the onoff button to let the board generate the mcu 3.3V.

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
Copy link
Owner

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
Copy link
Owner

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

@AILIFE4798
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

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
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

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
Copy link
Author

image-6
Image failed to attach

@AILIFE4798
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

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

@RoboDurden
Copy link
Owner

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
Copy link
Author

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

@AILIFE4798
Copy link
Author

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

@RoboDurden
Copy link
Owner

grafik

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

@RoboDurden
Copy link
Owner

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
Copy link
Author

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

@RoboDurden
Copy link
Owner

In defines.h there are two float defines to scale the voltage and currentDC:

// ADC value conversion defines
#ifndef MOTOR_AMP_CONV_DC_AMP
	#define MOTOR_AMP_CONV_DC_AMP 0.201465201465  // 3,3V * 1/3 - 0,004Ohm * IL(ampere) = (ADC-Data/4095) *3,3V
#endif
#ifndef ADC_BATTERY_VOLT
	#define ADC_BATTERY_VOLT      0.024169921875 	// V_Batt to V_BattMeasure = factor 30: ( (ADC-Data/4095) *3,3V *30 )
#endif

You can defines those two already in defines_2-6.h to get correct readings for this layout..

I assume that you now can compile yourself :-)

@AILIFE4798
Copy link
Author

i think i have sucessfully build my self
i will try to flash it now lets hope for the best

@AILIFE4798
Copy link
Author

yes it really worked!
now the pin is all correct and motor can spin smoothly and voltage/current reading is also accurate

@AILIFE4798
Copy link
Author

i just realized this board actually already exist since the second issue already lol #2
oh well at least mine is fully working now

@RoboDurden
Copy link
Owner

As you have more insight into the pin tracing of your 2.6.1, it would be nice if you compare the pcb with the photos of the 2.6 layout in the Schematics_2.6 folder.
If you do not see some differences for the pins defines in defines_2-6.h
then we can be quite sure that the 2.6.1. board is compatible with the 2.6 layout.

@AILIFE4798
Copy link
Author

to me it looked the same from the picture
i actually traced mine by using the physical pcb i only draw the image for you and others that have the same board to see
so i cannot be sure but i try to trace some random ones thats all on single layer and its the same
im not quite sure about the battery led but i think it should be the same

@AILIFE4798
Copy link
Author

hoverV2 6 1_final
and the final pin tracing image update

@AILIFE4798
Copy link
Author

As you have more insight into the pin tracing of your 2.6.1, it would be nice if you compare the pcb with the photos of the 2.6 layout in the Schematics_2.6 folder. If you do not see some differences for the pins defines in defines_2-6.h then we can be quite sure that the 2.6.1. board is compatible with the 2.6 layout.

the buzzer is on master for 2.6 but on slave for 2.6.1

@AILIFE4798
Copy link
Author

AILIFE4798 commented Jan 7, 2024

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

i can understand now it is sensing the voltage from phase wire to ground i think it is used to sens the back EMF or phase voltage on the yellow and blue phase wire

@RoboDurden
Copy link
Owner

RoboDurden commented Jan 7, 2024

For the advanced FOC control (which needs more than 32kB MCU), at least two phase currents are needed.
The empty footprint of the SOT-8 would be another dual op-amp.
two phase currents = two low-side mosfet voltages. The mosfet serves as a "shunt resistor" so the D-S voltage is proportional to the phase current.
On most layouts, there are two sot-8 dual opamp chips: one for two phase currents and the other for the currentDC amplification (and the third phase current).

I have reached my train station and will make a few days break from my outdoor life.
But going to bed now.

@AILIFE4798
Copy link
Author

it have the dual opamp fitted i just removed it to find the current dc pin but infact current dc is connected to the adc directly and the opamp is for 2 phase current
maybe i should replace the mcu i have the ability to do it
but the layout 2.8.1 is selling for $2 i cannot resist to buy some
i will buy some gd32f130c8t6 and if its not needed to replace the mm32spin i will use it on layout2.6.1

@AILIFE4798
Copy link
Author

Maybe I should compare this gen2 board with gen1 board which is using eferu foc to see if it really did make Any difference

@AILIFE4798
Copy link
Author

Can this layout be added to readme as ready now
Or do you need video of actual test to confirm

@RoboDurden
Copy link
Owner

No it looks to be 99% ready.
But i still have to decide what to do about the buzzer differerence between 2.6 and 2.61 :-/

@AILIFE4798
Copy link
Author

Ok

@AILIFE4798
Copy link
Author

you have deleted keil thats very unfortunate i also want to install on my laptop but its ok ill transfer the file my self
just why not keep it here for those other people that also want to compile them selves i would argue it should be in readme

@RoboDurden
Copy link
Owner

https://www.robosoft.de/forums/mdk539.exe.tmpX

@RoboDurden
Copy link
Owner

Thanks @AILIFE4798 for adding the HAL library from that mm32 examples with a pull request !
Now i am down to 22 errors but it really looks like it needs way more then to rename some function names or constants names.
Here for example the DMA init code for that adc (battery voltage and current DC) of the gen2.x :

	// Initialize DMA channel 0 for ADC
	dma_deinit(DMA_CH0);
	dma_init_struct_adc.direction = DMA_PERIPHERAL_TO_MEMORY;
	dma_init_struct_adc.memory_addr = (uint32_t)&adc_buffer;
	dma_init_struct_adc.memory_inc = DMA_MEMORY_INCREASE_ENABLE;
	dma_init_struct_adc.memory_width = DMA_MEMORY_WIDTH_16BIT;
	dma_init_struct_adc.number = 2;
	dma_init_struct_adc.periph_addr = (uint32_t)&ADC_RDATA;
	dma_init_struct_adc.periph_inc = DMA_PERIPH_INCREASE_DISABLE;
	dma_init_struct_adc.periph_width = DMA_PERIPHERAL_WIDTH_16BIT;
	dma_init_struct_adc.priority = DMA_PRIORITY_ULTRA_HIGH;
	dma_init(DMA_CH0, &dma_init_struct_adc);
	
	// Configure DMA mode
	dma_circulation_enable(DMA_CH0);
	dma_memory_to_memory_disable(DMA_CH0);
	
	// Enable DMA transfer complete interrupt
	dma_interrupt_enable(DMA_CH0, DMA_CHXCTL_FTFIE);
	
	// At least clear number of remaining data to be transferred by the DMA 
	dma_transfer_number_config(DMA_CH0, 2);
	
	// Enable DMA channel 0
	dma_channel_enable(DMA_CH0);

This has to be ported to the MM32 style:

    DMA_InitTypeDef DMA_InitStructure;
    NVIC_InitTypeDef NVIC_InitStruct;

    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
    DMA_DeInit(DMA1_Channel1);
    DMA_StructInit(&DMA_InitStructure);
    //DMA transfer peripheral address
    DMA_InitStructure.DMA_PeripheralBaseAddr = (u32) & (ADC1->DR);
    //DMA transfer memory address
    DMA_InitStructure.DMA_MemoryBaseAddr = (u32)&ADCValue;
    //DMA transfer direction from peripheral to memory
    DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
    //DMA cache size
    DMA_InitStructure.DMA_BufferSize = 20;
    //After receiving the data, the peripheral address is forbidden to move
    //backward
    DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
    //After receiving the data, the memory address is shifted backward
    DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
    //Define the peripheral data width to 16 bits
    DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
    //Define the memory data width to 16 bits
    DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
    //Cycle conversion mode
    DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
    //DMA priority is high
    DMA_InitStructure.DMA_Priority = DMA_Priority_High;
    //M2M mode is disabled
    DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
    DMA_InitStructure.DMA_Auto_reload = DMA_Auto_Reload_Disable;
    DMA_Init(DMA1_Channel1, &DMA_InitStructure);
    DMA_Cmd(DMA1_Channel1, ENABLE);

    //DMA interrupt initialization
    DMA_ITConfig(DMA1_Channel1, DMA_IT_TC, ENABLE);

It does not make much sense trying to port the Gen2 code line by line.
But better start from scratch and implement the adc / dma / timer / uart functionality with these mm32 examples that seem to cover all we need.

But i fear i will not have the happiness to write an entire new firmware for a 32 kB mcu which will not really fit into the Gen2.x code.

Need to take a break :-/

@AILIFE4798
Copy link
Author

I think just use some #ifdef for different microcontroller will do
The code will also support mm32spin06(64k) and mm32spin07(128k)
So there's no problem to port foc in the future

It's not on a hurry hardware will take a while to arrive although I believe allot of people have the hardware to test if you would finish it before I got

@RoboDurden
Copy link
Owner

With all the documentation this repo has become to big anyway.
So i will move the Keil project to a "partner" repo Gen2.x_GD32.
and to a second Gen2.x_MM32 in which i delete all code but the three led blinking in main() according to the three hall sensors.
If that compiles there is a chance that the one with the hardware can test it successfully.
Then add the DMA_ADC from the MM32_examples for batteryVoltage and currentDC as the 16 kHz adc_finished_callback is used to call CalculateBLDC(); which does only simple digital IO to drive the BLDC :-)
And if that works then add the RemoteUart to connect ESP32.
Finally move all code back to one universal Gen2.x

@AILIFE4798
Copy link
Author

thats a very good idea
dont aim too far on first try just gradually test everything

@RoboDurden
Copy link
Owner

Oh, i should have posted this to the 2.8 issue.

@RoboDurden RoboDurden changed the title Layout 2.6.1 Gen2.1.7.1 (ex2.6.1) Feb 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants