SBB Micro
Source code for the self-balancing-bike microcontroller unit (Teensy 4.1-based). 🚀️
|
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. | |
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.
#define DEBUG_SAMPLING_FAC 10 |
Sampling factor of data streaming (expressed in units of SAMPLING_TIME).
#define DODEBUG 1 |
Enable or disable debugging (1/0).
#define HEADER 0xFF812345 |
4-bytes header of data packet.
Current selected value is an ovf in float, and thus it is safe.
#define MAX_MISSING_READS 50 |
Maximum consecutive missing readings.
The maximum consecutive missing readings after which the overriding with received signals is disabled.
#define TERMINATOR 0xFF8CABDE |
4-bytes terminator of data packet.
Current selected value is an ovf in float, and thus it is safe.
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.