I am trying to get this board working and I have a question.
I added the board to the arduino IDE environment by copying the files from @Owen_Williams and placing it in a new folder. Thanks Owen for already making this files!
After that I installed the STM32Cubeprogrammer.
I can compile the sketch but uploading will not work. It gives the following error:
Serial Port COM3 is successfully opened.
Port configuration: parity = even, baudrate = 115200, data-bit = 8,
stop-bit = 1.0, flow-control = off
Timeout error occured while waiting for acknowledgement.
Timeout error occured while waiting for acknowledgement.
Error: Activating device: KO. Please, verify the boot mode configuration and check the serial port configuration. Reset your device then try again...
So to be sure I updated the ST link software of the daughterboard to version “V2J37M26”. Still no succes.
Looking at the error, it looks like the board is not in bootmode or maybe even does not have a bootloader for arduino installed? I downloaded the STM32 ST link utility and think that I need to install a bootloader like this one. I am not totally sure about the pin because I can’t find it on the datasheet so I first wanted to ask if I am on the correct path of configuring this board, or did I forget something or is this last part not necessary?
I’ve never programmed it using Arduino but recall that someone else has in another thread. I use platformio which installs the tool chain for you. I.e. i didn’t install st link utility myself, it happened automatically. There are no boot/reset buttons so it’s not that.
I guess you know that this board is programmed through usb port. I am using the stlink upload protocol.
I could probably help if you tried to use platformio.
On Aliexpress are a lot of double-shaft motors, designed for scooters or bikes. I was specifically looking for a single-shaft motor because I want to build a small quad/ATV/car. So my requirement was to have a nice looking ‘rim-like’ outside and the opposite side with the shaft must have a mounting for a disk brake. I was surprised to find only one supplier. This one.
They allow to choose 500/800W with/without disk brake and single/double shaft.
All the others (e.g. from QSMotor) seem really good, but are > 1000W or even 10 to 15kW and then cost > 400€.
I installed platform IO and checked that the basics are working with the nucleo 64 board.
I added your files (ldscript.ld PeripheralPins.c PinNamesVar.h variant.cpp variant.h) to the %HOME%/.platformio/packages/framework-arduinoststm32/variants/DISCO_B_G431B_ESC1/ location.
Updatet boards.txt in the following location: %HOME%/.platformio/packages/framework-arduinoststm32/boards.txt
Added the json file to %HOME%/.platformio/platforms/ststm32/boards/disco_b_g431b_esc1.json
Now I can compile and upload a sketch . The lights are flickering when uploading so I think that everything goes well there.
The only thing that I am not sure about is that there is actually a code running because I have no serial connection over the usb. I saw your video on youtube (really useful BTW) and added the following code to the plaformio.ini file:
But the serial will not work even with this code added. I am also doubting that the code is even running because with a simple open loop code, the motor will not run (used the following PWM setup: BLDCDriver6PWM driver = BLDCDriver6PWM(PHASE_UH, PHASE_UL, PHASE_VH, PHASE_VL, PHASE_WH, PHASE_WL);. But without serial programming is really difficult.
Did I forget a step above and do I still need to add something somewhere?
I can verify now that there is indeed code running on the device. I just made a simple LED blink code and configured the pin on PC6 and the led is blinking, so code is running on the device!
But the strange thing is, that when I add just the simple serial begin and serial print line and the build flags, the led stops blinking… So it looks like that serial is preventing the code from running?
Did someone else have the same problem?
Edit: Even stops working after only adding Serial.begin(115200);
To be sure that we are on the same line: We are both talking about serial over usb right?
I tried both things and it does not help. It is weird because it looks like the code completely blocks after putting something about serial (just serial, serial2 and myserial) in the sketch. If for example in the setup the light must blink, and after that start serial, than it will not blink before serial begin. So it looks like it just completely blocks the code. When serial is removed, the light will blink.
For your own ESC: You do not need to do something special right with serial?
I am thinking about what I did different than you in the configuration of the ESC and the only thing I can think of is that I updated the firmware of the st link. So maybe it has something to do with that? I am going to try to put the original firmware on it. I will keep you up to date!
Do you have other suggestions? Or maybe some crucial steps in the configuration that if might have forgotten to do?
Yes I’m using usb to program and print / serial. Do you have anything attached to rx/tx on the board? If so remove them as the rx/tx is shared/used by the daughterboard - it kind of proxies the serial comms using same pins.
Can you trying to remove the new line
Also - are you using platformio to connect to serial? It seems better at ‘finding the right port’ than other tools such as arduino serial monitor.
I can actually debug that board in platformio e.g. go to run > start debugging and put a break point on Serial.begin(). If you can get debugging working, it I may reveal what the issue is. I may have done some funky things with openocd to get debugging working.
Your issue is puzzling. Do you have an #include <Arduino.h> at the top of your main.cpp - this is needed because platformio does not automatically do this for you (unlike Arduino IDE)
You solved it for me! It was the new line… Sorry for wasting your time . I was so used working in C/C++ past time that I forgot the enter sensitivity on python-ish coding languages.
Because I always get great help from this community, I wanted to do something back and make a new topic on this forum with a small guide on how to set up this board. Is it good that I link some of your videos of you in that post?
I’m embarrassed to say I’ve not pushed these tiny boards that hard and haven’t attempted to add heat sinks. I’d be interested to hear what continuous power people can get out of them.
This is not exactly scientific but I tried a power test with this drone kit.
The board’s datasheet has max 6s battery so I fed it 24V from psu and set the voltage_limit=12. My power supply can only manage 5A.
I put the motor into motor.controller = ControlType::angle mode and asked it to hold zero position. By hand, I forced the hoverboard motor clockwise until it reached about 4A from psu. At this point the motor.monitor() was saying that voltage_q was about 6V (hoverboard resistance is quite low). i.e. I was well below my 12v voltage_limit.
The PSU said it was delivering ~100W.
At this power the mosfets temperature (no heatsink apart from my finger!) rose moderately quickly i.e. in about 10s rose to ~50deg and 20s it was too hot to handle (90 degrees).
I’m going to attempt some maths! It’s been 25 years since I last used this stuff - so I’d appreciate someone (maybe @Antun_Skuric) checking my calcs/understanding
As simplefoc was saying voltage_q was 6V, and PSU said 100W.
voltage_q = 6
voltage_peak_2_peak = 12
voltage_avg = voltage_peak_2_peak / pi = 3.8
current = power / voltage = 100 / 3.8 = 26A
Something tells me that I’ve got the above (very) wrong ;). Go easy, it’s been a long while since I studied this!
Anyway, to push these little drivers much above 100W is going to require some decent thermal management.
I’m quite surprised at how much torque you can get out of 100W. I wold struggled to hold the motor for more than 20s.
Also thanks for the calculation. In my opinion, you don’t need to re-calculate the sine-like PWM wave or take the resistance into account. 100W are 100W. So the 25V peak and 4A rms your PSU is showing are also going through at least 2 or at most 4 MOSFETs at the same time. So PWM apart (that’s what rms is for), they see “only” 4A. At least in my opinion. That’s far away from the claimed 40A peak by ST. But also not surprising giving the tiny package.
I don’t know how much an additional heatsink would improve. Any thoughts?! Or maybe also my simplified thinking above is wrong?!