Building Robots with CoachLab II and Tech Card Materials

{this page may load slowly due to a large number of images, please be patient}


Table of Contents


Overview

This page details steps in creating and programming a robot using CoachLab and Tech Card.  The examples given can be used in the classroom or by the hobbyist.

CoachLab is a system for electronic measurement by sensors, and is capable of controlling any zero to twelve volt device using a program that can be controlled by the value of those sensors.  This makes many interesting experiments into robotics possible.  Coach's "Basic" programming language is an excellent tool to teach real world programming skills. Tech Card is a building system using pre drilled and pre scored cardboard, wood, and plastic pieces that can form structural elements and mechanisms.  Tech Card is provided by The Science Source.

Back to the Top of this page


The Assignment (Build a Robot)

Assignment: Build a stationary robot that can rotate a light sensor in a circle covering 270 degrees.  The purpose of this robot is to scan a 270 degree arc parallel to the ground, find the brightest light source in that arc, and lock on to that source moving to follow it if it moves.  The robot should have a "zero" or "home" position at zero degrees and reset to that position when it is first started, and in the event that the robot looses the light source.  The robot must make use of at least one motor, and one light sensor.  It may also be useful to use a rotational motion sensor, or other means to limit its motion to 270 degrees.

The limitation to 270 degrees is to keep the robot from spinning the light senor around and around and tying its cord into a knot.

Design and build your robot in four steps.

    1) Design the physical mechanism

    2) Build the physical mechanism and test it manually (revise as necessary)

    3) Write a program to control the mechanism (should be broken into steps for each behavior)

    4) Test your completed robot and time permitting, improve on your design

Real World Applications of this Design

Notes to Instructors:  This assignment reflects an advanced assignment that could be given to students who had already learned simple programming, use of the CoachLab system, and other robotics principles.  It is intended as an example to you of the various possibilities for technology education that can be presented using CoachLab and Tech Card together.  You might wish to break this assignment down into several mini assignments along with related lectures or materials that could teach each concept individually to ultimately build the robot to complete the full task.  You might also wish to use Coach's three levels of programming to complete make the robot function using pieces of your own code initially and then let students graduate to higher levels of programming as they progress. 

TIP: Let students work in groups of two to four students.  Use cooperative learning techniques to assign each student in the group a particular task.  If grading this activity break up the grading into a points system for each component completed including students team work, written reports, and presentations.

TIP: Using the angular position sensor it is possible to reinforce the concept of positive and negative numbers using a -120 to +120 setting and zeroing the robot at the center (zero degree) point. 

Back to the Top of this page


Building the Robot

Every design for this particular robot may be unique and so there is no "right way" to build it.  As long at it works and meets the specifications for the assignment then it is ok.  The design presented on this page is simply one of many possibilities.  It is a good practice for students to design their robots on paper first and then seek approval from the instructor in order to weed out impossible or time consuming designs.

I choose Tech Card materials from Science Source because they are inexpensive, quick, easy, and safe to work with, and offer flexibility in designing mechanisms while at the same time teaching and reinforcing concepts of structural design. 

Overview of Basic Tech Card Materials

Tech Card materials are made up of recycled cardboard components that are pre punched and scored to form plates and beams that can be put together using pins, clips, or glue.  The system also has shafts, wheels, pulleys, gears, motors, and other components available.  All components can be cut with scissors to match the length needed for a particular design or experiment.  Holes and spacing are calibrated to the metric system.

Clockwise from upper Right
  • Base Plate (3 wide x 5 long x 1 high)
  • C-Beam (unfolded) (1 wide x 10 long x 1 high)
  • C-Beam (folded)
  • L-Beam (unfolded) (1 wide x 10 long x 1 high)
  • L-Beam (folded)
  • Wooden Dowel (4mm shaft diameter)
  • Large Cardboard Wheel/Washer
  • Small Cardboard Wheel/Washer
  • Medium Pulley (also available in large and small)
  • Motor Mounting Clip
  • Motor (3 volt)
  • Base Plate (unfolded)

Close-up of Base Plate (partly folded)

Close-up of Beams (cut to any length needed)

My Design

Structural Design:  I started off by building the structural base for the robot and its mechanisms.  Key to my design process were placement of the motor and sensors, supporting their weight, and keeping the design together and upright as the robot moves its parts (sometimes rapidly).

Materials Required:

To Assemble the Structure:

Fold both of the base plates into their "box" configuration.  Cut and fold four L-Beams to the same length leaving five holes showing. 

Place one base plate upside down on the table top and fix each of the four upright L-beams to it using pins.

Place the bottom base plate (also facing toward the table top) into the L-beams and fix it in the middle position (the 3rd set of holes) using pins.

