General Commands (See
Example 1) |
Command |
Description |
version |
Returns the GoGoX control's version number |
CommPort |
Defines the COM port to use. Must set this before
initializing the board. |
Initialize |
Opens the COM port. |
ping |
Pings the GoGo board |
CloseComm |
Closes the COM port. |
|
|
Output Port
Commands (See Example 2) |
Command |
Description |
TalkTo (Motor Bits) |
Sets the active motor ports. Each bit in "Motor Bits"
byte defines which port to be active. i.e. TalkTo 5 will set port 1
and 3 (A and C) active, as 5 (base 10) = 0000 0101 (base 2)
Working
with bits. You can calculate this "Motor Bits" value by adding up
the "Bit Value" (shown in the following table) of each port you want to
set active.
Motor |
Bit Number |
Bit Value |
A |
0 |
1 |
B |
1 |
2 |
C |
2 |
4 |
D |
3 |
8 |
E |
4 |
16 |
F |
5 |
32 |
So, for example, if you want to set port A, C, and F active, the
Motor Bits value would be:
1 + 4 + 32 = 37
If you want to set all ports active, the value would be:
1 + 2 + 4 + 8 + 16 + 32 = 63
|
mOn |
Turns on the active ports |
mCoast |
Coasts the active ports. |
mBreak |
Breaks the active ports. Break is useful
when the port is used to control a motor. It stops the motor
immediately. Whereas, coast simply turns of the power, which may allow
the motor to gradually slow down. Please note that Break consumes a lot
of power. So, try not to leave any ports on the break state for too
long. |
mOff |
Turns off the active ports. Off is a macro.
It Breaks for a short time then switches to Coast. |
mThisway |
Sets the polarity of the active ports to "this way" |
mThatway |
Sets the polarity of the active ports to "that way",
which is the opposite of "this way" |
mRd |
Reverses the polarity of the active ports |
SetPower (Power Level) |
Sets the power level of the active output ports. Power
level ranges from 0 (off) to 7 (default). Note that I use PWM (Pulse
Width Modulation) to implement the power level. Thus, the output voltage
does not change. The GoGo board just pulses it. |
|
|
Sensor Commands
(See Example 3,
Example 4) |
Command |
Description |
ReadSensor (Sensor number) |
Gets a value between 0-1023 from the specified sensor
port. |
ReadSensorMax (Sensor number) |
The GoGo board detects and saves the maximum sensor value it sees on
each port. ReadSensorMax() accesses this value on the board. Max value
is reset to 0 after each read. |
ReadSensorMin (Sensor number) |
Similar to ReadSensorMax() but it detects the minimum value instead. |
BurstMode (Sensor bits) |
Turns on burst mode for the sensor ports defined by the
"Sensor bits" byte. The "Sensor bits" value can be calculated
the same way as the "Motor bits" of the "Talk To" command. Please look
at the "Working with Bits" section above. Here is and extended "Bit
Value" table for Sensors.
Sensor |
Bit Number |
Bit Value |
1 |
0 |
1 |
2 |
1 |
2 |
3 |
2 |
4 |
4 |
3 |
8 |
5 |
4 |
16 |
6 |
5 |
32 |
7 |
6 |
64 |
8 |
7 |
128 |
Burst mode tells the GoGo board to continuously
send the selected sensor ports' data. This mode gives a much higher
refresh rate than constantly polling sensor values with the ReadSensor
command. A refresh rate of 29Hz per port was reached in my experiment
with all 8 sensor ports on. Thus, a refresh rate of up to 232Hz (29 x 8)
or higher is
possible when only 1 port is in burst mode. |
SensorBuffer (Sensor Number) |
Sensor Number ranges from 0 to 7 (0 = sensor1) Returns sensor data received in burst mode. When a
sensor port is set to burst mode (with the BurstMode command), the
sensor readings will be stored in a buffer. This function accesses that
buffer.
Note: -1 is returned if no new burst mode sensor data has arrived since
the last read. |