MBED maintains all the supported board programming reference at https://os.mbed.com/platforms/
For our board, F411RE, it can be referred at https://os.mbed.com/platforms/st-nucleo-f411RE/
i copy some of the essence here
Converting from Arduino
The Nucleo-F411RE has arduino compatible pinout. However, to use some of library created orginally for Arduino, we need to do some conversion from the arduino code to MBED.
When naming the pin, it is best to use the pin name under "MCU pin without conflict", those in blue colour. However, arduino pin name, LEDs and Buttons, MCU pins connected to other components
are also usable
The table below map the programming code in Arduino to the equivalent in MBED
Type | MBED code | Example | Arduino Code | Example |
---|---|---|---|---|
digital pin definition | refer to https://os.mbed.com/docs/mbed-os/v5.11/apis/drivers.html |
Parameters
| pinMode | |
PWM output | PwmOut | PwmOut led(LED1); |
Parameters
| pinMode(_pin1, OUTPUT);
analogWrite(_pin1, speed); |
digital write |
|
Parameters
| pinMode(_pin2, OUTPUT);
digitalWrite(_pin2, LOW); |
IO Voltage
A check on https://www.st.com/en/evaluation-tools/nucleo-f411re.html reveals that F411RE is 3.3V logic
however, the motor driver board i use MD13s is 3.3V to 5V logic tolerant
Testing
The F411RE provides a user LED, named as "LED1" for its label used in coding (but labelled as LD2 on the board)
To do a simple testing, i use the code snippet as below, where JogForward and JogBackward simple move the bot forward or backward
The LED2 on the F411RE is kept blinking to indicate that it is alive and running
i use the Arduino connector name for the motor function
#include "mbed.h" #include "CytronMotorDriver.h" DigitalOut myled(LED1); CytronMD motorRight(PWM_DIR,D3,D4); //D3==PB_3 for PWM, D4=PB_5 for direction CytronMD motorLeft(PWM_DIR,D5,D7); //D5==PB_4 for PWM, D7=PA_8 for direction void JogForward(); void JogBackward(); int main() { while(1) { //LED blinking to indicate it is running myled = 1; // LED is ON wait(0.2); // 200 ms myled = 0; // LED is OFF wait(0.2); // 200ms JogForward(); JogForward(); JogBackward(); JogBackward(); } }
I use PicoScope 5444D MSO to capture the PWM and direction control pin for both my left motor and right motor. The video shows the LED is blinking, indicating it is alive
An always on powerbank is used to power the Nucleo-F411RE. It is also the final battery to be used for the MCU and sensor
Here is a the PWM and direction capture for left and right motor (look at the digital capture. The analog channel is not used). i create 2 groups, one for right motor, another for left motor
Testing with the Automatic Weeding Bot
After verifying that the PWM and direction pin is providing output, i connect it to the bot and see it running forward and backward