Place the remaining full length L-beams across the uprights and fix into position using pins.

Mechanism Design: Once the structural design (or base) was assembled I began the design of the mechanism.  Key to this design was the knowledge that I had to keep the design as simple as possible, with as few moving parts as possible, but at the same time I had to find a way to slow down the speed of the motor by gearing it down.  I settled on a pulley system using rubber bands as belts.  The motor and angular position sensor were both fixed to the unit by motor clips held with double sided tape.  Dowel shafts that pass through the top plate and extend through the bottom plate formed the shafts for the pulley and turn table for the sensor.  Finally the sensor was placed onto the turntable by cutting an L-beam, folding it into a solid sheet, and fixing it to the turntable using two dowels and paper clips.

Materials Required:

To Assemble the Mechanism:

Assemble both pulleys using the dowel shafts and pulley pieces. The Step Down pulley has the large pulley wheel on the bottom and the smaller one on top.  The turntable is the opposite and has an extra pulley on top to link to the rotational motion sensor. Slip the dowel shafts through the top and bottom base plates using two small cardboard wheels as washers.

Insert the motor and rotational motion sensor into their motor clips.

Rig the rubber band belts as shown in the picture. 

This design works quite well and can be used for a number of different experiments.

Back to the Top of this page


Robot Building Tips

Instructor Tip: Build economics into your students designs.  Make a price sheet that describes the costs of each component, or the cost of labor to machine (cut or change) a component.  Students can then work out a cost for their design and can also compete on that factor for comparison to other robots, or for grading. 

Back to the Top of this page


Overview of CoachLab Programming

Coach Software uses a version of the 'Basic' programming language in order to control devices, and to teach programming.  The Coach language has the normal compliment of commands and built in functions including the ability to create and call functions and procedures, create modular programs, and pass variables from one program structure to another.  The output of any sensor can be used as a variable to control programs.  Programs can also activate outputs on appropriate hardware such as the CoachLab II interface panel in order to control "actuators" such as motors, lights, buzzers, relays, solenoids, muscle wire, etc. 

The Coach programming environment can be used by students of varying levels of sophistication and computer knowledge.  The Coach software authoring environment lets you create activities for students in which you can pre-define functions, procedures, variables, or sections of code.  In this way it is possible for beginning students to work with blocks of code that they could not yet create themselves and interact with it in order to change components or learn the function or logic behind a particular algorithm.  It is also possible for students or instructors to create their own code entirely from scratch using basic commands. 

Coach Basic does not encourage the "goto" command or other spaghetti coding techniques but instead uses a structure similar to languages such as Pascal.  Programs can be as simple or complicated as desired including performing complicated mathematical manipulations.  The Coach language, following the rules of "basic" also assists students as they enter the real world and begin to program on other systems and languages.

There are four modes of programming available within Coach software.

Manual control mode
Students can read connected sensors and switch actuators on and off  by simple clicking to study their behavior.

Instruction mode
Students can build programs by manually controlling a  model via  'Instruction buttons' on the screen. Each press of a pre-defined button adds a corresponding line of code to the program.  These code lines can then be executed in order as a program.  Students learn that models can be controlled with written commands.

Micro-world programming mode
A micro-world consists of a predefined set of commands tuned to a particular model. Students learn to write control programs by selecting statements from a command list on the screen. Each statement is written in easy to understand script like "Turn_Right"

Advanced programming mode
Experienced students can program freely by choosing commands from a complete list of available Coach Language commands or by typing commands free form. It is also possible to make custom commands and add these to the standard list of programming commands.

Programming in Coach 5

The editor used to write Coach Basic programs has built in syntax checking tools that prompt beginning students for the correct answer to questions and help save time in the classroom.  If simple syntax errors are present in code then the program will alert you to their presence, location, and in many cases how to correct the problem.  This keeps simple typos and other mistakes from taking up the student or teacher's valuable time. 

Coach programs can also be executed within a monitor window.  This helps students understand the flow within a program as well as letting them monitor the value of variables as a program progresses.  This is a powerful debugging tool and helps student spot faulty logic, or infinite loops in no time.   The monitor can be be adjusted to manually step through each line of code, or can execute code in order based on a slider that controls the speed at which the commands are executed. 

Back to the Top of this page


Sample Robot Code

It is not my intention to "give away" the answers to the programming challenges presented by this activity idea.  However I am including some sample code in this page so that you can see some of the ideas and methods that I have used to approach parts of this project.  In particular I am going to focus on the code that centers the robot at zero degrees when the program first starts as well as the other code needed to support that procedure.

