'Bambino-29 SERTXD("B29",CR) 'report program number @4800 '1025 bytes #PicAxe 20M2 #no_data '================================================================= '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. '2.28 PICAXE-20M2 20 2k 18 1-16 1-17 4 28 512 256 512 8 Yes 4 -32 'PICAXE-20M2 circuit board with LEDs off takes 1mA 'PICAXE-20M2 circuit board with LEDs off and servos connected takes 10mA '================================================================= 'Bambino-01 Test eyeLEDs, whiskerLEDs and speaker 'Bambino-02 Test PWM of eyeLEDs 'Bambino-03 Test InfraRed input 'Bambino-04 Test Eye light values 'Bambino-05 Test Whisker light values 'Bambino-06 Play the inbuilt tunes using keys 1 to 4 and beep on 5 'Bambino-07 Set servos to mid position 'Bambino-08 Calibrate servo mid positions and put in EEPROM. 'Bambino-08+ Adjust servo mid positions from Handset and put in EEPROM. 'Bambino-09 Introduce _iStand:- initialise with feet in mid position 'Bambino-10 Set rollby, rollbymax for Roll Right 'Bambino-11 Check rollby, rollbymax for Roll Left 'Bambino-12 Check rollby and rollbymax for rollL, rollR 'Bambino-13 Introduction of _Stand 'Bambino-14 Investigate effect of rollspeed; ' watch roll for all three speeds 'Bambino-15 Investigate effect of rollspeed; ' watch Roll and Stand for all three speeds 'Bambino-16 Check paceFL paceFR; Investigate effect of pacespeed ' Introduction of pulseservos: 'Bambino-17 Check Fd 'Bambino-18 Test Rt, Lt 'Bambino-19 Test Bk 'Bambino-20 Test T2l: TurntoLight: T2d: TurntoDark: Wl: Wd: 'Bambino-21 Creation of sections ACTIONS, BEHAVIOURS, ACTS; ' Introduction of ACT parameter 'Ado' 'Bambino-22 Demo routine + example use of Start1: to flash eyes 'Bambino-23 Walk Fd with obstacles avoidance using eyes from 04, ' introduction of Default behaviour 'Bambino-24 Walk Fd with obstacles avoidance as 23, with Act BT 'Bambino-25 Walk Fd with drop-off avoidance using whiskers from 05 'Bambino-26 rewritten with reading of whiskers as subroutines 'Bambino-27 rewritten with autocalibration of down whiskers 'Bambino-28 Test maximum PWM and hence minimum brightness of eyeLEDs, ' needed in Bambino-29 'Bambino-29 Wait for IR command then do it otherwise WANDER as B24 '----------------------------------------------------------------- Rationale: 'If IR command then do it otherwise walk and avoid '------------------------------------------------- 'Read in an Infra-red command from the TVR010 PicAxe IR-controller. 'And then GOSUB depending on the command. 'For simplicity only the forward looking eye sensors are used. ' 'Turns can be made by stepping forwards then sliding both feet 'or by stepping backwards then sliding both feet. If there is a big 'obstacle it is better to turn and back away which can be done by 'stepping backwards in a turn 'A flag variable f_direction is set to 1 if going forward and to 0 'if going backwards. In turns this controls which way to step. '================================================================= 'modified '-------- 'start 'Fd 'test for direction 'Bk 'test for direction 'Rt 'test for direction 'Lt 'test for direction 'RockAdo 'default behaviour, added Stand 'beep50 'EyesOFF: 'added PWM off 'iA for counter in Acts 'QEwhiskerL: for new names of B0,B1 'QEwhiskerR: for new names of B0,B1 'New '--- 'Rest: with PWM from Bambino-28 for LEDs at minimum brightness => low power consumption 'EyesDimmest: 'f_direction =bit30 '1=Fd, 0=Bk 'SYMBOL iA =B16 'counter for Acts: 'SYMBOL cmnd =B20 '================================================================= '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 Symbol KEY_POWER = 21 'Rest (Sleep is a reserved word) Symbol KEY_UP = 16 'Step Forward Symbol KEY_DOWN = 17 'Step Backward Symbol KEY_RIGHT = 18 'Turn Right Symbol KEY_LEFT = 19 'Turn Left Symbol KEY_BAR = 96 Symbol KEY_TENT = 54 Symbol KEY_VERT_CROSS = 37 Symbol KEY_VCROSS = 37 'synonym for easier coding Symbol KEY_DIAG_CROSS = 20 Symbol KEY_XCROSS = 20 'synonym for easier coding symbol IRkey1 = 0 'RockADo symbol IRkey2 = 1 symbol IRkey3 = 2 symbol IRkey4 = 3 symbol IRkey5 = 4 symbol IRkey6 = 5 symbol IRkey7 = 6 symbol IRkey8 = 7 symbol IRkey9 = 8 Symbol KEY_MINUS = 98 Symbol KEY_0 = 9 Symbol KEY_PLUS = 11 '================================================================= SYMBOL servopace =c.0 'left connector SYMBOL servoroll =c.4 'right connector SYMBOL VoiceLed_ =c.5 'low =>LED on SYMBOL eyeLedL_ =c.2 'low =>LED on SYMBOL eyeLedR_ =b.1 'low =>LED on SYMBOL GwhiskerLedL_ =c.3 'low =>Ground whisker LED on SYMBOL GwhiskerLedR_ =b.3 'low =>Ground whisker LED on SYMBOL eyeR =c.7 'adc SYMBOL eyeL =c.1 'adc SYMBOL GwhiskerL =b.5 'adc Ground whisker Down Left SYMBOL GwhiskerR =b.0 'adc Ground whisker Down Right SYMBOL inIR =c.6 SYMBOL outIR =b.2 SYMBOL tempW0 =W0 SYMBOL temp0 =B0 'initialise,calibrateholewhiskers,QGwhiskerX SYMBOL temp0dark =B0 'QGwhiskerX SYMBOL temp1 =B1 'initialise,QGwhiskerX SYMBOL temp1lit =B1 'QGwhiskerX 'W1 SYMBOL temp2 =B2 SYMBOL temp2diff =B2 SYMBOL B_flags =B3 SYMBOL f_direction =bit30 'stepping direction in turns Fd=1, Bk=0 SYMBOL f_Bfast =bit31 'speed Behaviour 1=use B_fast: SYMBOL Scentre =W2 SYMBOL rollC =B4 '100 is roll to the left, 200 to the right SYMBOL paceC =B5 '100 is left foot back, 200 left foot forward SYMBOL Sat =W3 'current servo positions SYMBOL rollat =B6 SYMBOL paceat =B7 SYMBOL Sto =W4 'desired servo positions SYMBOL rollto =B8 SYMBOL paceto =B9 SYMBOL Sspeed =W5 SYMBOL rollspeed =B10 '4 is too fast, 0 won't move SYMBOL pacespeed =B11 '6 is about max for servos to keep up 'SYMBOL Smoveby =W6 'SYMBOL rollby =B12 '+ve right 15 good for walking 'SYMBOL paceby =B13 '+ve Left foot forward 20@speed 3; 25@speed 1 SYMBOL Light =W7 SYMBOL lightR =B14 'ambient light level Right SYMBOL lightL =B15 'ambient light level Left 'W8 SYMBOL i =B16 '_iStand: SYMBOL spulse =B16 'FOR NEXT counter for servo pulses SYMBOL Ado =B17 'parameter for Acts 'W9 SYMBOL iA =B18 'counter for Acts SYMBOL obstacles =B17 '%1111 bitmap of obstacles '%Lefthole,Righthole,Leftobstacle,Rightobstacle, 'W10 SYMBOL cmnd =B20 '=== Your Bambino ================ SYMBOL rollby =15 '15 good for walking, edit to value in program11 SYMBOL paceby =25 '+ve Left foot forward 20@speed 3; 25@speed 1 SYMBOL sframe =20 'time between servo pulses SYMBOL rollbymax =20 '@speed 3; 25@speed 1 'rollmax absolute max is 40, above that the tilt rods hit the body SYMBOL pacebymax =30 'pacebymax absolute max is 30, above that the tilt rods hit the rear femur 'and the horn screws hit the leg body 'EEPROM DATA SYMBOL DrollC =254 'holds rollC, 100 is roll to the left, 150 is nominal centre SYMBOL DpaceC =255 'holds paceC, 100 is left foot back, 150 is nominal centre '================================= 'RAM DATA 28 - 511 SYMBOL RAMtemp0 =28 'first non variable RAM location SYMBOL RAMtemp1 =29 SYMBOL RAMholedetectR =30 'holds % light level difference for hole SYMBOL RAMholedetectL =31 'holds % light level difference for hole 'If there is close tungsten light then Bambino may need an eye shade 'or a neb to shield the ground from the tungsten light. '================================= 'depending on the sensors obsdetectL and obsdetectR may need to be different SYMBOL obsdetectL =10 '% light level difference for obstacle SYMBOL obsdetectR =10 '% light level difference for obstacle 'whisker LEDs on, 82R 1.414v =>17.2mA @4.02V '================================================================= initialise: 'get values from EEPROM set by program #8 or #8+ READ DrollC,rollC READ DpaceC,paceC SERTXD("rollC=",#rollC," paceC=",#paceC,CR) LOW eyeLedR_ 'make output HIGH eyeLedL_ 'make output GOSUB _iStand 'stand and initialise rollat, paceat initspeed: GOSUB B_fast GOSUB beep150 'so we know Bambino started, leaves VoiceLED on START: Ado =4 'for RockAdo IRIN [50,WANDER],inIR,cmnd 'IRIN with timeout 'if no IR then WANDER else continue GOSUB beep50 'so we know IR received DoIR: 'map keys '0= KEY_UP (16) 'Step Forward '1= KEY_DOWN (17) 'Step Backward '2= KEY_RIGHT (18) 'Turn Right '3= KEY_LEFT (19) 'Turn Left '4= IRkey1 (0) 'RockADo '5= IRkey2 (1) 'whee '6= IRkey3 (1) 'whoa '7= KEY_POWER (21) 'Rest '8= IRkey0 (9) 'WANDER 'trap some other keys, if not one of the above then Start ' 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 LOOKDOWN cmnd,(16,17,18,19,0,1,2,21,9,3,4, 5, 6, 7, 8, 9),cmnd IF cmnd>7 THEN Start ' 0 1 2 3 4 5 6 7 8 ON cmnd GOSUB Fd,Bk,Rt,Lt,RockAdo,whee,whoa,Rest,WANDER IRIN inIR,cmnd 'wait for IR cmnd GOSUB beep50 'so we know IR received, leaves VoiceLED on pause 100 'so beep doesn't run into whee, whoa GOTO DoIR WANDER: obstacles =0 GOSUB EyesOFF QEwhiskerL: READADC eyeL,lightL LOW eyeLedL_ 'eyeL on PAUSE 1 READADC eyeL,temp1lit HIGH eyeLedL_ 'eyeL off temp0 =255 -lightL 'possible change 'find difference as % of possible change temp1 =temp1lit MIN lightL -lightL *100 /temp0 SERTXD(" L%=",#temp1," ") IF temp1paceC AND f_direction=1 THEN GOSUB Fd 'need right foot forward IF paceat>paceC AND f_direction=0 THEN GOSUB Bk 'need right foot forward IF f_Bfast=1 THEN GOSUB beep150 IF f_Bfast=1 THEN GOSUB B_turn GOSUB _LF IF f_Bfast=1 THEN GOSUB B_fast RETURN _RF: 'SERTXD ("_RF") paceto =paceC -paceby FOR spulse=paceat TO paceto STEP -pacespeed paceat =spulse GOSUB pulseservos NEXT spulse RETURN _LF: 'SERTXD ("_LF") paceto =paceC +paceby FOR spulse=paceat TO paceto STEP pacespeed paceat =spulse GOSUB pulseservos NEXT spulse RETURN Stand: 'stand with both feet flat 'SERTXD (" Sd") IF rollat