B-G431B-ESC1 Discovery kit info

Hi all,

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! :slight_smile:

After that I installed the STM32Cubeprogrammer.

I can compile the sketch but uploading will not work. It gives the following error:

     -------------------------------------------------------------------
                   STM32CubeProgrammer v2.6.0                  
  -------------------------------------------------------------------

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?

Greetings,

Wittecactus

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.

@nurnware looks like cool project. Can you please link to motors you are using? I am looking for some powerful BLDC hub motors around 500 watts.

Thanks.

Thanks for confirming that, Owen. I thought so. I ordered the DRV8302 in Aliexpress instead. This board should work, especially with heatsink.

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€.

This is it spnning
spinning

1 Like

Hi @Owen_Williams,

As always thanks for the fast reply!

I installed platform IO and checked that the basics are working with the nucleo 64 board.

After that:

  • 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 :slight_smile:. 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:

build_flags =
-D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
-D PIO_FRAMEWORK_ARDUINO_NANOLIB_FLOAT_PRINTF
-D PIO_FRAMEWORK_ARDUINO_USB_HIGHSPEED_FULLMODE

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?

Greetings,

Wittecactus

Can you show me your platformio.ini. if your
monitor_speed = 115200 doesn’t match Serial.begin(115200); then nothing will print out.

You are putting your code in src/main.cpp, right? How about just starting with a couple of print statements before uploading anything more complex

Hi @Owen_Williams,

My platformio.ini file:

[env:disco_b_g431b_esc1]
platform = ststm32
board = disco_b_g431b_esc1
framework = arduino
monitor_speed = 115200

build_flags =

    -D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
    -D PIO_FRAMEWORK_ARDUINO_NANOLIB_FLOAT_PRINTF
    -D PIO_FRAMEWORK_ARDUINO_USB_HIGHSPEED_FULLMODE

lib_deps=
askuric/Simple FOC @ ^2.0.2
SPI
Wire 

Yes I am putting the code in src/main

Src

I also tried simpler code but it just will not print anything, even when using an other serial reader. So I am doubting that even something is running?

Thanks for your suggestions.

Greetings,

Wittecactus

Good news everyone!

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);

Couple of things to try.

  1. Use Serial2.begin(115200) and Serial2.print. put a delay(1000) after begin.

On this board Serial is supposed to be a symbolic link to Serial2

  1. Try to declare use your own serial
HardwareSerial myserial(USART2_RX, USART2_TX);
setup() {
myserial.begin(115200);
delay(1000);
myserial.print("please print out!");
....

Might need to check i got rx/tx order right in args

Hi @Owen_Williams,

Thank you for your suggestions!

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?

Greetings,

Wittecactus

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

build_flags =

    -D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC

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)

Hi @Owen_Williams,

You solved it for me! It was the new line… Sorry for wasting your time :grimacing:. 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?

Greetings,

Wittecactus

More than happy! I’m glad that I could help. Did you try the debug? I’ve not heard of anyone else getting it to work.

Hi @Owen_Williams,

I did not try debugging! I am not really familiar with that, I am going to try it. I will keep you up to date!

Greetings,

Wittecactus

@nurnware That is nice find and price is reasonable too.

Thanks.

“Let’s say the mosfets are 90% efficient (unlikely)…”

That’s right. Mosfets are much more efficient than that and these little monsters are rated at a whopping 120 Amps.
specs

Welcome @Jan_Donker.
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.

Thanks @Owen_Williams for the test! Really appreciate it.

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?!