WheelCommander to Brainstem Example
Last Modified: 2009-03-25
find:

basket

Acroname Robotics  

Related
Products

Product image for Parallax Cont Rotation Servo
Parallax Cont Rotation Servo
Product image for Nubotics Wheel Commander
Nubotics Wheel Commander

Contents

Differential drive robot with WheelCommander attached.

Introduction

In this example, a BrainStem GP 1.0 module uses a Nubotics WC-132 WheelCommander to command a differential drive robot to drive in a square.  The WC-132 is a motion controller that incorporates closed loop functionality to differentially driven robots when combined with odometry encoders such as the Nubotics WheelWatchers.  A simple 2WD platform consisting of two continuous rotation servo motors, a coaster wheel, and batteries provided a base platform to test the WheelCommander. 

The Nubotics WheelCommander wizard was first run to properly configure the motion controller based on the constructed robot.  This wizard is available at the Nubotics website .  This configuration utility requires the RS232 level be shifted to TTL levels.  This can be accomplished by using an Acroname interface connector. 

These programs use the TEA language which is a subset of ANSI C.  They use standard TEA libraries along with WW-01 Wheel Watcher source files. 

Circuit Schematic

Wiring schematic of the WheelCommander test system.

In the above schematic, a Brainstem GP is connected to the WheelCommander via the I2C bus.  The I2C bus provides both signal and clock lines between the controllers as well as power supply lines to the WheelCommander. 

Source Code

The following TEA program illustrates how to communicate and control the WheelCommander from a across the I2C bus.  As the program starts, the Brainstem sends a request to reset the internally stored registers of the WheelCommander.  Velocity and acceleration values are written to the WheelCommander and then the program begins its loop.  This loop first commands the WheelCommander to drive forward a distance, checks for completion, begins to rotate a bit and then repeat 3 more times.  The status of the WheelCommader can be checked to determine if the motion control is active or not.  This is done by reading the status and comparing it to a bit masked flag.  For more information on this, see the product manual at Nubotics website and check the section on "Status Bit Defintions". 

This example uses Build 23 or later of the BrainStem Console and TEA libraries. 

Note

You can use the GP application to center a modified servo. 

Copy the wc-1.tea file listed below to the aUser subfolder of your brainstem directory.  Next, enter the following commands from the Console to install and run the programs:

steep "wc-1" load "wc-1" 2 0 launch 2 0

If your robot is properly configured, your robot should being traveling in some pattern resembling a square.  You may need to adjust either your settings of the WheelCommander or adjust the macro defined values for distance DISTANCE_INC or angle ANGLE_INC. 

/* WheelCommander Example (wc.tea) */ #include <aCore.tea> #include <aPrint.tea> #include <aWC132.tea> #define DELAY 100 #define DISTANCE_INC 100 #define ANGLE_INC 45 void main() { int distance = 0; int angle = 0; char i = 0; /* counter for loop */ aPrint_String(“Running WC.\n”); /* Set up WheelCommander parameters. */ aWC132_ResetMotion(); aWC132_SetVelocity(20); aWC132_SetAcceleration(50); for (i = 0; i < 4; i++) { /* Move a specified distance */ aPrint_String(“Translating.\n”); distance = distance + DISTANCE_INC; aWC132_SetDistance(0,distance); aWC132_SetAngle(0); aWC132_Go(); /* Spin in a loop until we are done. */ while (aWC132_IsActive()) aCore_Sleep(DELAY); /* Rotate a specified angle */ aPrint_String(“Rotating.\n”); aWC132_SetDistance(0,distance); aWC132_SetAngle(angle + ANGLE_INC); aWC132_Go(); /* Spin in a loop until we are done. */ status = aWC132_GetStatus(); result = status & ACTIVE; while (aWC132_IsActive()) aCore_Sleep(DELAY); } /* End of for loop */ /* Stop the motors */ aWC312_Coast(); } /* End of main */

Additional Resources

The Nubotics website has additional info, FAQs, and pictures on their documentation pages.  They also have example code for other controllers. 

Revision History:

  • 2009-03-06: Fixed new line characters in print string function and changed GetByte functions to plural form. Thanks for finding this Pete Skeggs.
  • 2006-10-26: Fixed Typo that had resitor value wrong
  • 2006-10-26: Put back the code that was needed.
  • 2005-11-10: Example Created
 

Related Links:

Using an Omni-directional Wheel as a Caster Idea

Brainstem Software: Console Overview

voice: 720-564-0373, email: sales@acroname.com, address: 4822 Sterling Dr., Boulder CO, 80301-2350, privacy
© Copyright 1994-2012 Acroname, Inc., Boulder, Colorado. All rights reserved.