Page 263 - Amphibionics : Build Your Own Biologically Inspired Robot
P. 263

Amphibionics 06  3/24/03  9:02 AM  Page 242
                                                       Amphibionics
                                          The next program will test the robot leg motors and will ensure that
                                          the motor connector is oriented correctly. Compile motor-test.bas,
                                          listed  in  Program  6.3.  Program  the  PIC  16F84  with  the
                                          motor-test.hex file listed in Program 6.4, and then insert it into the
                                          18-pin socket on the main board. When the power is turned on, the
                                          left leg motor should rotate in a forward direction for 3 seconds,
                                          and then turn off. The right leg motor should then rotate forward
                                          for 3 seconds. The whole sequence will then repeat itself. If either
                                          the left or right leg motors are rotating in the reverse direction dur-
                                          ing this test, then de-solder the wires connected to the offending
                                          motor,  reverse  them,  and  re-solder  the  connections.  If  the  first
                                          motor to run is the right motor, then unplug the motor connector
                                          (JP3), turn it around, and plug it back in. The motors are controlled
                                          by first setting the L298 enable pins high on the desired channels.
                                          The forward or reverse pins for each channel are then set high,
                                          depending on the direction in which you want the motor to travel.
                                          If both the forward and reverse pins are set high, then the chip will
                                          perform a fast motor stop.

                                          '------------------------------------------------------------------------------------------------------------------------------
                      PROGRAM 6.3
                                          '  Name     : motor-test.bas
                      motor-test.bas program
                                          '  Compiler : PicBasic Pro - MicroEngineering Labs
                      listing
                                          '  Notes     : Program to test the leg motors
                                          '------------------------------------------------------------------------------------------------------------------------------

                                          ' PortA set as outputs. pins 0 and 1 inputs
                                          trisa = %00000011


                                          ' PortB set as outputs. pin 1 input.
                                          trisb = %00000001

                                          '------------------------------------------------------------------------------------------------------------------------------
                                          ' initialize variables

                                          include "modedefs.bas"



                      242
   258   259   260   261   262   263   264   265   266   267   268