' ============================================================================== ' ' File...... GaitPIC-Template.bsp ' Purpose... General code template for using the GaitPIC-Nomad ' Author.... (C) 2006 Steven R. Norris -- All Rights Reserved ' E-mail.... norris56@comcast.net ' Started... 06/29/2006 ' Updated... 07/05/2006 ' ' {$STAMP BS2p} ' {$PBASIC 2.5} ' ' ============================================================================== ' ------------------------------------------------------------------------------ ' Program Description ' ------------------------------------------------------------------------------ ' ------------------------------------------------------------------------------ ' Revision History ' ------------------------------------------------------------------------------ ' 0627a - First version ' ------------------------------------------------------------------------------ ' I/O Definitions ' ------------------------------------------------------------------------------ Piezo PIN 0 ' Piezo Speaker ' GaitPIC interface Pin_GpBusy PIN 8 ' Busy Pin_GpStop PIN 9 ' All stop Pin_GP PIN 10 ' Serial commands ' ------------------------------------------------------------------------------ ' Constants ' ------------------------------------------------------------------------------ ' GaitPIC baud rate Gpbaud CON 45 ' 38400 baud ' Servo positions Center CON 750 Raise CON 600 Lower CON 300 LiftRamp CON 7 HorzRamp CON 8 FootRamp CON 8 ' ------------------------------------------------------------------------------ ' Variables ' ------------------------------------------------------------------------------ Gait VAR Byte Direction VAR Byte Speed VAR Byte GaitCount VAR Byte Servo VAR Byte ServoAddr VAR Byte Position VAR Word Ramp VAR Byte counter VAR Byte ' ------------------------------------------------------------------------------ ' EEPROM Data ' ------------------------------------------------------------------------------ ' ------------------------------------------------------------------------------ ' Initialization ' ------------------------------------------------------------------------------ ' Define initial state of all pins OUTS=%0000000000000000 ' FEDCBA9876543210 DIRS=%0000011000000001 '1=Output HIGH Pin_GpStop HIGH Pin_GP PAUSE 2000 ' Flush the GaitPIC's receive buffer GOSUB FlushIt ' Home LOW Pin_GpStop GOSUB HomeIt PAUSE 3000 ' ------------------------------------------------------------------------------ ' Program Code ' ------------------------------------------------------------------------------ Main: ' Your code goes here! DO LOOP STOP END ' ------------------------------------------------------------------------------ ' Subroutines ' ------------------------------------------------------------------------------ FlushIt: SEROUT Pin_GP, GpBaud, [0,0,0,0,0,0,0,0,$FF] RETURN WalkIt: SEROUT Pin_GP, GpBaud, ["!w",Gait,Direction,Speed,GaitCount,$FF] DO WHILE Pin_GpBusy = 1 LOOP RETURN StopIt: SEROUT Pin_GP, GpBaud, ["!s",$FF] DO WHILE Pin_GpBusy = 1 LOOP RETURN HomeIt: SEROUT Pin_GP, GpBaud, ["!h",$FF] DO WHILE Pin_GpBusy = 1 LOOP RETURN