The first step is to define two procedures that can turn the motor on and let it spin to the right or to the left (aka clockwise and counter-clockwise.)  Since turning the motors on and off requires a few lines of code it is easiest to define them as procedures so that you can call that procedure by name and avoid re-typing the code over and over in your main program.  It also makes the program modular and lets you make changes to the code in one place vs. many if you decide to change something about how the motors function.

Procedures can be defined in the procedure window which can be accessed in the editor window by placing your pointer between the title bar and the editing area and then pulling the editing area down to reveal the procedure window.

Notes and Information Coach "Basic" Code

Definition of the procedure called "Motor_Right"

Turn on Coach output #1 (apply 3volts)

Wait for 0.15 seconds

Turn off Coach output #1

Wait for 0.15 seconds

End the Procedure

Procedure Motor_Right
  Set(1)
  Wait(0.15)
  Reset(1)

  Wait(0.15)
EndProcedure

 

The first "wait" statement in this code is used in order to send pulses to the motor so that it turns for a finite amount of time and then turns off.  The pulleys in the robot itself will gear down the motor meaning that to turn the turntable one degree will require multiple full rotations of the motor shaft.  The exact amount of time to leave the motor on can be calculated using the gear ratios of the pulleys and determining the motors speed in RPM, or by setting up an experiment using CoachLab itself.   However I simply worked by trial and error to create the appropriate delay time.  The main reason for moving the turn table by only a few degrees with each motor action is to keep the device from constantly overshooting its mark, and to keep it from moving so fast that it looses its belts (rubber bands). 

 

The second "wait" statement in this code is used to give a pause between motor actions when you call multiple motor statements in a row.  In this way the motor will move in nice, evenly timed steps with an even duty cycle.

 

Notes and Information Coach "Basic" Code

Definition of the procedure called "Motor_Left"

Turn on Coach output #2 (apply 3volts)

Wait for 0.15 seconds

Turn off Coach output #2

Wait for 0.15 seconds

End the Procedure

Procedure Motor_Right
  Set(2)
  Wait(0.15)
  Reset(2)

  Wait(0.15)
EndProcedure

 

