'Bambino-24 SERTXD("B24",CR) 'report program number @4800baud '631 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 '----------------------------------------------------------------- Rationale: 'Walk Fd with obstacles avoidance from 23 '-------------------------------------------------- 'Simply stepping backwards if there are obstacles to the right and left 'as in #23 is not very useful. 'Here is introduced BT (BackTurn) which steps back twice and then turns. '================================================================= 'modified '-------- 'Walk: BT instead of Bk 'New '--- 'BT Back Back and Turn right '================================================================= 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 whiskerLedL_ =c.3 'low =>whisker LED on SYMBOL whiskerLedR_ =b.3 'low =>whisker LED on SYMBOL eyeR =c.7 SYMBOL eyeL =c.1 SYMBOL inIR =c.6 SYMBOL outIR =b.2 SYMBOL temp0 =B0 SYMBOL eyelit =B0 SYMBOL temp1 =B1 'b2 SYMBOL B_flags =B3 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 =B11 '4 is too fast, 0 won't move SYMBOL pacespeed =B12 '6 is about max for servos to keep up SYMBOL i =B13 '_iStand: Acts: SYMBOL spulse =B14 SYMBOL lightL =B15 'ambient light level Left SYMBOL lightR =B16 'ambient light level Right SYMBOL eyediff =B17 SYMBOL obstacles =B18 '%11 bitmap of obstacles %LeftRight SYMBOL Ado =B19 'parameter for Acts '=== 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 '================================= 'depending on the sensors obsdetectL and obsdetectR may need to be different SYMBOL obsdetectL =10 '% light level difference for obstacles SYMBOL obsdetectR =10 '% light level difference for obstacles '================================================================= 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 START: obstacles =0 GOSUB EyesOFF QEwhiskerL: READADC eyeL,lightL LOW eyeLedL_ 'eyeL on PAUSE 1 READADC eyeL,eyelit HIGH eyeLedL_ 'eyeL off temp1 =255 -lightL 'possible change 'find difference as % of possible change eyediff =eyelit MIN lightL -lightL *100 /temp1 SERTXD(" L%=",#eyediff," ") IF eyediffpaceC THEN GOSUB Fd '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