Skip to content

[03] Mini Control Board X3

Features:

  • Bluetooth connectivity
  • 4 DC motor channels
  • 2 servo motor channels
  • 12 LED bar

Arduino example: X3_FBI_LedBlink.ino

TotemModule module(03);

Module image

Module commands

Before start

• Install programming environment by following tutorial on Arduino setup.
• Join our community forum for any questions: https://forum.totemmaker.net.

Command naming convention

Some commands controls various channels (A, B, C, ...). There is a logic behind command naming for flexibility:
write("commandA", 10) - will set value 10 for individual channel A.
write("commandAll", 100) - will set value 100 for all existing channels.
write("commandABCD", 10, 20, 30, 40) - will set individual values for A, B, C, D channels.
write("commandABC", 10, 20, 30) - will set individual values for A, B, C channels.
Only commands listed in "Module commands" will be accepted. Other variations will be discarded.
All commands are case sensitive! Calls like CommandA, COMMANDa, motorA/BRAKE will be ignored.

Configuration

Commands starting with "cfg" retains it's value after module power off. Used as module configuration parameters.

cfg/robot/name ( name )

Configure robot name visible during connection.
Parameter:
name - string up to 30 bytes max.
Default: Totem X3-FBI.
module.write("cfg/robot/name", "My robot"); // Set robot name

cfg/robot/model ( model )

Configure Totem robot model (MiniTrooper, Truck, ...).
Used to identify type of the robot. Can be set to any value. Also received with getModel().
Value can be generated with command: TotemModule::hashModel("model").
Parameter:
model - 16bit hash of robot model name [0:0xFFFF].
Default: 0.
// Set robot model to Truck
module.write("cfg/robot/model", TotemModule::hashModel("Truck"));
// Check if robot is Truck
ModuleData data;
if (module.readWait("cfg/robot/model", data) &&
    data.getInt() == TotemModule::hashModel("Truck")) { }

cfg/robot/color ( color )

Configure robot color.
Used to recognize robot appearance by it's color. It may be displayed inside mobile application or on-board RGB LED.
Parameter:
color - 24bit RGB color value (without brightness) [0:0xFFFFFF].
Default: 0.
module.write("cfg/robot/color", 0x0000FF); // Set robot color to BLUE
// Alternative to set individual RGB colors:
module.write("cfg/robot/color", 0, 0, 255); // Set robot color to BLUE

cfg/motorABCD/invert ( onA , onB , onC , onD )

Configure motor output polarity.
Individual motors can be configured to invert it's spinning direction. Allows to fix reversed motor wiring without reconfiguring robot controls.
Parameter:
onA - invert channel A [true:false].
onB - invert channel B [true:false].
onC - invert channel C [true:false].
onD - invert channel D [true:false].
Default: false (off)
// Invert channels A and B. C, B - not inverted.
module.write("cfg/motorABCD/invert", true, true, false, false);

cfg/reset ( )

Reset all module configuration to factory default.
module.write("cfg/reset"); // Reset all module settings to default

DC motor control

motorA ( power )

motorB ( power )

motorC ( power )

motorD ( power )

Set individual DC motor A, B, C, D channel power.
Positive - forward, negative - backward, 0 - stop.
Parameter:
power - channel output power [-100:100]%.
module.write("motorA", 100); // Write channel A

motorABCD ( powerA , powerB , powerC , powerD )

Set DC motor A, B, C, D channels power with a single command call.
Positive - forward, negative - backward, 0 - stop.
Parameter:
powerA - set channel A output power [-100:100]%.
powerB - set channel B output power [-100:100]%.
powerC - set channel C output power [-100:100]%.
powerD - set channel D output power [-100:100]%.
module.write("motorABCD", 100, 50, 0, -100); // Write channels A, B, C, D

Servo motor control

servoA ( position )

servoB ( position )

Set servo motor A, B channels position (-100, 0, 100) = (0°, 90°, 180°).
Parameter:
position - position of servo arm [-100:100].
module.write("servoA", 0); // Set servo channel A to 90° angle

Light bar control

leds ( state )

Control red LED bar.
Each bit in 12bit value represents individual on-board LED. 1 - on, 0 - off.
Parameter:
state - [0b000000000000:0b111111111111].
module.write("leds", 0b110011110011); // Set led bar to: on|on|off|off|on|on|on|on|off|off|on|on

Battery

battery ( )

Get connected battery voltage. This command is read-only.
Returned value is in millivolts. Divide by 1000 to get volts [2.7V:4.2V].
Returns: [2700:4200]mV.
// Read battery voltage
int voltage = module.readWait("battery").getInt(); // Result: 3350 -> 3.350V
// 'readWait' will delay code execution until result is received from the module.
ModuleData data; // Prepare variable to store read result
module.readWait("battery", data); // Perform read with wait until result is received
bool voltage = data.getInt(); // Get battery value from result. 3350 -> 3.350V
// Function that will receive all subscribed commands of module
void onModuleData(ModuleData data) {
    if (data.is("battery")) { // Check if received command is "battery"
        bool voltage = data.getInt(); // Get battery value from result. 3350 -> 3.350V
        Serial.print("Battery voltage = ");
        Serial.println(voltage);
    }
}
void setup() {
    module.attachOnData(onModuleData); // Register onModuleData function
    module.subscribe("battery"); // Subscribe to receive any state change of battery
}