Sequencing TEA Programs Example
Last Modified: 2006-10-31
find:

basket

Acroname Robotics PDF webpage version Sequencing TEA Programs Example PDF

Related
Products

Product image for Brainstem GP 1.0 Module
Brainstem GP 1.0 Module
Product image for BrainStem Moto 1.0 Module
BrainStem Moto 1.0 Module

Contents

Introduction

A BrainStem GP 1.0 module has a size limit of 1K for executable TEA programs but some tasks may require more than 1K of executable code space.  This example illustrates a technique for sequencing several TEA programs.  This makes it possible to write an application that exceeds the 1K file limit. 

The following example demonstrates how to make a TEA program launch a new TEA program after the current program ends execution. 

Programming Structure

In order to launch a new program, this technique requires a program to trigger a reflex just before it ends execution.  The reflex waits a moment to allow that process to terminate safely.  This frees a TEA process slot.  Then the reflex launches a new program that runs in the free process slot. 

With this technique, the old program and all its data is destroyed.  This "sequential" approach differs from the multi-file technique which makes it possible to call other TEA programs as subroutines.  With the multi-file technique, the state of the calling process is preserved, but a second process slot must be used for the subprogram.  The sequential approach is more efficient for applications that can be divided into well-defined subtasks that have little dependence on one another. 

Flowchart of program execution.
System flowchart for sequencing TEA programs using a reflex.

Source Code - Reflex

The reflex takes the file slot ID as an input parameter.  It writes that ID to a byte in the scratchpad then launches a timer.  When the timer expires, the reflex retrieves the file slot ID and launches a new program.  This reflex is hard-coded to run programs in process slot 0.  The reflex will work with any other application as long as the initial program runs in process slot 0. 

The programming for this example consists of five source files.  The "mr.leaf" file is the source code for the reflex that will be used to launch the next file.  The "mr.bag" file is the compiled reflex.  It should be loaded into the module with the "batch" command. 

This example just prints status messages indicating which programs are active.  It is only intended as a template for sequential TEA file applications.  To run the example, save the source files to your BrainStem aUser directory and enter the following commands in the Console:

Source Code - TEA Files

Source files mr0.tea , mr1.tea , and mr2.tea should be compiled and loaded into file slots 0,1, and 2 respectively.  The mr0.tea program will launch mr1.tea when it ends.  The mr1.tea program will launch mr2.tea when it ends.  The mr2.tea program will launch mr0.tea again when it ends.  The programs trigger the launch reflex by writing to a raw input port with the "aCore_Outportc" routine.  Raw inputs trigger reflexes.  The 0x037D value is the raw input port base address (0x0300) plus 125 (0x7D), the ID for the launch reflex.  The three TEA programs will execute in and endless loop. 

element type not assignedelement type not assigned

Revision History:

  • 2005-09-23: Example Created
 

Related Examples:

One TEA Program with Multiple TEA Files as Subtasks Example

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