Page 223 -
P. 223

210   Chapter Twelve

                              goto start
                           max2:
                              b2 = 254                 ‘Cap max b2 at 2.54 milliseconds
                              goto start
                           min2:
                              b2 = 75                  ‘Cap min b2 at .75 millisecond
                              goto start

                           ‘Routines for servomotor 4
                           left4:
                              b3 = b3 + 1              ‘Increase the pulse width
                              if b3 > 254 then max3    ‘Maximum 2.54 milliseconds
                              goto start
                           right4:
                              b3 = b3 ­ 1              ‘Decrease the pulse width
                              if b3 < 75 then min3     ‘Minimum .75 millisecond
                              goto start
                           max3:
                              b3 = 254                 ‘Cap max b3 at 2.54 milliseconds
                              goto start
                           min3:
                              b3 = 75                  ‘Cap min b3 at .75 millisecond
                              goto start

                           ‘Routines for servomotor 5
                           left5:
                              b4 = b4 + 1              ‘Increase the pulse width
                              if b4 > 254 then max4    ‘Maximum 2.54 milliseconds
                              goto start
                           right5:
                              b4 = b4 ­ 1              ‘Decrease the pulse width
                              if b4 < 75 then min4     ‘Minimum .75 millisecond
                              goto start
                           max4:
                              b4 = 254                 ‘Cap max b4 at 2.54 milliseconds
                              goto start
                           min4:
                              b4 = 75                  ‘Cap min b4 at .75 millisecond
                              goto start
                           end

                          Figure 12.33 is a photograph of the five­servomotor controller.
                          The robotic arm servomotors can plug right onto the three position headers
                        on the main board. However, to separate the control board from the robotic
                        arm, I used five 24­in servomotor extensions. Once wired, each SPDT switch
                        controls one robotic arm servomotor (see Fig. 12.34).
                          When using the robotic arm, I noticed the arm move too quickly for me to
                        perform fine movements. So to slow it down, I added a delay routine. This fol­
                        lowing program is identical to the above program, with the exception of the
                        delay routine(s).
   218   219   220   221   222   223   224   225   226   227   228