SBB Micro
Source code for the self-balancing-bike microcontroller unit (Teensy 4.1-based). 🚀️
Loading...
Searching...
No Matches
Debugging

Functions and definitions for debugging. More...

Macros

#define DODEBUG   1
 Enable or disable debugging (1/0).
 
#define HEADER   0xFF812345
 4-bytes header of data packet.
 
#define TERMINATOR   0xFF8CABDE
 4-bytes terminator of data packet.
 
#define DEBUG_SAMPLING_FAC   10
 Sampling factor of data streaming (expressed in units of SAMPLING_TIME).
 
#define MAX_MISSING_READS   50
 Maximum consecutive missing readings.
 

Functions

void start_debug (void)
 Initialize the debug.
 
void do_debug (void)
 Stream and receive signals.
 

Detailed Description

Functions and definitions for debugging.

Definition of the debug functions, variables, and macros. This includes functions to initialize and run the debug. Debug consists of:

The signal streaming and receiving is performed using the HostPort class via USB/serial, with a rate defined by DEBUG_SAMPLING_FAC. 4-bytes header and terminator, defined by HEADER and TERMINATOR, are used to indicate the begin and end of the data packet trasmitted or received. Trasmitted signals are those in the control input ctrl.controlModel_U and output ctrl.controlModel_Y. Received signals are the reference current and throttle, which are used to override the corresponding signals in ctrl.controlModel_Y and to set the drivers. If no signals are received for more that MAX_MISSING_READS times or NaN values are receive for a signal, the corresponding signal in ctrl.controlModel_Y is not overrided. Debug is not active in MTP mode.

See also
debug.h HostPort NAN_VAL MTP

Macro Definition Documentation

◆ DEBUG_SAMPLING_FAC

#define DEBUG_SAMPLING_FAC   10

Sampling factor of data streaming (expressed in units of SAMPLING_TIME).

See also
SAMPLING_TIME

◆ DODEBUG

#define DODEBUG   1

Enable or disable debugging (1/0).

◆ HEADER

#define HEADER   0xFF812345

4-bytes header of data packet.

Current selected value is an ovf in float, and thus it is safe.

See also
HostPort

◆ MAX_MISSING_READS

#define MAX_MISSING_READS   50

Maximum consecutive missing readings.

The maximum consecutive missing readings after which the overriding with received signals is disabled.

◆ TERMINATOR

#define TERMINATOR   0xFF8CABDE

4-bytes terminator of data packet.

Current selected value is an ovf in float, and thus it is safe.

See also
HostPort

Function Documentation

◆ do_debug()

void do_debug ( void )

Stream and receive signals.

Function to stream and receive signals at a sampling rate defined by DEBUG_SAMPLING_FAC. When signals are received, the corresponding signal in ctrl.controlModel_Y is overrided in order to set the driver manually. The function must be called continously at a sampling rate of SAMPLING_TIME.

See also
DEBUG_SAMPLING_FAC SAMPLING_TIME

◆ start_debug()

void start_debug ( void )

Initialize the debug.

Function to initialize the HostPort. It also attaches to the HostPort the objects to trasmit and receive. Receive buffer is initialize with NaN values.

See also
HostPort NAN_VAL