Hi guys, love your work with the SimpleFOC library and community. It’s been really inspiring.
I have been driving my BLDCs using SimpleFOC on a reflashed gimbal controller which has been great so far except I am having issues connecting multiple sensors due to addressing issues (I need a multiplexer). I also have a B-G431B-ESC1 Discovery kit which @Owen_Williams has been demoing a bit on YouTube (great vids btw) and was wondering if Owen or someone else could give me some pointers on getting SimpleFOC running on there - preferable with a sensor connected as well.
I am pretty comfortable with microcontrollers, sensors and flashing etc. My questions are:
How would I go about flashing the B-G431B-ESC1 to run Arduino firmware?
How do I know what microcontroller pins map to what on the B-G431B-ESC1 board?
How did you guys (whoever wrote the gimbal tutorial) know which microcontroller pins mapped to what on the gimbal controller board? I’ve looked everywhere for a schematic but couldn’t find anything that seemed legit.
I would be happy to even write a tute on using the B-G431B-ESC1 once I know more about it.
Yes, gimbal controllers are really limited regarding their pinout.
And it is true that atmega328 does not have a good support for multiple i2c sensors.
In the new version of the library you change the default bus of the i2c and spi sensor so if your mcu would allow for it you would not need the multiplexor.
Owen will be able to tell you more about the B-G431B-ESC1, he is the big master of it
I do not even have one.
But what I can tell you is that you will need either a st-link programmer or another stm board with st-link If you have a Nucleo board, that would be enough.
This is a great question. I do not have a good way.
The way I did it is by trying pins. Gimbal controllers do not have too many so it will work reasonably fast.
Thinking about it more I think the pin defs for the B-G431B-ESC1 can probably be found somewhere in the CubeIDE example code somewhere. I’ll buy an ST-Link programmer and start poking around
You don’t need an stlink with this board as it has a daughter board. The daughterboard has an st-link on it. Essentially you program through usb
You probably need an ftdi (serial to usb) to get Serial1.print() working, without it, you are coding blind. I haven’t managed to get print working through usb so I’m using rx/tx and ftdi for serial. I have got break points working though (in platformio). Usb ftdi are about £3 on ebay.
I created a PR to get this board added to stm32duino, until this is accepted you won’t be able to choose this board in arduino. The process should be that you add stm32duino boardmanager url to arduino, but until this board gets merged then it’ll be missing from the list. The PR is flagged as targeting 2.0, they are restructuring all their boards and it’s holding things up.
Before the PR is accepted it should still be possible to get it working but you’d essential need to copy a folder of 6 files and update a boards.txt somewhere in your file system. If you are interested in trying i can try to help you.
The b-g431b-esc1 has no i2c or spi. It can only be used with hall or abz encoders (not tried the latter). It has current sensing hardware on it, but I’m not sure i have the time/skills to get this working!
I’ve got two gimbal controllers one is dual channel and the other is triple channel (storm32). I like the latter a bit more but that requires stlink. It’s supposed to have 2 i2c buses but i could only get one working. I did get spi working but that requires desoldering resistors to ‘liberate’ spi2. @blackblue007 did a great guide of storm32 with simplefoc
Again i was also using ftdi. The storm32 is a little challenging to use but i learnt a lot from it
Thanks for the info, Owen, it’s all making a bit more sense now. I only realised the daughterboard was a standalone programmer after posting. That will save me 15 bucks at least
I’ll keep digging in over the next weeks and try to get something going and reach out if not. Your PR should be enough to know what to change.
It’s a shame about the lack of spi & i2c on the b-g431b-esc1 as it seems like a nice cheap driver with more reliable doco etc than the gimbals I have (2-channel and 3-channel BCG (non-storm) clones).
As a possible solution for sensing do you think an as5600 magnetic encoder in PWM mode being read by the PWM input of the b-g431b-esc1 could work?
Yes - I reckon PWM with as5600 would work. I played with AS5600 analog when I first started using SimpleFOC. I did find that there was a bit of a deadzone when it wrapped to a new revolution in PWM mode causing it to speed up slightly once per revolution. The readings were a lot noisier and hence harder to tune PID with PWM - probably needs more low pass filter and/or to ignore the lowest bits (i.e. treat it as a 9bit resolution instead of 12bit).
I want to create a custom dual board - this is not something I’ve done before, but if it works the schematic will be open source.
BTW - you can buy an st-link clone on ebay for <£5. They are missing a swd (serial wire debugger) pin meaning that you can’t use printf() but you can certainly program with them.
Hello, @Owen_Williams Serial.available() doesn’t work with this board with Arduino IDE ? When I send a value through the serial monitor, nothing happen ?
However, I get well what sends me this last one with Serial.println…
Hi Owen, thank you for your nice Youtube Video.
Tried to get PlatformIO running tonight. Unfortunately I didn’t managed to find a way where to copy the 6files from your PR. I managed to add the json file with the board definition. So that PlatformIO recognize B-G431 properly. But I don’t know where to paste the stm32duino files. It seems they are not really local on my PC, sorry Iam not so familiar with github now.
Regards Waldemar
If you are struggling to find where DISCO_B_G431B_ESC1 folder should be created perhaps you can look for DISCO_F407VG folder, it should live along side that.
@Marc_O - I am seeing the same - Serial1 works in 1 direction, I can print but not read. My suspicion is that the serial event interrupt is not hooked up correctly. This is the first board variant I’ve created so it’s likely missing something.
At the moment it looks like we are limited to button, potentiometer and pwm/servo as possible input mechanisms. When I get a chance I’ll try to unlock Serial1.read.
I copied all the files into the new folder.
Now I receive strange errors if I try to select a board in board selector menu
all Error: “Error: Traceback (most recent call last):\r\n File "C:\Users\wladi\.platformio\penv\lib\site-packages\platformio\main.py", line 109, in main\r\n cli() # pylint: disable=no-value-for-parameter\r\n File "C:\Users\wladi\.platformio\penv\lib\site-packages\click\core.py", line 829, in call\r\n return self.main(*args, **kwargs)\r\n File "C:\Users\wladi\.platformio\penv\lib\site-packages\click\core.py", line 782, in main\r\n rv = self.invoke(ctx)\r\n File "C:\Users\wladi\.platformio\penv\lib\site-packages\platformio\commands\init.py", line 44, in invoke\r\n return super(PlatformioCLI, self).invoke(ctx)\r\n File "C:\Users\wladi\.platformio\penv\lib\site-packages\click\core.py", line 1259, in invoke\r\n return _process_result(sub_ctx.command.invoke(sub_ctx))\r\n File "C:\Users\wladi\.platformio\penv\lib\site-packages\click\core.py", line 1066, in invoke\r\n return ctx.invoke(self.callback, **ctx.params)\r\n File "C:\Users\wladi\.platformio\penv\lib\site-packages\click\core.py", line 610, in invoke\r\n return callback(args, kwargs)\r\n File "C:\Users\wladi\.platformio\penv\lib\site-packages\platformio\commands\boards.py", line 31, in cli\r\n return _print_boards_json(query, installed)\r\n File "C:\Users\wladi\.platformio\penv\lib\site-packages\platformio\commands\boards.py", line 80, in _print_boards_json\r\n for board in _get_boards(installed):\r\n File "C:\Users\wladi\.platformio\penv\lib\site-packages\platformio\commands\boards.py", line 75, in _get_boards\r\n return pm.get_installed_boards() if installed else pm.get_all_boards()\r\n File "C:\Users\wladi\.platformio\penv\lib\site-packages\platformio\package\manager\platform.py", line 176, in get_all_boards\r\n for board in self.get_registered_boards():\r\n File "C:\Users\wladi\.platformio\penv\lib\site-packages\platformio\package\manager\platform.py", line 169, in get_registered_boards\r\n "get", "/v2/boards", cache_valid="1d"\r\n File "C:\Users\wladi\.platformio\penv\lib\site-packages\platformio\clients\http.py", line 140, in fetch_json_data\r\n with ContentCache("http") as cc:\r\n File "C:\Users\wladi\.platformio\penv\lib\site-packages\platformio\cache.py", line 36, in enter\r\n self.delete()\r\n File "C:\Users\wladi\.platformio\penv\lib\site-packages\platformio\cache.py", line 132, in delete\r\n with open(self._db_path, "w") as fp:\r\nPermissionError: [Errno 13] Permission denied: ‘C:\\Users\\wladi\\.platformio\\.cache\\http\\db.data’\r\n\r\n============================================================\r\n\r\nAn unexpected error occurred. Further steps:\r\n\r\n Verify that you have the latest version of PlatformIO using\r\n pip install -U platformio command\r\n\r\n Try to find answer in FAQ Troubleshooting section\r\n https://docs.platformio.org/page/faq.html\r\n\r\n Report this problem to the developers\r\n https://github.com/platformio/platformio-core/issues\r\n\r\n============================================================”
That was quick. They’ve answered my question already. Two options 1) snap off daughterboard (it is responsible for holding RX high) or 2) Do all Serial over USB through daughterboard. I’ve tested the second and it works! Simplifies things as I only need a single USB cable! (FTDI is back in the draw). Some more details in link.
Wow ! Many thanks @Owen_Williams I would try this evening. Just another question about the dead time, what value have you put for this board, please ? Because I think the transistors heat up a little bit.
I don’t think you have to worry about deadtime for this particular board. I think the hardware handles that. Take a look at page 8 of the driver L6387ED datasheet
Yes the transistors will get warm - you might get lower losses by reducing PWM frequency to reduce switching losses but you’ll start to get that annoying hum!
Thank you Owen, I tried even to uninstall and install the complete IDE. But I still have the issue…
I someone have an idea, please advice.
Regards Waldemar
You can try deleting the .platformio folder or .cache folder. I think it’ll be safe to do so. This may remove my PRs. I think @Marc_O might have got it working with arduino ide so that is another route to explore.
Hi,
Yes, you are right @Owen_Williams, it is simpler in Arduino IDE, but I also succeed with platformio. @Waldemar Under Arduino IDE, you just have to put the folder DISCO_B_G431B_ESC1 under the ARDUINO15 folder in the variants folder of the STM32 platform with the others, and to copy the boards.txt in current 1.9.0 folder of STM32 platform.