'{$STAMP BS2p} '{$PBASIC 2.5} ' ************************************************************** ' * RoboSpinArt InkArm Test7 * ' * (c) Vern Graner SSE, Texas Information Services * ' ************************************************************** ' * Code operates the a Parallax Serial Servo Controller, * ' * and a Parallax Serial Inkjet Module * ' ************************************************************** ' * Last update 10-3-06 * ' ************************************************************** ' ************************ ' * Conditonal Compile * ' ************************************************************************* #SELECT $STAMP #CASE BS2, BS2E, BS2PE T2400 CON 396 T4800 CON 188 T9600 CON 84 T19K2 CON 32 T38K4 CON 6 #CASE BS2SX, BS2P T2400 CON 1021 T4800 CON 500 T9600 CON 240 T19K2 CON 110 T38K4 CON 45 #CASE BS2PX T2400 CON 1646 T4800 CON 813 T9600 CON 396 T19K2 CON 188 T38K4 CON 84 #ENDSELECT ' ************************ ' * I/O Definitions * ' ************************************************************************* PSC PIN 1 ' Parallax Serial Servo Controller InkJet PIN 3 ' Parallax Serial Inkjet ' ************************ ' * Constants * ' ************************************************************************* ' Baud Rates SevenBit CON $2000 '\ Inverted CON $4000 ' Serial TTL com baud modes used with conditional compile Open CON $8000 '/ 'Parallax SSC settings PSCBaud CON Open + T38K4 ' Parallax Serial Servo Controller InkArm CON 7 'PSC channel for InkArm InkArmRate CON 10 'Seek Speed of servo 0-63 InkArmRetract CON 1100 'Fully retracted to clear bucket (1100 for verticle) InkArmExtend CON 685 'over the bucket for painting 'Inkjet Settings InkBaud CON Open + T9600 Prompt CON ">" ' ready prompt from HP driver STX CON 2 ' start of text ETX CON 3 ' end of text Esc CON 27 ' OEM configuration command 'System Constants True CON 1 False CON 0 ' ************************ ' * Variables * ' ************************************************************************* ' Parallax Serial Servo Controller PSCchannel VAR Nib ' servo 0-15 PSCRate VAR Byte ' servo seek rate 0-64 PSCposition VAR Word ' servo position 250-1250 PSCBuff VAR Byte (3) ' buffer to hold answer from PSC ' loop through button check cntI VAR Byte 'Increment Counter ' System variables PaintShots VAR Byte 'number of paint shots per play PaintTime VAR Byte 'amount of time to play Ticks VAR Byte 'incremented for each loop used for seconds countdown Seconds VAR Byte RunTime VAR Byte (4) 'used by button command Switches VAR Byte '74LS 165 input switches ' ************************ ' * Initialization * ' ************************************************************************* MainProgramStart: ' ************************ ' * Init Servos * ' ************************ DEBUG "Resetting...",CR SEROUT PSC, T2400, ["!SCSBR",1,CR] 'set PSC baud to 38k4 ' ************************ ' * turntable stop * ' ************************ DEBUG "Stop turntable..",CR PSCposition = 765 ' stop=765 fast=1200 PSCchannel = 6 PSCrate = 0 GOSUB MoveServos ' ************************ ' * Extend InkArm * ' ************************ DEBUG "Retract InkArm..",CR PSCposition = InkArmRetract PSCchannel = InkArm PSCrate = InkArmRate GOSUB MoveServos DEBUG "READY", CR PAUSE 2000 ' ************************ ' * Turntable Start * ' ************************ DEBUG "Start the turntable..",CR PSCposition = 200 ' stop=765 fast=1200 PSCchannel = 6 PSCrate = 0 GOSUB MoveServos PAUSE 2000 ' ************************ ' * Extend InkArm * ' ************************ DEBUG "Lower InkArm..",CR PSCposition = InkArmExtend PSCchannel = InkArm PSCrate = InkArmRate GOSUB MoveServos PAUSE 1000 ' ************************ ' * Print Text * ' ************************ DEBUG "Printing...",CR Reset: SEROUT Inkjet, InkBaud, [Esc, "C", 15] ' intercolumn delay 1.5 ms SERIN Inkjet, InkBaud, 500, No_Inkjet, [WAIT(Prompt)] Start: SEROUT Inkjet, InkBaud, [STX] SEROUT Inkjet, InkBaud, ["The Robot Group - First Night Austin 2007 "] SEROUT Inkjet, InkBaud, [ETX] GOTO Printed No_Inkjet: ' not-ready code here DEBUG "Inkjet not responding!",CR Printed: DEBUG "Print complete",CR PAUSE 1000 ' ************************ ' * Turntable stop * ' ************************ DEBUG "Stop turntable..",CR PSCposition = 765 ' stop=765 fast=1200 PSCchannel = 6 PSCrate = 0 GOSUB MoveServos ' ************************ ' * Extend InkArm * ' ************************ DEBUG "retract InkArm..",CR PSCposition = InkArmRetract PSCchannel = InkArm PSCrate = InkArmRate GOSUB MoveServos DEBUG "Done!",CR STOP ' ************************ ' * Subroutines * ' ************************************************************************* MoveServos: SEROUT PSC, PSCBaud,["!SC", PSCchannel, PSCrate, PSCPosition.LOWBYTE, PSCPosition.HIGHBYTE,CR] RETURN