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

Amphibionics 05  3/24/03  8:44 AM  Page 169
                                       Chapter 5 / Serpentronic: Build Your Own Robotic Snake
                        :1001A000A8009630A9009630AA009630AB00963091
                        :1001B000AC00F020CD2824088C0025088D005520A7
                                                                                   snake-test.hex file
                                                                                   listing (continued)
                        :1001C0000C08A4000D08A5005F302405A60005302A                PROGRAM 5.2
                        :1001D000A2001030A00026088E0004301420080071
                        :1001E0000130AE00640015302E02031825292708BF
                        :1001F0008C008D01063084000430012028088C001A
                        :100200008D01063084000830012029088C008D0102
                        :1002100006308400803001202A088C008D010630D1
                        :100220008400403001202B088C008D0106308400B2
                        :10023000203001202C088C008D0106308400103005
                        :0C02400001200C306420AE0FF2280800F2
                        :02400E00F53F7C
                        :00000001FF

                        The next program will be used to calibrate the infrared sensor so
                        that the robot can safely avoid obstacles. The modulation frequen-
                        cy of the sensor was set using a multimeter when the circuit board
                        was initially built. The software calibration routine will be used to
                        fine-tune the frequency to improve the sensor’s response. The rou-
                        tine works by taking the input from the sensor and then outputting
                        the opposite state to the LEDs. The sensor input value is inverted
                        before being output to the LEDs because the sensor’s output is nor-
                        mally logic 1 (high) when it is not receiving a signal, and switches
                        to a state of logic 0 (low) when a signal is received. This will allow
                        us to visually see how the sensor is responding to the modulated
                        infrared  radiation,  and  then  adjust  the  modulation  frequency
                        accordingly. The program is called ircal-serpent.bas, and is listed
                        in  Program  5.3.  Program  the  PIC  16F84  with  the  corresponding
                        ircal-serpent.hex file listed in Program 5.4 and insert it into the 18-
                        pin socket on the controller board. When the power is turned on
                        and nothing is in front of the sensor, the LEDs should be off. To cal-
                        ibrate the circuit, use a small screwdriver to turn potentiometer R3
                        counterclockwise until the LEDs are on solid. Figure 5.58 shows
                        resistor R3 on the infrared circuit board being adjusted. Once the
                        LEDs are on solid, slowly rotate potentiometer R3 clockwise until


                                                                                                 169
   185   186   187   188   189   190   191   192   193   194   195