WW-02 to BrainStem Example
Last Modified: 2006-10-30
find:

basket

Acroname Robotics PDF webpage version WW-02 to BrainStem Example PDF

Related
Products

Product image for BrainStem Moto 1.0 Module
BrainStem Moto 1.0 Module
Product image for Single WW02 Gear Motor Encoder
Single WW02 Gear Motor Encoder
Product image for Solarbotics GM8 Gear Motor
Solarbotics GM8 Gear Motor
Product image for Blue Wheel for Gear Motor
Blue Wheel for Gear Motor
Product image for 4200mAh 6C Battery Pack
4200mAh 6C Battery Pack

Contents

Example setup for interfacing a WW-02 to a BrainStem Moto.

Introduction

In this example, a BrainStem Moto 1.0 module uses a Nubotics WW-02 Wheel Watcher assembly to measure the distance traveled by a DC gear motor.  The WW-02 provides quadrature channel A and channel B outputs, an encoder clock output, and a direction output.  These outputs can be processed to provide speed and distance information.  The WW-02 is designed to mount directly on a Solarbotics GM8 DC gear motor. 

Circuit Schematic

In the following schematic, two digital IO pins on the Moto module which are dedicated to quadrature encoder input handling are connected to the Channel A and Channel B outputs of the WW-02 board.  Power for the board is supplied by a regulated +5V output pin and ground pin on the Moto module.  A Solarbotics GM8 DC gear motor with a WW-02 mounted to it is connected to a Wirz 203 Motor Driver board.  The motor driver board is connected to the PWM and DIR outputs of the Moto module. 

Wiring diagram between the BrainStem Moto and the WW-02.

Source Code

The Moto module has built-in capability for capturing quadrature encoder data.  To enable quadrature input, it is necessary to select a motion control mode that supports encoder input.  The test program configures motor channel 1 to be in PWM mode with encoders enabled.  The Moto board counts 128 ticks per revolution when used with a WW-02 encoder.  After configuring the motor control mode, the program applies 90% power to the motor to make it spin.  In PWM mode, motor power is a two-byte signed value ranging from -32768 to 32767 so a value of 29500 is roughly 90% power.  A loop displays encoder counts every second on the Console application screen. 

Copy the "ww-2.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 program:

steep "ww-2" load "ww-2" 4 0 launch 4 0

This program uses the TEA language which is a subset of ANSI C.  It uses standard TEA libraries.  This example uses Build 22 or later of the BrainStem Console and TEA libraries. 

/* ww-2.tea */ #include <aCore.tea> #include <aPrint.tea> #include <aMotion.tea> #define CHANNEL 1 void main() { int k; // enable PWM output to drive motor aMotion_SetConfig(CHANNEL, aMOTION_MODE_PWMENC, 0); // then apply 90% power to motor aMotion_SetSetpoint(CHANNEL, 29500); // roll along and print Low 2 bytes // of the tick count every second while (1) { k = aMotion_GetEnc32L(CHANNEL); aPrint_IntDec(k); aPrint_Char('\\n'); aCore_Sleep(10000); } }

Additional Notes

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

Revision History:

  • 2005-02-02: Example Created
 

Related Links:

Brainstem Software: Console Overview

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