Open AILIFE4798 opened 6 months ago
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 :-)
i think i have sucessfully build my self i will try to flash it now lets hope for the best
yes it really worked! now the pin is all correct and motor can spin smoothly and voltage/current reading is also accurate
i just realized this board actually already exist since the second issue already lol #2 oh well at least mine is fully working now
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.
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
and the final pin tracing image update
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
here is comparator area pin tracing but i do not understand anything
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
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.
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
Maybe I should compare this gen2 board with gen1 board which is using eferu foc to see if it really did make Any difference
Can this layout be added to readme as ready now Or do you need video of actual test to confirm
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 :-/
Ok
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
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 :-/
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
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
thats a very good idea dont aim too far on first try just gradually test everything
Oh, i should have posted this to the 2.8 issue.
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
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