gMonitorGP.teaIndex

Overview

The gMonitorGP.tea file contains the source code for the monitor process that runs in the GP 2.0 processor.  This program controls Garcia initialization, logic states for the ranger enable circuits, rear IR ranger behavior, and head button input.

Initialization

The GP monitor is configured to launch at power-up.  It reconfigures any digital IO pins that do not use default settings.  Then it launches the Moto monitor and checks for button input.  If the button is pushed, the GP monitor launches the Moto Demo program.  After the initialization steps, the GP monitor enters an endless loop where it updates the sensor enable outputs and checks the rear IR rangers.

Rear Sensor Control

The check_rear_sensors routine monitors the rear IR rangers.  The aGARCIA_GP_PADB_REARCTRL scratch pad byte controls the operation of this routine.  The aGARCIA_GP_CTR_REARTHR counter contains a 2-byte range threshold.  A primitive that needs to monitor the rear sensors must initialize these two RAM values before beginning a motion.

If the aGARCIA_GP_PADB_REARCTRL control byte is non-zero, the routine checks the rear rangers based on the flags set in the control byte.  If a rear ranger exceeds the range threshold, the routine writes the appropriate error code to the aGARCIA_MOTO_PADB_GPSTAT byte in the Moto processor and clears the aGARCIA_GP_PADB_REARCTRL control byte to disable further checks of the rear rangers.  A new primitive can re-enable rear sensor checks by writing a new value to the control byte.

Control RAM Function
aGARCIA_GP_PADB_REARCTRL Flags for controlling rear sensor check.
aGARCIA_GP_CTR_REARTHR Threshold for rear sensors.
aGARCIA_MOTO_PADB_GPSTAT Receives status of rear sensor check from GP processor.

Sensor Enable Logic

The Garcia robot has circuits that can independently switch the rear, front, side, and bottom IR ranger pairs on or off.  The check_for_mirror_update routine controls the logic states of the sensor enable outputs.  Two RAM bytes control the enable logic.  Changes to the aGARCIA_GP_PADB_MIRRORIO byte will be applied to the sensor enable outputs based on the state of bit flags set in the aGARCIA_GP_PADB_MIRRORMASK byte.  A primitive that needs to enable or disable sensor pairs must write appropriate values to these two RAM values before beginning a motion.

A specific ranger enable circuit may be chosen by picking a particular bit in these two control RAM values.  The following defined values provide indexes for the appropriate bits.

aGARCIA_GP_BIT_ENABLESIDE Index of bit that controls state of enable circuit for the side rangers.
aGARCIA_GP_BIT_ENABLEFRONT Index of bit that controls state of enable circuit for the front rangers.
aGARCIA_GP_BIT_ENABLEREAR Index of bit that controls state of enable circuit for the rear rangers.
aGARCIA_GP_BIT_ENABLEDOWN Index of bit that controls state of enable circuit for the downward-looking proximity sensors.

The aGARCIA_GP_PADB_MIRRORMASK byte uses inverse logic so clearing one of these bits signals a change to the state of the enable circuit for the specified sensor pair.  Changing one of these bits in the aGARCIA_GP_PADB_MIRRORIO byte will change the state of the enable circuit for the specified sensor pair.  Setting the bit will enable the circuit.  Clearing the bit will disable the circuit.  A change in the aGARCIA_GP_PADB_MIRRORIO value will only be applied when the monitor finds a matching inverted bit in the aGARCIA_GP_PADB_MIRRORMASK byte.  Then the monitor will apply the change and clear the aGARCIA_GP_PADB_MIRRORMASK byte.  The aGARCIA_GP_PADB_MIRRORIO will reflect the current state of the enable circuits until it is modified.

The following example shows how to turn on the front ranger pair, disable the side and rear ranger pairs, and leave the state of the bottom ranger enable circuit unchanged.  This example is for a primitive running on the Moto processor.  It must use the gc_write_padb_gp routine to send a command across the network that writes a byte into the GP processor's scratch pad.

Create mask for
sensor enables that will change
mask = ~((1<<aGARCIA_GP_BIT_ENABLEFRONT) |
(1<<aGARCIA_GP_BIT_ENABLESIDE) |
(1<<aGARCIA_GP_BIT_ENABLEREAR));
Create new state value state = (1<<aGARCIA_GP_BIT_ENABLEFRONT);
Update aGARCIA_GP_PADB_MIRRORMASK byte gc_write_padb_gp(aGARCIA_GP_PADB_MIRRORMASK, mask);
Update aGARCIA_GP_PADB_MIRRORIO byte
to apply change
gc_write_padb_gp(aGARCIA_GP_PADB_MIRRORIO, state);

Head Button Input

The check_for_mirror_update routine also checks the state of the head button and writes the result to the aGARCIA_GP_PADB_MIRRORBUTTON byte.  A host application may query this scratch pad byte directly.  A primitive running in the Moto board may check the state of this byte by performing a master-mode read of the scratch pad.


version: 1.0, build n.a.
© Copyright 1994-2012 Acroname, Inc., Boulder, Colorado.  All rights reserved.