SP03 to BrainStem Example
Last Modified: 2006-10-26
find:

basket

Acroname Robotics PDF webpage version SP03 to BrainStem Example PDF

Related
Products

Product image for Brainstem GP 1.0 Module
Brainstem GP 1.0 Module
Product image for 2600mAh AA NiMH Battery
2600mAh AA NiMH Battery
Product image for Devantech SRF08 Range Finder
Devantech SRF08 Range Finder
Product image for Devantech Speech Synthesizer
Devantech Speech Synthesizer
Product image for BrainStem IIC Cable
BrainStem IIC Cable
Product image for 4X AA Battery Pack w/Connector
4X AA Battery Pack w/Connector

Contents

Test setup for interfacing the SP03 with a SRF08 and BrainStem GP.

Introduction

In this example, a BrainStem GP 1.0 module uses a Devantech SP03 Speech Module to say phrases.  The BrainStem GP 1.0 uses its built in high speed IIC bus to communicate with the speech module.  The module can say one of 30 stored phrases or speak arbitrary text sent via a serial or I2C connection.  A BrainStem Moto 1.0 could also be used to run the example program since it has identical IIC capabilities. 

Circuit Schematic

In the following schematic, one of the 2 IIC headers on the BrainStem is used to interface to the IIC port on the SP03 module.  The other IIC header is connected to a Devantech SRF08 Sonar module.  The IIC headers provide power and ground connections for each device.  This circuit will work using a 4 AA battery pack to power the circuit. 

Wiring diagram between the SP03 and BrainStem.

Source Code - Loading Phrases onto the SP03

One of the first things you may want to do with the SP03 is load some phrases into it's memory.  The Console program (as of Build 13) includes special commands for the SP03 that can be used for loading a set of phrases, speaking a stored phrase, speaking arbitrary text, or adjusting current volume, pitch, and speed settings.  To control the SP03 through the serial port, there must be a text file called "console.config" in the aBinary subdirectory of the BrainStem folder.  That file must contain the following lines of text to disable "BrainStem" mode and enable "SP03" mode:

########################################################################### # filename: console.config ########################################################################### # # baudrate - This determines the serial speed the Console tries to # communicate with devices at. The default Console setting is 9600. baudrate = 38400 # mode - Set the Console application to work in different operational # modes. The default Console setting is to work in BrainStem mode. mode = SP03

With these configuration file settings, the Console will run in SP03 mode and the usual BrainStem features will be disabled.  SP03 mode requires a direct serial connection to the module.  See the Devantech SP03 docs for details.  A set of phrases may be stored in a ".chat" file in the aUser subdirectory of the BrainStem folder.  The following "chat" file contains some lyrics from a ballad about a doomed ocean voyage.  The three numbers preceding each phrase are volume, pitch, and speed settings, respectively.  Volume ranges from 0-7 (0 is loudest).  Pitch ranges from 0-7 (0 is highest).  Speed ranges from 0-3 (0 is slowest).  Each phrase can have different settings.  Save the file as "sp03-1.chat" and enter the following command at the Console prompt to load the phrases via the serial link into the SP03:

0 4 3 "just sit right back" 0 4 3 "and youl hear a tale" 0 4 3 "a tale of a fate full trip" 0 4 3 "that started from" 0 4 3 "this tropic port" 0 4 3 "aboard this tiny ship" 0 4 3 "the mate was a mitey sailor man" 0 4 3 "the skipper brave and sure" 0 4 3 "5 passengers set sail that day" 0 4 3 "for a 3 hour tour" 0 4 3 "a 3 hour tour" 0 4 3 "the wether started getting ruf" 0 4 3 "the tiny ship was tossed" 0 4 3 "if not for the corridge" 0 4 3 "of the fearless crew" 0 4 3 "the minnow would be lost" 0 4 3 "minnow would be lost"

Source Code - TEA Program to Launch Stored SP03 Phrases

Now that the phrases are loaded, it is time to try some TEA programs.  These examples use Build 13 or later of the BrainStem Console. 

Close the Console application and comment out the lines of text in the "console.config" file.  Commenting out setting values makes the application use it's default setting values.  Be sure to comment out the mode and baudrate settings by inserting a # character on each line as shown:

########################################################################### # filename: console.config ########################################################################### # # baudrate - This determines the serial speed the Console tries to # communicate with devices at. The default Console setting is 9600. # baudrate = 38400 # mode - Set the Console application to work in different operational # modes. The default Console setting is to work in BrainStem mode. # mode = SP03

The following program uses the TEA language which is a subset of ANSI C.  It is compiled using the BrainStem Console by entering the steep command. 

This program utilizes the TEA library for handling the Devantech SP03 Speech Module.  The aSP03_SpeakString routine is used to say an introductory message.  Then a loop cycles through the 30 messages stored in the module.  If they are blank, the module will say skip them.  The looping routine uses the aSP03_SpeakPhrase routine to say a stored message.  The aSP03_WaitForCompletion routine makes the program pause until a phrase is completed. 

/* sp03-1a.tea */ /* recites the stored phrases */ #include <aSP03.tea> void say_phrase(char x) { aSP03_SpeakPhrase(x); aSP03_WaitForCompletion(); } void say_all() { char i; for (i=1; i<=30; i++) { say_phrase(i); } } void main() { aSP03_SpeakString(0,5,3,"these are my stored phrases"); aSP03_WaitForCompletion(); say_all(); }

Source Code - Arbitrary SP03 Input

Stored phrases are convenient for common messages.  For a robot, some examples are "ouch", "hello master", or "my batteries are low".  Arbitrary text may be combined with stored phrases to give a robot an impressive vocabulary.  As mentioned earlier, some creativity may be required to get the best performance from the text-to-speech algorithm.  For example, "robot" will be pronounced as "robit".  Breaking the text into two words, i.e.  "ro bot" provides a more standard pronunciation.  Some words may need to be misspelled to get a proper pronunciation.  The conversion for "beeyootiful" sounds better than the conversion for the correctly spelled "beautiful".  For numbers, the module is quite good at figuring out how to pronounce them properly.  The text "142" is automatically converted to "one hundred forty-two".  This powerful feature is demonstrated in the following program. 

This program demonstrates how the speech module can provide spoken feedback of numeric data.  It also demonstrates the flexibility of the IIC bus.  The program has a loop that takes sonar readings and says the current reading.  The program includes the TEA library for handling Devantech SRF08 Sonar Rangers.  The SRF08 ranger also has an IIC interface.  It must be configured with an address of 0xE2 for use with this particular program.  The address of the speech module is hard-wired to be 0xC4. 

/* sp03-1b.tea */ /* speaks value of sonar readings */ #include <aCore.tea> #include <aSP03.tea> #include <aSRF08.tea> void main() { int r; aSP03_SpeakString(0,4,3,"now I will give sonar readings"); aSP03_WaitForCompletion(); while (1) { r = aSRF08_RangeInt((char)0xE2, aSRF08_INCH); aSP03_SpeakInt(0,3,1,r); aSP03_WaitForCompletion(); aSP03_SpeakString(0,4,3,"inches"); aCore_Sleep(20000); } }

Revision History:

  • 2002-10-31: Example Created.
 

Related Links:

BrainStem Console Getting Started Guide for Devantech SP03 Connections

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.