Micro-Bot Test Program


 Back To Index

This is the initial test utility program that's pre-programmed into each Micro-Bot for testing after assembly. It tests for proper mechanical assembly, controller operation, servo operation, electrical connections and batteries. It has been compiled with the PicBasic Pro demo version compiler.

Simple routines are the easiest to use for troubleshooting and initial tests. When you fist install batteries in Micro-Bot, and switch power on to both the microcontroller & motors, Micro-Bot will begin to execute this simple test routine.

If you ever need to re-program Micro-Bot with this test utility program, locate the file named First.hex or open & compile the First.bas file on the Micro-Bot CD-ROM. See the Basic Infrared Object Detection & Navigation for details on how the motor control section of this example works.

This is also a good routine to tinker with if you're just getting started with the PicBasic Pro demo compiler.

'****************************************************************
'*  Name    : First.BAS                                         *
'*  Author  : Bruce Reynolds                                    *
'*  Notes   : Micro-Bot Initial Test Program                    *
'****************************************************************
@ DEVICE HS_OSC,MCLR_OFF,LVP_OFF,WDT_OFF,PROTECT_OFF
DEFINE OSC 20    ' We're using a 20MHz crystal

TRISB=%00000000  ' Set PortB TRIS register
PORTB=%00000011  ' LEDs off, pulsout pins set for logic 1 pulse

Loops       VAR BYTE    ' Loop counter
Time        VAR BYTE    ' 
MotorDir    VAR WORD    ' Motor directions for pulsout command
Left_Servo  VAR PortB.4 ' PortB.4 = left servo output
Right_Servo VAR PortB.5 ' PortB.5 = right servo output

Begin:
  FOR Time=20 TO 40      ' Twenty to forty
   MotorDir=$3C50        ' Forward
   GOSUB Move
   MotorDir=$5050        ' Right turn
   GOSUB Move
   MotorDir=$3C3C        ' Left turn
   GOSUB Move
   MotorDir=$503C        ' Backup
   GOSUB Move
  NEXT Time
  GOTO Begin
  
Move:
  FOR Loops = 1 TO Time
   PULSOUT Left_Servo,MotorDir.LowByte*10   ' Compute value for left servo movement & move it
   PULSOUT Right_Servo,MotorDir.HighByte*10 ' Compute value for right servo movement & move it
  PAUSE 20
  NEXT Loops
  RETURN


 Back To Index

Copyright © 2007 Reynolds Electronics
http://www.rentron.com