This second procedure works exactly the same as the first procedure except it turns the motor in the opposite direction.  The CoachLab II interface uses outputs in pairs labeled on the interface itself as "A", "B", "C", and "D".  Each pair has a "1" and a "2"  In the Coach programming environment the outputs are simply indexed by number 1 through 8.  Therefore A1 = 1, A2 = 2, B1=3, C2 = 6, and so on.  If you turn the number one input on then a voltage will appear at that terminal and the system is grounded through the complimentary terminal (#2).  In this way it is possible to control the direction that a motor will spin.

 

Another way to do these procedures and make them even more modular would be to define a variable for the wait time.  For example:

 

Notes and Information Coach "Basic" Code

Define the variable "wait_time" and assign a value of

0.15

Definition of the procedure called "Motor_Right"

Turn on Coach output #1 (apply 3volts)

Wait for "wait_time" seconds

Turn off Coach output #1

Wait for "wait_time" seconds

End the Procedure

wait_time = 0.15

 

Procedure Motor_Right
  Set(1)
  Wait(wait_time)
  Reset(1)

  Wait(wait_time)
EndProcedure

 

In this new example a Variable called "wait_time" has been declared and given an initial value of 0.15 seconds.  By using a variable it is much easier to use trial and error to determine the correct amount of time to leave the motor running because you only need to change the value in one place.

 

As with most other programming languages the code is executed by the computer in the order that it appears on screen.  Because of this it is necessary to define variables and give them initial values before they are called or used by any command, function, or procedure.

 

Since procedures can also accept variables it is also possible to create one piece of code to turn the motor either direction by passing a variable to it for "left" or "right" 

 

Ok... now that we have made our lives easier with the above procedures to control the motor we can now create code that can be used to center the motor now matter where it is pointing when the program starts. 

 

Notes and Information Coach "Basic" Code

Repeat Statement (keep doing until...)

Conditional Statement for input #2 (if true then)

Turn the motor to the left one degree

Finish with that conditional statement

Conditional Statement for input #2 (if true then)

Turn the motor to the right one degree

Finish with that conditional statement

Until the sensor is between 5 and -5 degrees

Repeat
  If Level(2) > 5.1 Then
    Motor_Left
  EndIf
  If Level(2) < -5.1 Then
    Motor_Right
  EndIf
Until (Level(2) < 5) AND (Level(2) > -5)

In this example we wish to center the turntable at zero degrees, and there are many approaches to this problem.  Since the pulleys and belts used in this robot do slip sometimes, and since one pulse to the motor is not necessarily exactly one degree of movement from the turntable it is not possible to simply read the position of the angular position sensor and then turn the motor in the correct direction by an exact number of pulses to get it to the right position.  Instead a more dynamic approach is needed (i.e. one that can accept some variable nature of the mechanism).

The 'Repeat {lines of code} Until (a condition is met)' method is the easiest way to accomplish this task.

In the above code we test the condition of the robot and act upon it accordingly.

Sensor # 2 in this experiment is set up to be the angular position sensor reading between -120 and 120 degrees. Therefore any statements that check the level of (2) will tell you well the robot it pointing.

This code checks the value of the position sensor, if the value is greater than 5.1 degrees then it turns the motor left by one pulse in an attempt to center the motor.  If the value of the sensor is not greater than 5.1 then the computer simply skips to the next line of code after the "EndIf" for that conditional statement.  The second "If" statement does the same as the first, only in the opposite direction.

The entire code block will keep repeating itself over until a the sensor is finally centered between a +5 and -5 range (more precision is not possible due to pulley slippage in the robot itself)

To test this condition we use a compound logic statement in the "Until" command.  Logically when the turntable is pointing the way we want it will be both higher than - 5 degrees AND less than +5 degrees.

Obviously there are other ways to go about this code that use fewer steps but this method might be more obvious to your students if they need some help understanding what goes on.

This code is interesting to watch as the computer executes it by using the monitor window. 

Once you have perfected this code you can make it into a procedure and then call it from your main program.  The you can move on to the complicated programming of setting up the light tracking capabilities. 

Question... Will the following code work???

Notes and Information Coach "Basic" Code

Define a procedure named "Center_Motor"

Define a variable for Postive Limit at 5.0 degrees

Define a variable for Negative limit at -5.0 degrees

Repeat Statement (keep doing until...)

Conditional Statement for input #2 (if true then)

Turn the motor to the left one degree

Otherwise

Turn the motor to the right one degree

Finish with that conditional statement

Until the sensor is between the Positive and Negative limits.

End the procedure

Procedure Center_Motor

 Positive_Limit = 5.0

 Negative Limit = -5.0

 Repeat
  If Level(2) > Postive_Limit Then
    Motor_Left
  Else
    Motor_Right
  EndIf
 Until (Level(2) < Positive Limit) AND (Level(2) > Negative Limit)

EndProcedure

Can you take for granted that if the position is not greater than the positive limit then it is automatically less than the negative limit?  How might you rewrite this code?

 

The HTML help files in the Coach software contain detailed programming information and syntax.  There are also manuals on the Coach CD-ROM as well as available for download.  All rules of normal programming apply to Coach Basic.

 

Back to the Top of this page


Other Uses and Ideas for this Robot

The physical robot described on this page can be used for a variety of experiments.  And since Tech Card materials can be reused it is easy to modify an existing design into a new form.  Since Coach programming language is capable of simple and complicated tasks this means there are lots of ways to make new robots.  Here are a few ideas that teach design, mechanics, and programming skills.

Back to the Top of this page


More Information

 

Download the Coach Control Manual (full details on the Coach Programming Environment)

    [Click Here to Download] (Adobe .pdf format) {464 KB}

 

Download the Guide to the Coach Basic Programming Language. (full details on commands and methods)

    [Click Here to Download] (Adobe .pdf format) {480 KB}

 

Subscribe to our E-mail Newsletter [Click Here for more information]

 

Download a Video Clip of the Robot in Action (.avi windows video) [Click Here] {Warning 7.76 MB!}

 

Learn more about Tech Card [Click Here for more information]

 

Contact us with questions or comments [Click Here to Contact Us]

 

Back to the Top of this page


Rank This Article

 

Please give us feedback about this article, by filling out this anonymous form.  The information you provide will help us to produce better information in the future.

 

[FrontPage Save Results Component]

Please Answer the Following Questions (all fields are optional) and then click "Submit" when you are finished

 

Do you teach Technology Education, Engineering, or Programming

 

Was this article helpful to you?

 

Rank this article on a scale of 1 to 10 (10 being best)

 

Would you like to see more articles about programming and design?

 

Comments or Suggestions

 

Please click "Submit" to submit this evaluation.

Back to the Top of this page


 


Site Design and Content Copyright 2003 Harris Educational (All Rights Reserved)

This site best viewed at 1024 x 768 Resolution

Tested for MS-IE 6.0, Netscape 6.2 and Opera 6.0

Includes Flash (tm) Animation Generated by SWiSH 2.0

If you experience problems viewing these pages please upgrade your browser

Please contact us with any broken links or other viewing problems


Click Here to Return to the Harris Educational Main Site

With Lesson Plans, Free Resources, and Information for Educators and Students

Not Just Probeware! (see below for other pages of interest to educators)

 

Reinventing Science  *  Science Kits  *  Seibun Science Workshops  *  Lesson Plans