www.superrobotica.com
Ejemplos de programas
' Listing 1. BASIC Stamp I Program Demonstrating the Mini SSC
' Program: SCAN.BAS (BS1 servo control demo)
' This program demonstrates servo control using the MiniSSC.
' It commands servo 0 slowly and smoothly through its full
' range of travel. To run this program, leave all configuration
' jumpers off the Mini SSC board. Connect:
' BS1 Mini SSC Purpose
' ----- --------- -------------
' pin0 S(in) pin S Serial signal
' Vss S(in) pin G Ground
' Plug a servo into Mini SSC output 0 and connect power as described
' in the manual. Run this program. The servo will slowly scan back
' and forth. Change for/next step values to change servo movement.
SYMBOL svo = 0 ' Use servo 0.
SYMBOL sync = 255 ' Mini SSC sync byte.
SYMBOL pos = b2 ' Byte variable b2 holds position value.
again:
for pos = 0 to 254 step 1 ' Rotate clockwise in 1-unit steps.
serout 0,n2400,(sync,svo,pos) ' Command the Mini SSC.
next pos ' Next position.
for pos = 254 to 0 step -1 ' Rotate counter-clock, 1-unit steps.
serout 0,n2400,(sync,svo,pos) ' Command the mini SSC.
next pos ' Next position.
goto again ' Do it again.
' Listing 2. BASIC Stamp II Program Demonstrating the Mini SSC
' Program: SCAN.BS2 (BS2 servo control demo)
' This program demonstrates servo control using the MiniSSC.
' It commands servo 0 slowly and smoothly through its full
' range of travel. To run this program, install a jumper at
' B on the Mini SSC board; leave all other jumpers off.
' Connect:
' BS2 Mini SSC Purpose
' ----- --------- -------------
' P0 S(in) pin S Serial signal
' Vss S(in) pin G Ground
' Plug a servo into Mini SSC output 0 and connect power as described
' in the manual. Run this program. The servo will slowly scan back
' and forth. Try changing the step values in the for/next loops
' to see the effect on servo movement.
svo con 0 ' Use servo 0.
sync con 255 ' Mini SSC sync byte.
pos var byte ' Byte variable holds position value.
n96n con $4054 ' Baudmode: 9600 baud (BS2-SX, change to $40F0).
n24n con $418D ' Baudmode: 2400-baud (BS2-SX, change to $43FD).
' BS2 program example, continued.
again:
for pos = 0 to 254 step 1 ' Rotate clockwise in 1-unit steps.
serout 0,n96n,[sync,svo,pos] ' Command the mini SSC.
next ' Next position.
for pos = 254 to 0 step 1 ' Rotate counter-clock, 1-unit steps.
serout 0,n96n,[sync,svo,pos] ' Command the mini SSC.
next ' Next position.
goto again ' Do it again.
S310165 Controlador 8 Servos Mini SSC II
11