Stryder14m2_IR: SETFREQ m32 SERTXD("Stryder14IR-1",CR) 'report program number @38400 'derived from Bambino B47 #PicAxe 14M2 #no_data 'Choose #defines '========================================================================================================================= 'PICAXE IC Memory ext I/O Outputs Inputs ADC Memory Starts Polled Resonator ' £ Type pins bytes slot pins Vars. RAM Spad Data Table* Int. def. opt. ' 08M2+ 8 2k-DATA 6 1-4 1-4 3 28 128 256 4 Yes Yes 4 -32 just a newer chip [forum Technical post] '========================================================================================================================= '----------------------------------------------------------------- Rationale: '================================================================= Modified_and_New: Modified: New: '================================================================= Note: 'pin outcmnd and speed Behaviour values only differences from Jet08IR '================================================================= ProgramOverview: 'all IR received commands are translated and passed onto the Arduino. 'no learning is done here. '------------------------------------------ 'function keys '[f|] [f^] [f+] [fx] '------------------------------------------ '------------------------------------------ '================================================================= 'BEHAVIOURS: '[9][1] - "s1" - B_slow: '[9][2] - "s3" - B_medium: '[9][3] - "s5" - B_fast: '[9][4] - "bu-1","bu+2" - B_UStimid: '[9][5] - "bu-2","bu+4" - B_USnormal: '[9][6] - "bu-3","bu+6" - B_USbold: '================================================================= 'REACTIONS: '[+] - "U" - R_Ping: '[-] - "GW" - R_Whiskers '================================================================= 'COMMANDS '[0]-[8] - "0"-"8" '[Power] - "." - end, stop '[f|] - "r" - record '[f+][f+] - "##" - quit '[f+][<] - "#<" - do default '[f+][>] - "#>" - resume '================================================================= 'ACTIONS: '[^] - F '[v] - B '[>] - R '[<] - L '[f+][Power] - H '----------------------------------------- '----------------------------------------- '----------------------------------------- '----------------------------------------- '----------------------------------------- '----------------------------------------- '================================================================= 'MOVEMENTS: '----------------------------------------- '----------------------------------------- '----------------------------------------- '================================================================= 'COMMUNICATION: 'HMI - Human Machine Interface 'beep50 'squak: 'beep255: '================================================================= 'UTILITIES: 'nokey: 'badkey: 'Z: 'do nothing '================================================================= 'SENSE: '================================================================= BambinoCommands: 'using TVR010_PicAxe_IR_controller ' '[KEY_POWER] stops a learned Act and enters Command mode. ' ends modify mode, ends learning ' it can't stop a subroutine Act '[KEY_POWER][KEY_POWER] is Halt '[KEY_POWER][KEY_POWER][KEY_POWER] is Stop/Start ie toggle f_walking (JA only) ' 'Direction Keys '-------------- '[KEY_UP] ie [Fd] Step Forward '[KEY_DOWN] ie [Bk] Step Backward '[KEY_RIGHT] ie [Rt] Step Right '[KEY_LEFT] ie [Lt] Step Left ' 'Function Keys '------------- '[KEY_BAR] ie [f|] enters learn mode to record key presses ' has to be followed by a number key 1-8 ' = the Act to be remembered ' up to 8 Acts can be learned ' learned Acts can call subroutine Acts 'Acts can chain to other Acts, eg Fd,Bk,2 - chain to Act2 'A learned Act which chains itself repeats forever, 'eg [f|][1][Fd][1][POWER] Act1 will do Fd forever '[KEY_TENT] ie [f^] selects subroutine Acts = SAct, ' has to be followed by a number key 1-8 ' plays SActs, SActs play until the end. ' [KEY_LEFT] is Roll Left ' [KEY_RIGHT] is Roll Right '[KEY_VCROSS] ie [f+] modify USawareAt, UStoonear ' [+] set USAwareAt in EEPROM DUSawareAt ' [-] set UStoonear in EEPROM DUStoonear ' [Key_POWER] to quit '[KEY_XCROSS] ie [fX] Dump EEPROM Acts DATA to PC, including Config Data ' 'Act Keys '-------- '[1] to [8] Play an Act '[f^][1] to [f^][8] Play a subroutine Act 'When Recording an Act, ' [1]-[8] record a jump to a new Act ' if [1],[2],[3],[4],[5],[6],[7].[8],[0] are used to jump to ' another Act there is no point in recording more moves because they ' will never be replayed since control is transfered to the new Act, ' just press [KEY_POWER] to end the recording; ' [f^] then [1]-[8] to do and include a Subroutine Act (SAct); ' when the memory slot is full Bambino will beep and recording will end. 'Act8 Autoruns on PowerOn ' On poweron to WANDER do [f|][8][0][Power] ' enter command mode do [f|][8][Power] ' WANDER B_slow do [f|][8][9][1][0][Power] ' run Act1 do [f|][8][1][Power] ' do SAct1 then Act1 do [f|][8][f^][1][1][Power] ' etc 'Act0 is WANDER and cannot be changed ' 'Behaviour Key '------------- '[9] Behaviour mode eg [9][1] set speed slow ' [1] set speed slow ' [2] set speed medium ' [3] set speed fast - default ' [4] set US behaviour to timid ' [5] set US behaviour to normal - default ' [6] set US behaviour to bold ' [7] disable Whiskers test ' [8] disable Ultrasonic test ' [9] set US behaviour to User values set by handset ' [KEY_UP] B_faster: - increase speed ' [KEY_0] B_normal: - normal speed ' [KEY_DOWN] B_slower: - decrease speed ' 'Sensor Keys '----------- '[-] enable and test Whisker sensors and re-act, R_Whiskers: '[+] enable and test Ping sensor and re-act, R_Ping: ' 'Activity Key '------------ '[0] WANDER ' ' 'Quirks '------ ' If you are recording Act1 and press [f|][2] then you will start 'to record Act2 and Act1 will be left without placing an end marker. 'If Act1 is then played the new moves will be played then whatever 'moves remained there from before. 'If you enter record mode but press [POWER] before pressing a valid 'Act key [1] - [8] then until you press [POWER] a second time and 'Bambino's eyes glow dim any commands will be recorded in Act #6. 'There is no room left to correct this! '[KEY_POWER]=21 @32bytes per slot =>$2A0 =>$A0 =160 =32 *5 =slot #6 'If you record [F +] to set USuser and [Power] to finish then record 'more commands they will not play because [Power] will end Play. '================================================================= TVR010_PicAxe_IR_controller: '--------------------------- 'Before use, the transmitter must be programmed with the ‘Sony’ transmit code. '1. Insert 2 AAA size batteries, preferably alkaline. '2. Press ‘S’ and ‘B’ at the same time. S is in the centre of the arrows. ' The top left red LED should light. '3. Press ‘0’. The LED should flash. '4. Press ‘1’. The LED should flash. '5. Press ‘3’. The LED should go out. '6. Press the red power button (top right). '------------------------------------------- 'IRin cmnds using PicAxe controller 'DO NOT PRESS OTHER KEYS 'ie [A] [B] [C] [D] [E] [F] [G] 'They change the Mode and [B] has to be pressed to change back. '[square] [triangle] [()] [L] [X] [backwards F] have no effect and don't send Sony code SYMBOL KEY_POWER = 21 'Sleep SYMBOL KEY_UP = 16 '[Fd] Step Forward [9][Fd]=set vitality Behaviour to faster SYMBOL KEY_DOWN = 17 '[Bk] Step Backward [9][Bk]=set vitality Behaviour to slower SYMBOL KEY_RIGHT = 18 '[Rt] Step Right SYMBOL KEY_LEFT = 19 '[Lt] Step Left SYMBOL KEY_BAR = 96 '[f|] learn an Act, next [key] selects an Act SYMBOL KEY_TENT = 54 '[f^] next [key] selects a Subroutine-Act SYMBOL KEY_VERT_CROSS = 37 'use synonym for easier coding SYMBOL KEY_VCROSS = 37 '[f+] Modify Mode {when routine included} ' [+] set USAwareAt in DUSawareAt ' [-] set UStoonear in DUStoonear ' {[Fd] alter PaceCentre in DpaceC} ' {[Bk] alter PaceCentre in DpaceC} ' {[Rt] alter RollCentre in DrollC} ' {[Lt] alter RollCentre in DrollC} ' { [-][+] to adjust } ' [Key_POWER] to quit SYMBOL KEY_DIAG_CROSS = 20 'use synonym for easier coding SYMBOL KEY_XCROSS = 20 '[fX] transfer EEPROM to PC for including in programs ' -- Subroutine-Act and Commands -- SYMBOL KEY_1 = 0 '[1] [f^][1]=>RockADo [9][1]=set speed slow SYMBOL KEY_2 = 1 '[2] [9][2]=set speed medium SYMBOL KEY_3 = 2 '[3] [9][3]=set speed fast SYMBOL KEY_4 = 3 '[4] [9][4]=set US behaviour to timid SYMBOL KEY_5 = 4 '[5]' [9][5]=set US behaviour to normal SYMBOL KEY_6 = 5 '[6]' [9][6]=set US behaviour to bold SYMBOL KEY_7 = 6 '[7]' [9][7]=disable Whiskers test SYMBOL KEY_8 = 7 '[8]' [9][8]=disable Ultrasonic test SYMBOL KEY_9 = 8 '[9] set Behaviour modes [9][9]=set US behaviour to User SYMBOL KEY_MINUS = 98 '[-] enable & test Whisker sensors and re-act, R_Whiskers: SYMBOL KEY_0 = 9 '[0] WANDER [9][0]=set vitality Behaviour to normal SYMBOL KEY_PLUS = 11 '[+] enable & test Ping sensor and re-act, R_Ping: '================================================================= ASCI_KeyValues: '0 - 21 37 54 96 98 ' Ctrl % 6 ¬ b '================================================================= CommandMapping: ' 0 - 99 direct keys '100 - 199 subroutine Acts '200 - 255 behaviours '================================================================= PIN_MAPPING: SYMBOL outCcmnd =b.5 'JA c.4 SYMBOL inIR =c.3 '----------------------------------------- VARIABLES_and_CONSTANTS: SYMBOL tempW0 =W0 SYMBOL temp0 =B0 'initialise,calibrateholewhiskers,QGwhiskerX SYMBOL temp1 =B1 'initialise,QGwhiskerX 'W1_flags 'SYMBOL =B2 ' SYMBOL B_flags =B3 'bit24 - bit31 SYMBOL f_recording =bit24 'W2 SYMBOL temp2 =B4 'calibrateholewhiskers,QGwhiskerR 'SYMBOL temp3cmnd =B5 SYMBOL Scentre =W3 SYMBOL rollC =B6 '100 is roll to the left, 200 to the right SYMBOL paceC =B7 '100 is left foot back, 200 left foot forward SYMBOL Sat =W4 'current servo positions SYMBOL rollat =B8 SYMBOL paceat =B9 SYMBOL Sto =W5 'desired servo positions SYMBOL rollto =B10 SYMBOL paceto =B11 SYMBOL Sspeed =W6 SYMBOL rollspeed =B12 '4 is too fast, 0 won't move SYMBOL pacespeed =B13 '6 is about max for servos to keep up 'SYMBOL Smoveby =W7 'SYMBOL rollby =B14 '+ve right 15 good for walking 'SYMBOL paceby =B15 '+ve Left foot forward 20@speed 3; 25@speed 1 SYMBOL counters =W8 'SYMBOL i =B16 '_iStand: 'SYMBOL spulse =B16 'FOR NEXT counter for servo pulses SYMBOL oldcmnd =B17 ' 'W9 SYMBOL cmnd =B18 SYMBOL IRcmnd =B18 'cmnd from IRremote SYMBOL Ccmnd =B19 SYMBOL BeHave =B19 'W10 'SYMBOL Apend =B20 'Penultimate end of record slot 'SYMBOL eptr =B21 'pointer to EEPROM 'W11 'SYMBOL Ado =B22 'parameter for Acts 'SYMBOL usdist =B23 'US distance to object 'SYMBOL sframe =B24 'b25 - b27 '================================= '----------------------------------------- 'EEPROM Acts, start addresses '----------------------------------------- 'RAM data addresses 28 - 127 '================================================================= '================================================================= INITIALISE: f_recording =0 '---------------- cmnd =255 'invalid '================================================================= ACTIVITIES: WaitIRcmnd: GOSUB IRgetNewCmnd DoCmnd: SERTXD(CR,">",#cmnd,"=") SELECT cmnd '[POWER],[UP],[DOWN],[RIGHT],[LEFT],[0] CASE KEY_POWER SEROUT outCcmnd,T9600_32,(".") SERTXD(".") f_recording =0 IF cmnd=oldcmnd THEN SEROUT outCcmnd,T9600_32,("H") SERTXD("H") cmnd ="H" ENDIF IF oldcmnd="H" THEN SEROUT outCcmnd,T9600_32,("S") SERTXD("S") ENDIF CASE KEY_UP SEROUT outCcmnd,T9600_32,("F") SERTXD("F") CASE KEY_DOWN SEROUT outCcmnd,T9600_32,("B") SERTXD("B") CASE KEY_RIGHT SEROUT outCcmnd,T9600_32,("R") SERTXD("R") CASE KEY_LEFT SEROUT outCcmnd,T9600_32,("L") SERTXD("L") CASE KEY_0 SEROUT outCcmnd,T9600_32,("0") SERTXD("0") ' GOTO WANDER '[1]-[8] Acts CASE cmnd 0-7 Acts 1-8 Ccmnd ="1" +cmnd SEROUT outCcmnd,T9600_32,(Ccmnd) SERTXD(Ccmnd) '[9] Behaviour CASE KEY_9 SEROUT outCcmnd,T9600_32,("vb") SERTXD("vb") GOSUB IRgetNewCmnd cmnd =cmnd +200 MAX 255 GOTO DoCmnd '[+] do Pingsensor CASE KEY_PLUS Ccmnd ="U" 'Test Ping sensor and act on result SEROUT outCcmnd,T9600_32,("U") SERTXD("U") '[-] do Whiskers CASE KEY_MINUS Ccmnd ="-" 'Test Whiskers and act on result SEROUT outCcmnd,T9600_32,("GW") SERTXD("GW") '[mode|] record CASE KEY_BAR f_recording =1 SEROUT outCcmnd,T9600_32,("r") SERTXD("r") 'do Behaviours CASE >=200 behave =cmnd -200 'cmnd 0 1 2 3 4 5 6 7 8 'keys [1] [2] [3] [4] [5] [6] [7] [8] [9] ON behave GOSUB B_slow,B_medium,B_fast,B_UStimid,B_USnormal,B_USbold,B_noWhiskers,B_noUS,B_USuser '[mode^] subroutine Acts CASE KEY_TENT 'subroutine acts '[mode+] Adjust CASE KEY_VCROSS 'modify 'USawareAt, UStoonear SEROUT outCcmnd,T9600_32,("vb") SERTXD("vb") GOSUB IRgetNewCmnd SELECT cmnd CASE KEY_VCROSS SEROUT outCcmnd,T9600_32,("##") SERTXD("##") 'quit CASE KEY_LEFT SEROUT outCcmnd,T9600_32,("#<") SERTXD("#<") 'run default CASE KEY_RIGHT SEROUT outCcmnd,T9600_32,("#>") SERTXD("#>") 'resume ELSE SEROUT outCcmnd,T9600_32,("H") SERTXD("H") 'halt ENDSELECT '[modeX] Dump 'Remember internal Slots/Acts are 0-7 keys [1]-[8] CASE KEY_XCROSS 'Dump sends DATA to PC, include Config Data END SELECT '------------- oldcmnd =cmnd GOTO WaitIRcmnd '----------------------------------------- WANDER: '================================================================= BEHAVIOURS: '---------- B_faster: 'vitality Behaviour RETURN B_normal: 'vitality Behaviour RETURN B_slower: 'vitality Behaviour 'sertxd("-",#sframe) RETURN B_fast: 'speed Behaviour SEROUT outCcmnd,T9600_32,("s6") SERTXD("s6") 'JA s5 RETURN B_medium: 'speed Behaviour SEROUT outCcmnd,T9600_32,("s4") SERTXD("s4") 'JA s3 RETURN B_slow: 'speed Behaviour SEROUT outCcmnd,T9600_32,("s2") SERTXD("s2") 'JA s1 RETURN B_turn: 'only called if B_fast rollspeed =1 'slow so foot doesn't bounce pacespeed =3 '5@4MHz RETURN B_USbold: SEROUT outCcmnd,T9600_32,("bu-1") SERTXD("bu-1") SEROUT outCcmnd,T9600_32,("bu+2") SERTXD("bu+2") RETURN B_USnormal: SEROUT outCcmnd,T9600_32,("bu-2") SERTXD("bu-2") SEROUT outCcmnd,T9600_32,("bu+4") SERTXD("bu+4") RETURN B_UStimid: SEROUT outCcmnd,T9600_32,("bu-3") SERTXD("bu-3") SEROUT outCcmnd,T9600_32,("bu+6") SERTXD("bu+6") RETURN B_USuser: 'get values from EEPROM set by User with [f+] 'if US distances are valid, overwrite RAM values RETURN B_noWhiskers: RETURN B_noUS: RETURN '================================================================= REACTIONS: '--------- R_Ping: 'react to Ping information RETURN '----------------------------------------- R_whiskers: Qholes: 'holes have priority Qobstacles: ObstacleMemory: AddMemoryToMap: Qfrustrated: ShowMind: Wavoid: RETURN '================================================================= PROGRAMMED_ACTS: '--------------- SUBROUTINE_ACTS: '#rem RockAdo: 'SAct #100 RETURN '#endrem rollR: RETURN rollL: RETURN '--------------------------- 'whee: - HMI '--------------------------- 'whoa: - HMI '--------------------------- BkBkOtMt: 'Bk Bk Ot Mt RETURN '--------------------------- Rest: RETURN '================================================================= ACTIONS: '------- Fd: RETURN _FdL: RETURN '----------------------------------------- BkBk: '----------- Bk: _BkL: RETURN _BkR: RETURN '----------------------------------------- Mt: 'MemoryTurn, turn same way as last time RETURN '----------------------------------------- Ot: 'OtherTurn, turn opposite way to last time RETURN '----------------------------------------- Rt: RETURN '----------------------------------------- Lt: RETURN '----------------------------------------- Stand: 'stand with both feet flat RETURN '================================================================= MOVEMENTS: '--------- _RF: RETURN _LF: RETURN '----------------------------------------- _rollL: RETURN _rollR: RETURN '----------------------------------------- pulseservos: RETURN '----------------------------------------- _iStand: RETURN '================================================================= COMMUNICATION: 'HMI - Human Machine Interface '------------- beep50: RETURN squak: 'because that is what it sounds like beep255: RETURN EyesOFF: RETURN EyesON: RETURN LEDswaitkey: 'eyes dimmest, whiskers off EyesDimmest: RETURN '================================================================= UTILITIES: '--------- IRgetNewCmnd: GOSUB nokey IRIN inIR,cmnd 'Get cmnd RETURN IRgetKey1to8: IRgetAct_cmnd: IRIN inIR,cmnd 'key1 - key8 => 0-7 IF cmnd<8 THEN _IRgetActEnd IF cmnd=KEY_POWER THEN RETURN ENDIF 'quit GOSUB badkey GOTO IRgetAct_cmnd 'repeat until valid act _IRgetActEnd: GOSUB beep50 RETURN nokey: IRIN [50,_nokeyend],inIR,cmnd'IRIN timeout =>return GOTO nokey _nokeyend: RETURN badkey: Z: RETURN '================================================================= SENSE: '----- QEwhiskerL: RETURN QEwhiskerR: RETURN '---------------------------------------- calibrateGwhiskers: RETURN QGwhiskerL: RETURN QGwhiskerR: RETURN '---------------------------------------- setUSawares: RETURN '=================================================================