| gMonitorMoto.tea | Index |
Overview
The gMonitorMoto.tea file contains the source code for the monitor process that runs in the Moto 1.0 processor. This program controls front and side IR ranger sensing, responses to the downward-looking proximity detectors, responses to IR communication signals, and stall sensing.
Initialization
The Moto monitor is launched by the GP monitor. The GP monitor is configured to launch at power-up so after a brief delay both monitors will be active after power-up. The Moto monitor initialization routine default settings to the control RAM and reconfigures any digital IO pins that do not use default settings.
The Main Loop
After initialization, the main loop starts. The loop remains in an idle state until a primitive writes a non-zero value to the aGARCIA_MOTO_PADB_MONENABLE control RAM location. Then the loop repeatedly calls routines to check for sensor detections and stall conditions. Results of these checks are written to the aGARCIA_MOTO_PADS_STATUS control RAM location. A non-zero value in this location signals a primitive to terminate execution. Then the primitive can disable the monitor and the loop will return to the idle state.
Sensor Control
The monitor_sensors routine monitors the front and downward-looking IR rangers. It also checks for incoming IR communication signals and a signal from the GP processor that indicates a rear sensor detection. Bit flags in the aGARCIA_MOTO_PADB_EXEFLAGS and aGARCIA_MOTO_PADB_ENDFLAGS scratch pad bytes determine which sensors are actually checked.
The main monitor loop calls the monitor_sensors routine several times a second. If a sensor detection occurs, the routine writes a code corresponding to the type of detection into the aGARCIA_MOTO_PADS_STATUS control RAM location. Once this status byte has been written, the monitor_sensors routine does not perform any more sensor checks until the status byte is cleared.
The following control RAM locations are used to control the behavior of the sensor monitoring routine.
| Control RAM | Function |
|---|---|
| aGARCIA_MOTO_PADB_ENDFLAGS | Flags for controlling which sensors to check to determine end of primitive execution. |
| aGARCIA_MOTO_PADB_EXEFLAGS | Flags for controlling additional aspects of primitive execution. |
| aGARCIA_MOTO_PADB_GPSTAT | Receives status of rear sensor check from GP processor. |
| aGARCIA_MOTO_PADS_FRONTTHR | Threshold for front sensor detections. |
| aGARCIA_MOTO_PADS_STATUS | Contains status result for sensor check. |
Stall Sensing
The monitor_pid_stall routine checks for stalls, which are conditions that indicate the PID motor control loops are having trouble maintaining desired settings. Due to the nature of stall sensing, it takes some time for a stall to be detected reliably so stall conditions are checked at a slower rate than than sensor detections. A separate Stall Sensing page discusses the details of stall detection in the Garcia robot.