Debugging

You can easily try do debug your Nucleo code by communicating with it via serial. In order to do so, you can install putty and connect the Nucleo directly to the PC. Check the COM of the device (in device manager) and then open putty, by setting it as follows:

  • Connection type - Serial

  • Speed - 19200

  • Serial line - COMxx

  • Terminal == local-echo - Force on

  • Terminal == Local line editing - Force on

Go to session and then press Open.

Once you started the putty, a sign that everything works is: == the I’m alive message, after that you can try to communicate with it. After each message sent, you have to press Ctrl+M, then Ctrl+J.

../../_images/putty.png
The Nucleo has 3 power states: KL0, KL15 and KL30, all designed as a safety feature:
  • KL0 Nothingis working. whatever command you send or ask from the Nucleo, will be discarted.

  • KL15 Only the interaction with the sensors work, actions like: reading data from IMU, reading data regarding instant consumption, total voltage, autonomy…

  • KL30 Enables also the control of the vehicle. Now, messages like: set speed, set seering angle, set movement duration will work.

The Nucleo has a PowerManager, used to protect your work and to increase your safety. Mainly, it does the following:
  • If the battery drops below 7.2 Volts, it sends via serial a warning about it, it does so every x seconds.

  • If the battery drops below 7.1 Volts, it sends via serial an error, and then the nucleo puts itself into sleep mode.

  • To avoid building each time a battery is changed, it also can receive messages via serial about the capacity of the battery/s connected.

Nucleo expects via serial the following structure:

#command:val1;val2;valx;;\r\n

And, for each command that it receives, it sends back the following structure:

@command:response1;response2;responsex;;\r\n

Where, command identifies the message, values are ended by a ;, while ;\r\n signals the end of the message.

The commands sent are

command

Description

value

Example request

Example response

speeding

Sets the target speed of the

vehicle

signed int Speed [mm/s] (-500,+500)

#speed:60;;\r\n

@speed:60;;\r\n

steering

Sets the target steering of the

vehicle

signed int steer [deg*10] (-230,+230)

#steer:180;;\r\n

@steer:60;;\r\n

braking

Sets the vehicle in brake state

but allows to set the steering

signed int steer [deg] (-23,+23)

#brake:180;;\r\n

@brake:60;;\r\n

battery enable

Enables/Disables publishing total

battery value

bool

#battery:1;;\r\n

@battery:1;;\r\n

instant enable

Enables/Disables instant

consumption value

bool

#instant:1;;\r\n

@instant:1;;\r\n

imu enable

Enables/Disables imu publishing

values

bool

#imu:1;;\r\n

@imu:1;;\r\n

Controlled move

Sets the velocity control duration

i.e. a specific movement for a

period of time

signed int Speed signed int Steer

signed int time [deciseconds] (0,n)

#vcd:80;-130;121;\r\n

@vcd:80;-130;121;;\r\n

kl

Sets the power state of the

nucleo

unsigned int state [0,15,30]

#kl:15;;\r\n

@kl:60,;\r\n

batteryCapacity

Sets the capacity of the battery/s

unsigned int mAh (0,n)

#batteryCapacity:12000;;\r\n

@batteryCapacity:60;;\r\n

resource enable

Enables/Disables resource monitor

publishing

bool

#resourceMonitor:1;;\r\n

@resourceMonitor:1;;\r\n

Information received

type

Example response

Description

Battery level

@battery:7800;;\r\n

Signals the battery level is 7.8V.

Instant consumption

@instant:1;;\r\n

1 mA consumed in the last second(frequency can be modified).

Warning battery level

@warning:0;1;13;;\r\n

possibly 0 hours, 1 minute and 13 seconds until sleep.

Error battery level

@shutdown:ack;;\r\n

Nucleo going into shut down mode.

imu data

@imu:1,2,3,4,5,6\r\n

roll,pitch,yaw (deg) and accelx,accely,accelz (m/s).

Velocity-control-dur

@vcd:0;0;0;;\r\n

The movement has finished.