Buy an Axon, Axon II, or Axon Mote and build a great robot, while helping to support SoR.
0 Members and 1 Guest are viewing this topic.
ldiff var wordrdiff var wordlhori var wordrhori var wordlhori = (8 * temp(5)) + 476) 'temp(5) = left joy horizontallvert = (8 * temp(6)) + 476) 'temp(6O = left joy verticalif lhori > 127 then ldiff = 1500 - ((lhori * 8) + 476) rdiff = lhori lservo = lvert + ldiff rservo = lvert - rdiff elseif lhori < 127 ldiff = lhori rdiff = 1500 - ((lhori * 8) + 476) lservo = lvert - ldiff rservo = lvert + rdiffendif'servo pulse code and other stuff (500 to 2500)
bx-24
;PS2 Controller / BotBoard II / SSC-32 ;Tank Differential Steering Algorithm;05/31/09;program status: Successful ;problems: nonepause 1000 'intial pause;PS2 controller constants DAT con P12CMD con P13SEL con P14CLK con P15;-----------------------------index var bytetemp var byte(19)mode var byte;drive and camera servo variablesLservo var wordRservo var wordtiltservo var wordpanservo var wordX var wordY var word;SSC-32 timing variablettm var bytettm = 50;Drive and Camera servo intial positionLservo = 1500Rservo = 1500tiltservo = 1200 panservo = 1526;send intial servo positions to SSC-32SEROUT P11, I38400, ["#0P",DEC Lservo, "#1P",DEC Rservo, "#2P",DEC panservo, "#3P",DEC tiltservo,"T",DEC TTM,13];PS2Inithigh CLKlow SELshiftout CMD,CLK,FASTLSBPRE,[$1\8,$43\8,$0\8,$1\8,$0\8] ;CONFIG_MODE_ENTERhigh SELpause 1low SELshiftout CMD,CLK,FASTLSBPRE,[$01\8,$44\8,$00\8,$01\8,$03\8,$00\8,$00\8,$00\8,$00\8] ;SET_MODE_AND_LOCKhigh SELpause 100low SELshiftout CMD,CLK,FASTLSBPRE,[$01\8,$4F\8,$00\8,$FF\8,$FF\8,$03\8,$00\8,$00\8,$00\8] ;SET_DS2_NATIVE_MODEhigh SELpause 1low SELshiftout CMD,CLK,FASTLSBPRE,[$01\8,$43\8,$00\8,$00\8,$5A\8,$5A\8,$5A\8,$5A\8,$5A\8] ;CONFIG_MODE_EXIT_DS2_NATIVEhigh SELpause 1low SELshiftout CMD,CLK,FASTLSBPRE,[$01\8,$43\8,$00\8,$00\8,$00\8,$00\8,$00\8,$00\8,$00\8] ;CONFIG_MODE_EXIThigh SELpause 1main ;main loop ;-----------PS2 Mode----------low SELshiftout CMD,CLK,FASTLSBPRE,[$1\8]shiftin DAT,CLK,FASTLSBPOST,[mode\8]high SEL;-----------------------------;-----------PS2 Data----------low SELshiftout CMD,CLK,FASTLSBPRE,[$1\8,$42\8]shiftin DAT,CLK,FASTLSBPOST,[temp(0)\8,temp(1)\8,temp(2)\8,temp(3)\8,temp(4)\8,temp(5)\8,temp(6)\8,temp(7)\8,temp(8)\8, |temp(9)\8,temp(10)\8,temp(11)\8,temp(12)\8,temp(13)\8,temp(14)\8,temp(15)\8,temp(16)\8,temp(17)\8,temp(18)\8]high SEL;-----------------------------X = temp(5) + 1372 'left horizonial joystick data inputY = temp(6) + 1372 'left vertical joystick data input Lservo = 1500 'if no data inputRservo = 1500 'if no data input'foward if Y < 1499 and X = 1500 then Lservo = Y Rservo = 3000 - Y 'backwardelseif Y > 1501 and x = 1500 Lservo = Y Rservo = 3000 - Y 'power spin leftelseif Y = 1500 and X < 1374 Lservo = 1372 Rservo = 1372'power spin right elseif Y = 1500 and X > 1625 Lservo = 1627 Rservo = 1627 'foward left elseif Y < 1499 and X < 1499 Lservo = 1499 - (1499 - X) Rservo = 3000 - Y 'foward right elseif Y < 1499 and X > 1501 Lservo = Y Rservo = 3000 - (1501 + (1501 - X)) 'backward left elseif Y > 1501 and X < 1499 Lservo = 3000 - (1499 - (1499 - X)) Rservo = 3000 - Y 'backward right elseif Y > 1501 and X > 1501 Lservo = 3000 - (1501 + (1501 - X)) Rservo = 3000 - Y endiftiltservo = (4 * temp(4)) + 688 'camera tilt servopanservo = (7 * temp(3)) + 630 'camera pan servo;send data to SSC-32 SEROUT P11, I38400, ["#0P",DEC Lservo, "#1P",DEC Rservo, "#2P",DEC panservo, "#3P",DEC tiltservo,"T",DEC TTM,13] goto main