| WheelCommander to Brainstem Example Last Modified: 2009-03-25 | | |
| Acroname Robotics | |||
| ![]() 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 ![]() 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.
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>
#deï¬ne DELAY 100
#deï¬ne DISTANCE_INC 100
#deï¬ne 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 speciï¬ed 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 speciï¬ed 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:
| ||||||
Related Links: | |||||||
| 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. |