-
Notifications
You must be signed in to change notification settings - Fork 25
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
MM32 pin autodetect firmware :-) #66
Comments
two friendly suggestions to make your autodetect.c code more readable: i do not like
this suggests that the two arrays share the same type of information.
using structs will save memory and improves readability:
with something like
And better use enum or defines instead of plain integers. I used bits insead of 1,2,3 to easily test for multiple cases:
peace :-) |
i will replace the switch case magic number with enum or define i thought the storage is calculated by program+ro+rw data i have searched for it last time |
this is my first time writing code for other people to use insted of for my self so its not very readable but itll get better |
Yes you are right, for the difference between spin05 and spin06 the 32kb inlcudes program+ro+rw data I think. But for the Keil free 32 kB I think I got the error message when only program data exceed 32 kB. But I should test my autodetect binary with a new gd32f130c6 target to very that. |
use gcc or platformio+gcc to unlimited |
Oh yes, please build me a makefile, then I could add these firmwares to my free online compiler: https://pionierland.de/hoverhack I strongly dislike Linux :-/ |
i have unlimited compile size and compiler v5 in keil dont need to worry about that linux is great |
@RoboDurden i have edited the code a bit and hopefully its more understandable now |
Why not, I'll try to do it when I have free time... so far, there are problems with this ((
gcc is also available for Windows ps. A good option is Visual Studio Code + Platformio plugin, it can download and install gcc itself. |
i think @GRROWL911 is using the platformio plugin |
but can it support mm32 because eferu is gd32 |
As many hoverboards only have 32kB anyway, the 32kB free Keil limit is no problem for us. |
yeah the mm32spin06 is really quite rare and not needed in most case anyways 32k is enough |
i may have forgot to git push but its done now |
Yes indeed, the platformio plugin for VS Code works, and I can flash and debug with an ST-Link, I have not found where to set a complete chip erase yet. So I use pyocd for that step.
… On Feb 19, 2024, at 12:33 PM, AI LIFE ***@***.***> wrote:
i think @GRROWL911 <https://github.com/GRROWL911> is using the platformio plugin
—
Reply to this email directly, view it on GitHub <#66 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AIFRBBEJ7MZ5TKKQWHXYBI3YUOSJ7AVCNFSM6AAAAABDPGE6RGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJTGA3DEOBSGM>.
You are receiving this because you were mentioned.
|
hows your progress now |
I have adc and uart1 working, I am struggling with getting UART2 working. I have TX2 working, however when I enable RX2 it does not work and stops RX1 too. The slave boards have two pin outs for UART. I'm pretty sure about the pins, and I think the AF if my problem. Otherwise, I was distracted with the LKS board for a bit. Finished tracing those pins, and erased the chip, and programmed the LEDs ok.
… On Feb 19, 2024, at 1:39 PM, AI LIFE ***@***.***> wrote:
hows your progress now
have you got adcs and uart at least
—
Reply to this email directly, view it on GitHub <#66 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AIFRBBHJSLNAN3Y7E32YEA3YUOZ6ZAVCNFSM6AAAAABDPGE6RGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJTGEZTEMZUGI>.
You are receiving this because you were mentioned.
|
same as mine uart2 rx not working nice to see you making progress with lks just as fast as i did with mm |
Was hoping to use the UART2 as a passthrough to the master, perhaps it is not possible.
… On Feb 19, 2024, at 1:46 PM, AI LIFE ***@***.***> wrote:
same as mine uart2 rx not working
i think bug in the library
with debug it can work i see data in RDR register but interrupt and dma not work
but my firmware do not need 2 uart anyways 1 is enough
nice to see you making progress with lks just as fast as i did with mm
i think it will not be hard as all example and hal library is available
—
Reply to this email directly, view it on GitHub <#66 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AIFRBBBH4BGC26XROEIHJPDYUO24BAVCNFSM6AAAAABDPGE6RGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJTGEZTSOJRGE>.
You are receiving this because you were mentioned.
|
it should be but its not idk why either |
I can work around the issue with my controller which has two UARTs and I can connect to each independently. I was just trying to get this to work.
As a side, I did get UART2 working, if UART1 DMA is not enabled. So comment out this
if(UARTEN==UART1){
DMA_NVIC_Config(DMA1_Channel3, UARTEN, (u32)&UART1->RDR, (u32)sRxBuffer, 1);
}else{
DMA_NVIC_Config(DMA1_Channel3, UARTEN, (u32)&UART2->RDR, (u32)sRxBuffer, 1);
}
leave in this:
DMA_NVIC_Config(DMA1_Channel5, UART2EN, (u32)&UART2->RDR, (u32)sRx2Buffer, 1);
and the interrupt:
void DMA1_Channel4_5_IRQHandler(void)
will be executed. Also note that the Channel for UART2 is 4/5, so
DMA_NVIC_Config(DMA1_Channel3, UARTEN, (u32)&UART2->RDR, (u32)sRxBuffer, 1);
is not correct anyway. Also note the extra parameter, since in
void DMA_NVIC_Config(DMA_Channel_TypeDef* dam_chx, UART_TypeDef* uart, u32 cpar, u32 cmar, u16 cndtr)
UARTEN was hard coded, and would not allow for both UARTs to be setup.
//UART_DMACmd(UARTEN, UART_DMAReq_EN, ENABLE);
UART_DMACmd( uart, UART_DMAReq_EN, ENABLE);
This does not fix the problem with getting both working, however at least give the option of one or the other.
… On Feb 19, 2024, at 3:02 PM, AI LIFE ***@***.***> wrote:
it should be but its not idk why either
because one of my board annoyingly used uart2 for masterslave and im still unable to get it to work and i also bricked it with the clock fix
but to control master and slave just physically connect 2 board tx and rx together then command will be sent to both board
and you have successfully used slave board??
why everyone can do that i cant
—
Reply to this email directly, view it on GitHub <#66 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AIFRBBHQOX47ETTEJOCV7QLYUPDYRAVCNFSM6AAAAABDPGE6RGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJTGIYDOOJTGU>.
You are receiving this because you were mentioned.
|
And, yes I did get the slave board working, either connected to the master, or by itself. When by itself, I needed a 13.7V power input on the 12V UART connector, and it works as expected. Note there are no hold, nor switch, and the UART2 for my board reuses these pins, so make sure when compiling for the slave you disable the LATCHPIN and BTNPIN. Also, for my slave, there is a buzzer, however no buzzer on the master.
… On Feb 19, 2024, at 3:02 PM, AI LIFE ***@***.***> wrote:
it should be but its not idk why either
because one of my board annoyingly used uart2 for masterslave and im still unable to get it to work and i also bricked it with the clock fix
but to control master and slave just physically connect 2 board tx and rx together then command will be sent to both board
and you have successfully used slave board??
why everyone can do that i cant
—
Reply to this email directly, view it on GitHub <#66 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AIFRBBHQOX47ETTEJOCV7QLYUPDYRAVCNFSM6AAAAABDPGE6RGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJTGIYDOOJTGU>.
You are receiving this because you were mentioned.
|
because my firmware is made for just 1 uart i never designed for 2 to be enabled at same time so i reuse UARTEN |
and if i support uart2 i will need to compile tens of hundreds of binary every time which is def not possible |
i think i will get some 7815 regulators to try out the slave board to see if it work |
No need to support UART2, I was just trying to get it to work for my board and figure out why it did not work. I will also be abandoning using UART2 since it does not work.
… On Feb 19, 2024, at 5:15 PM, AI LIFE ***@***.***> wrote:
because my firmware is made for just 1 uart i never designed for 2 to be enabled at same time so i reuse UARTEN
i just want to allow board like layout2.21 that use uart2 as masterslave to use uart2
i did not know uart2 is dma channel 4/5 thats why it doesnt work
i can easily fix it now but because to support autodetect i will choose to ignore uart2 anyways as uart2 have too many pin
uart1 only have 6 and 2 of them is used by motor so only 4 wire and 4 combinations
automaticly matching pinmodeAF is very very hard so i choose not support uart2
—
Reply to this email directly, view it on GitHub <#66 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AIFRBBDB6UFJSEMD6ON4LATYUPTJJAVCNFSM6AAAAABDPGE6RGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJTGMYDEMRZGQ>.
You are receiving this because you were mentioned.
|
ok if you have any new layout you can help try out the autodetect firmware |
A note about the ADC. While working on the LKS board, I noticed that the current reading is actually coming from two pins and they use some sort of comparison between the two to get the current. I am not yet sure about the details, and not sure if it improves the resolution of the readings, just thought I would pass it along.
… On Feb 19, 2024, at 1:39 PM, AI LIFE ***@***.***> wrote:
hows your progress now
have you got adcs and uart at least
—
Reply to this email directly, view it on GitHub <#66 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AIFRBBHJSLNAN3Y7E32YEA3YUOZ6ZAVCNFSM6AAAAABDPGE6RGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJTGEZTEMZUGI>.
You are receiving this because you were mentioned.
|
no,there is 2 pins going to the current sens resistor,one going to adc and other one go to a comparator |
That is what i wrote i did :-) |
you can now try the sine wave mode |
https://youtu.be/0jwVfbfLZfA :-/ The aweful stuttering at high speed sometimes does not seem to be because of the cc power supply. Maybe the 32.0 Volt low battery. |
if you fancy using the autodetect again then use |
Yes that helped. at one point there was still that stuttering. Right at the beginning the sine firmware did boot up and the esp32 was directly sending pwm 1000. I guess at very high torques the voltage even went below the new 24000 = 24 V limit and your software tries to stop the motor. |
set it to 0 will disable low battery protection |
public video: https://youtu.be/ZMJMT-ILVzc I really want to do other stuff on this sunny day. |
So here my working pin definition for 2.4.1 (ex2.8):
So of course good programming would not mean to use a uint16_t or int16_t anyway but a nice struct with uint8_t for pin definitions, float for battery voltages and uint32_t for baud rate. And for storing in "eeprom" you can aways cast the struct to (u8*)
The pinFinder dump would become intuitive as well: And now we have the Linux vs OOP dispute again :-( |
You can get rid of this warning
by adding a
Linux believes don't care about warnings ;-) |
and this brings the warnings to zero:
|
I also added 's' for 'short list' to the CLI
'l' listing all values did always flood the putty console and i needed to scroll upwards to see the pin definitons :-/ |
Yes, the CLI will have problems to access values from a config struct. When you really want to read and overwrite a special value, you of course need to read a manual :-(( To access a value of a struct you would need something like that (compiles successfuly):
or continue your
to link the index to the configType |
the struct will be better on saving eeprom storage, but there is no need to save storge the switch case i really dont need to handle those condition so it is ok |
UartBus does not require 19200, it is only the defaut to support softwareSerial. |
the best solution is to let user type 115200 and store 1152,type 42000 and store 4200,type SIN_VOLT and store 2,but again not in 32k |
Yes, BAT_EMPTY = 0; seems to prevent the stuttering when board is started while esp32 is sending pwm 1000 :-) I could make a youtube tutorial on your nice pinFinder and main firmware. How do i test |
yes,open the serial feedback from esp,command sped will equal to real feedback speed |
Yes, speed mode works great :-) Maybe you want to add a SINE_POS (SINE_ODOM) mode. |
yes indeed,position mode will be useful,with sine wave position holding is possible by increasing the positive d axis (opposite of field weakening),it will require complicated algrorithm to acheive but it might be doable btw now field weakening is disabled,if you have need of spinning very fast it can do at least 2x the current speed with just 24v(by drawing more current) |
maybe you are right,because i actually go rotate the motor by hand 1 revolution and it is 90 |
You should sleep now :-) |
i have not fixed the low battery problem, have to work on other things during the day |
someone said the low battery mode is active when it is disabled, and i tried it it actually didnt get disabled, and i end up have to use keil to debug to find it, cuz it is 1 month ago i already forgot |
Yes, my autodetect code is even older ;-) |
must be very hard to work with a gd32, cuz its not possible to debug ive tried that |
and now f103 series(gd/stm/mm) support is on the list too |
when you have ported to f103, i dream that then f130 will not be a big step. |
there is no mm32f130 unfortunately |
@AILIFE4798 has written a complete new autodetect for his MM32 firmware that saves the found pins to EEPROM that his hoverboard firmware reads on startup. So only one hoverboard firmware needed :-)
The autodetect firmware currently is the pin-finder branch of his MM32 firmware: https://github.com/AILIFE4798/Hoverboard-Firmware-Hack-Gen2.x-MM32/tree/pin-finder
This autodetect firmware offeres a uart serial user interface in which you can also set the UartBus id for controlling multiple boards on one uartBus !
Would be great if people with a MM32 board start testing it :-)
The text was updated successfully, but these errors were encountered: