'Bambino-22 SERTXD("B22",CR) 'report program number @4800baud '598 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 '----------------------------------------------------------------- Rationale: 'StartX (see Manual1 page 61) can be used for multitasking ' here it is used to flash the eyes whilst walking. 'However StartX is not useful for pulsing the servos. 'Also it should be noted that the PicAxe Servo command for pulsing ' the servos as a background task is not reliable for more than ' one servo and causes the servos to judder. 'You will see that whilst Start1 ToggleEyes is running the other Eye ' commands don't work quite as you expect. ' Comment Start1 to see the difference 'Later programs do not use Starts for these reasons '================================================================= 'modified '-------- 'start: 'New '--- 'Beep150 '========================================================== 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 inIR =c.6 SYMBOL outIR =b.2 SYMBOL eyeR =c.7 SYMBOL eyeL =c.1 SYMBOL temp0 =B0 'symbol cmnd =B1 SYMBOL Scentre =W1 SYMBOL rollC =B2 '100 is roll to the left, 200 to the right SYMBOL paceC =B3 '100 is left foot back, 200 left foot forward SYMBOL Sat =W2 'current servo positions SYMBOL rollat =B4 SYMBOL paceat =B5 SYMBOL Sto =W3 'desired servo positions SYMBOL rollto =B6 SYMBOL paceto =B7 SYMBOL Sspeed =W4 SYMBOL rollspeed =B9 '4 is too fast, 0 won't move SYMBOL pacespeed =B10 '6 is about max for servos to keep up SYMBOL i =B11 SYMBOL spulse =B12 'SYMBOL eyeRval =B13 'SYMBOL eyeLval =B14 'SYMBOL eyediff =B15 SYMBOL Ado =B16 '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 '================================= GOTO initialise ' jump round Starts IMPORTANT !!! '========================================================== 'All startX run automatically on PowerOn 'Start0 default main 'Start1 toggle eyes Start1: FlashEyes: GOSUB ToggleEyes 'alter eyeL eyeR so we know program is running PAUSE 100 GOTO FlashEyes '========================================================== 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: 'changed by speed behaviour GOSUB B_fast start: GOSUB beep150 GOSUB ToggleEyes 'alter eyeL eyeR so we know program is running GOSUB Fd GOSUB Fd GOSUB Fd GOSUB Fd GOSUB EyeRon GOSUB Rt GOSUB Rt GOSUB Rt GOSUB Rt GOSUB EyesON GOSUB Fd GOSUB Fd GOSUB Fd GOSUB Fd GOSUB EyeLon GOSUB Lt GOSUB Lt GOSUB Lt GOSUB Lt GOSUB EyesON Ado =12 GOSUB BkAdo GOTO start '----------------------------------------- 'Acts '---- RockAdo: FOR i=1 TO Ado GOSUB _rollR GOSUB _rollL NEXT i RETURN FdAdo: FOR i=1 TO Ado GOSUB Fd NEXT i RETURN BkAdo: FOR i=1 TO Ado GOSUB Bk NEXT i RETURN ToggleEyes: TOGGLE eyeLedR_ 'alter eyeR so we know program is running TOGGLE eyeLedL_ 'alter eyeR so we know program is running RETURN EyesON: LOW eyeLedR_ LOW eyeLedL_ RETURN EyeRON: HIGH eyeLedR_ LOW eyeLedL_ RETURN EyeLON: LOW eyeLedR_ HIGH eyeLedL_ RETURN '----------------------------------------- 'Behaviours '---------- B_fast: pacespeed =6 '6 is about max for servos to keep up rollspeed =3 'half of pacespeed is about right for walking RETURN '----------------------------------------- 'Actions '------- beep150: SOUND VoiceLed_,(150,10) RETURN Fd: SERTXD (" Fd") IF paceatpaceC THEN GOSUB Fd 'need right foot forward GOSUB _LF 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