euromicro 80: micromouse competition

5

Click here to load reader

Post on 21-Jun-2016

220 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Euromicro 80: Micromouse competition

Euromicro 80: Micromouse competition Alongside the main Micromouse* competition, held during Euromicro 80, Microprocessors and Microsystems awarded prizes for a description of the design approach used in creating the mouse. The judges, drawn from the Inter- national Editorial Advisory Board of Microprocessors and Microsystems, used the following criteria to decide upon the winners:

• elegance in the approach to mouse design • economy in the use of available resources • novelty in the solution of particular hardware or

software problems encountered

There were five entries to this part of the competition but the judges quickly shortlisted the two winners - most of the other entries were let down, the judges felt, by the lack of any description of the software. The first prize was awarded to Dr Peter Robinson of Lancaster University for PASCAL mouse-engine and the runner-up prize to Nick Smith for Sterling mouse (who was the only competitor to get to the centre of the maze). Their prize-winning entries follow. A full report of Euromicro 80 will appear in the next issue.

PASCAL MOUSE ENGINE Peter Robinson, f i rs t -pr ize w inne r

Intrigued by the results of the Portsmouth Micromouse trials, the Microprocessor Unit of the Computer Services Department, University of Lancaster began to sketch out a mouse design which was seen as an ideal test bed for several systems under development at the time. These were:

• three-chip 8085 system with three I/O ports, 2k ROM and 1 k RAM

• use of the Leeds University Micro-PASCAL compiler for real-time control

• ultrasonic pulse echo position sensor

As development started as late as August, readily available Motor control

CPU / + sonar cord card ~ 1 ' ~ ~

II ,, ,,. oc.so _ .... if battery n- (' . . . . . . . . 1 J. H1 lira" I pock I I n

' \ Y T v ' Sonar Motor baffery batteries

Optical Reflective pickup slots

Steering Steering Sonar servo oxle servo

Figure I. Mouse Engine chassis

*The Mic romouse contes t was first devised by IEEE Spect rum.

components had to be used wherever possible. In particular, although a two-wheel chassis was designed, it had to be abandoned in favour of a chassis from one of the cheap (under £10) radio-controlled cars now on the market. Although this chassis is of the car type, it was accepted from the outset that the lack of manoeuvrability inherent in such a design could be compensated for by precision control systems.

Chassis The chassis layout in Figure 1 shows the servos which were added to steering and sonar position sensor. Battery power comprises rechargeable nickel cadmium for the processor (four AA-size cells connected in series), motor (2AA-size connected in series), and a PP3-size cell to provide power for the sonar receiver and transmitter. Two DIN plugs and sockets reconfigure the cells for either supply or charging operation.

Processor The circuit diagram of the microprocessor system is shown in Figure 2. The CPU is the Intel 8085A, with MCS 85 system components used throughout (8755 EPROM and 8185 RAM). The 8755 provides 2k of EPROM, two 8-bit I/O ports and a 6-bit I/O port. The 8185 is a l k x 8 RAM for the 8085 bus.

Sonar position control Operating at 40 kHz, the sonar position control uses a pulse echo rangefinding system. The transmitter and receiver circuits are shown in Figure 3. The transmitter incorporates a gated CMOS oscillator with push-pull output. The receiver is conventional with TR1 and TR2 as a linear amplifier. The output of this amplifier is detected by D1, buffered by a MOSFET TR3 and finally clipped by a 741 comparator. Transistor TR4 ensures that the output fed to

+SV

0 I ~ c . e085

,::, .<l++l+ o.+ ~+ re>l,, (e!

I iJ I,

J ~ ~ eTe55

j A8~AIo

~ Dote/odd

]) io/~

I IVuV~ vm, e

I +

2jAe jA9 ~lDom/oaa

0 +SV

(a) l%-+ A

(8) Pot+ B

(e) Port c tl

Figure 2. CPU card

370 0141-9331/80/090370--05 $02.00 © 1980 IPC Business Press microprocessors and microsystems

Page 2: Euromicro 80: Micromouse competition

_ ~ . [ . - o * 5 V

TX gob= ~ / ~ T R 6

~ P o , , ~ , ' W ~ ; , | ] (s.,~ ~,, ± ",o,, 5.,k const.) I lOk I0.1FF

bit 2) I " i n | time ~ "1- (Set ~l~,dkl)

~ / +SV ---L.

L - - I G2

TD2 / I0 k Ultm=o~l¢ tmMmittw - -

Ultrasonic receiver

TX breokthmugh compensation

- o+9 V

I '~zvF~r ̀ ~ k (i'~'', L-~t'k I ~ i :~ ='')

:Set TR4 :.'=o,0,I I

Figure 3. Sonar unit

the I/O port switches between 0 - 5 V. An important part of the sonar system is the transmit-pulse-breakthrough com- pensation network. This network, fed by the output of the switching circuit TRS-TR6 serves to cancel the effects of transmitter breakthrough in the receiver and provides a degree of time-varying gain to compensate for absorption of the sound pulses as they travel through the air.

In operation, the microprocessor initiates the transmis- sion of an ultrasonic pulse by raising the TX gate input to a logic 1 for 100/Js. The distance of the object closest to the receiver can then be found by measuring the time taken for the first echo to arrive. This echo causes the logic level fed back to the microprocessor to switch from 1 to 0, a transition which can be easily sensed by software.

Distance sensor

In order to provide the microprocessor with information as to the distance travelled along the ground, a sensor is provided on the nondriven wheel on the driving axle. This sensor comprises a light emitting diode and photosensitive transistor in a single package. Light from the diode is reflected by notches in the tyre of the nondriven wheel. These notches reveal the hub of the wheel which is a good refelctor of light. The nondriven wheel was chosen to pre- clude the possibility of wheel spin giving rise to false readings. The arrangement is shown in Figure 1. Pulses from the phototransistor are fed back to an input port on the microprocessor, and by counting these pulses the micro- processor gains a measure of distance travelled.

M o t o r control

Figure 4 shows the motor control circuit used on the Mouse Engine. Two control lines are connected to output ports and feed the inputs of Darlington drivers. One of these lines causes the forward/reverse relay to change state and the other turns the motor on or off.

Software

The majority of the mouse programming was performed using the Leeds University PASCAL compiler for micro- processors. This compiler is itself written in PASCAL and translates a PASCAL source into an intermediate code suitable for interpretation by a microprocessor. At present interpreters exist for the Intel 8080 and 8085 and the

Forword/_= reverse

Dorlir~ton driver orro

Relay coil

~ 3 v MoOr on

_ t Reloy

I

Motor

Figure 4. Motor drive

Motorola MC6800. Compilation was performed at Lancaster on the

ICL 2960 mainframe computer and the resulting code downline loaded (along with the interpreter code) into a PROM programmer in order to program the 8755. In the system used, the interpreter occupies approximately 1 kbyte and the remaining 1 kbyte is free for use by the mouse program. Should this prove insufficient program space, provision has been made on the board for an extra 8755 to be fitted.

The procedures used were:

• outport (port, ch:char); • inport (port:char; var ch-char); • servoturn (servo:char; direc:integer); • rangefind (var range:integer); • nearestwall(varminrange, way:integer); • runmotor (motordir:char; distance:integer);

Of these, the first four were written in machine code. The procedures outport and inport both take as parameters a character variable which specifies the port number (in the range 0-255) to be accessed. In the case of outport a character variable is used to specify the value to whii:h the port is to be set, and in the case of inport, the port value is passed back to the main program as a character.

Procedures servoturn and rangefind had to be written in machine code due to time critical processes. To turn a servo in a given direction the programmer simply calls

vol 4 no 9 november 1980 371

Page 3: Euromicro 80: Micromouse competition

the procedure with parameters servo and direc. The char- acter variable servo is set equal to 1 to turn the wheel servo and equal to 2 for the sonar servo. In PASCAL this may be achieved by use of the standard function chr, e.g.

servo:=chr(1);

would assign the value 1 to servo. The integer direc governs the direction to which the servo sets itself, on a scale 0 to 6. The machine code routine feeds the servo (a digital pulse proportional type) with a burst of pulses whose width is pulled from a lookup table, accordingly to the value of direc specified.

The procedure rangefind passes back the range of the object closest to the sonar as an integer in the range 0 - 2 5 5 . The operating distance of the sonar is from approximately 0.03 m (0 on the above scale) to 1 m (255).

Procedure nearestwa//returns the range and direction of the closest object to the mouse.

As its name suggests, runmotor runs the drive motor. Parameters motordir and d/stance govern the direction of travel (0 = forward, 1 -- reverse) and the number of opto- pickup pulses sensed before the motor is stopped.

The first test program (see Appendix) was designed to seek out the wall nearest to the mouse and track along it, and was the first program run on the mouse. Success was achieved with this approach, but more precision is needed in the steering control routine.

Maze problem

The approach to the maze problem was in two stages:

• control routines were developed to survey the maze on a random search basis. During this phase a linked list was built up of the path taken through the maze. Should a trap have been encountered then this was recognized as such and the appropriate part of the list collapsed on exit from the trap (i.e. the mouse forgets about dead-end routes, but remembers not to make the wrong turn again at that node)

• analysis of the linked list built up (using the power of PASCAL list processing) to determine the shortest path through the maze

Cat toppl ing problem

Sonar lends itself to this as the problem becomes one of measuring the angle subtended at the maze by either a rotund cat or a slim peg. This should be readily achieved by the pulse-echo technique.

Present progress

As yet the control routines have to be finalized. All hard- ware is built and tested, the effort needed now falls on the software side, but the structured approach of PASCAL allows rapid development of complex control routines.

First version

] %ORIG)N=1372 3435 PROGRAm ~;

2 3435 VAR PORT.VAL,[email protected],WHEELSERVO. 3435 SON~RSERVO,ZERO,SONARTX,

4 3435 SONARRX.FORW&RD,REVERSE : C H A R ; 5 3435 I,DIREE,WALLRANGE,DELTA. 6 3435 CLOSESTRANGE,STOPRANGE : INTEGER; ? ]43~ ENDFL~G : BOOLEAN; P ]4~5 PROCEDURE OUTPORTEPORT,CH : C H A R ) ;

13 PROCEDURE INPORTIPORT : CHAR;V~R CH : CHAR); 11 VA~ C : CHAR;

1~ PROCEDURE SERVOTURN(SEkVO : CHAP;DIREC : INTEGER); 15 ] A k ( BEG)N

11 ]45~ END; 1~ PROCEDURE RANGEFIND(VAR RANGE : INTEGEr); I~ VAR R : INTEGER; 2~ )ASs BEGIN 21 345) E.~WTI~(~62) ; ~2 D45D R~NGE:=R 2S ~4SF END; ~ PROCEDURE NEARESTWALL(VAR mINRANGE.WAy : INTEGER); 25 VAR NEARANGE.K,TURN : INTEGER; 26 346 ~ BEGI~ Z? 3 4 6 7 MINRRNGE:=32000; 2~ ) ~ G a FOR K:=I TO G DO 29 347~ ~EGIN ~3 3~79 TURN:=K; ~1 ]47~ SERVOTURN(SONARSERVO,TURN); 52 J ~ S RANGEFIND(NEARANGE); ~ ]A~g IF (NEARANGE<MINRANGE) THEN ~A 3492 BEGIN 35 349~ MINRANGE:=NE~RANGE; 56 3497 WAY::~; 57 349r END; 3R 349E END; 3~ ]AYF END; G3 PROCEDURE RUNMOTOR(MOTORDIP : CHAR;DISIANCE : INTEGER); 4 1 VAR COUNT : INTEGER; G? OPTO,LASTOPTO : CHAR; 4 5 349~ BEGIN R~ ]~A~ OUTPORI(PORTA,MOTORDIR); ~S 34AA COURT:=O; 45 U~AF WHILE(COUNT(DISTANCE) DO 4 7 3RB~ BEGIN ~B ~ R b o I N P O R T I P O R T B . O P T O ) ; A9 3~B~ IF (LASTOPTO=CHR(OI) AND (OPTO=CHR(~)) THEN 53 ] 4 C f C O U N T : = C O U N T + I ; 51 ]~D/ LASTOPTO:=OPTO; 52 ]RDC END; $3 ]4DE OUTPORT(PORFA,ZERO); 54 ]LE6 END; S~ ('MAIN PROGRAM STARTS HERE*) SG ~ E 7 BEGIN 5F JAEB (*START BY INITIALISING VARIABLES AND SETTING UP pORT A S~ 0 4 E ~ AS ~ L L O U ~ P U T S I P O R T B AS A L L I N P U T S * ) 59 34E~ PORTA:=CHR(O); (*PORT A DATA REG') 5] ) 4FJ PORTG:=CHR(1); (*PORT 6 DAT~ REG*) ~1 ]4F5 ZERO:=EHR(~); 62 ]AFA WHEELSERVO:=CHR(I); (*WHEELSERVO IS BIT O,PORI A*) 6~ ] 4 f r SONARSERVO::CHR(2); (*SONARSERVO IS BIT I,PORT A*) 6A JSU~ SONARTX:=CHR(G); (*SONAR IX PIN IS BIT 2,PORT A * ) 65 050~ PORT:=CHR(2);VAL:=CHR(2SS);OUTPORT(PORTIVAL); 66 ]51 o P O R T : = C H R ( S ) ; O U T P O R T ( P O R T . Z E R O ) ; 57 ]52~ FORWARO:=CHRIR); ( *FORWARD 1 5 BIT3=IebITA=OIPORT ~ * ) 6 8 352~ REVERSE:=CHR(24);I*REVERSE I~ BITS=I,BITA=I,PORT A * ) 69 ]S2F DELTA := IO ; (*ADJUST T H I S FOR TRACKING CONTROL*) 7] ]53~ STOPRANGE:=IJ; (.AQJUST THIS FOR STOP DISTANCE AT E N D * ) 71 ~53 R (*PORT A LOOKS LIKE: 72 35~ ~ ~ I T 7 6 5 4 3 2 I O 7~ 353; NO NO ND FR mo ST SS WS *~ ~4 ]53 ~ (*PORT ~ LOOKS LIKE: 75 ]53 ~ BIT 7 6 5 ~ 3 2 1 J 7~ ]5~- ND ND ND N~ ND ND OP RX * ) 77 D53 (*WHERE; l~ 353 ~ ND = NOT YET DEFINED 7~ ]53 FR = FORWARD/REVE~SE CONTROL,U=FORW~RD ~3 ]53 ~0 : MOTOR ON,I=ON ~1 ~53 ST SONAR TX LEAO,I=PULSE TX ~2 3 5 3 " SS = SONAR SERVO ~5 35} WS : WHEEL SERVE ~ ]b~" oP OPTO P I C K U P ON WHEEL ~5 ) 5 ~ RX = SONAR RX INPUT,I=ECHO * ) ~ Jss~ (*FIND NEAREST WALL AND TRACK PARALLEL TO IT UNTIL ~ / ]5~ ~ END W~LL REACHED*) ~E JSS' REPEAT ~ ]bs- NEARESTWALL(~ALLRANGE.DIREG); J )SSl IF(DIREC>3) THEN SERVOTURNIWHEELSERVO,OIREC-3)

91 3S~F ELSE SERVOTURN(WHEELSERVO,DIREC+3); 92 JS5 r RUN~OIORIFORWARD,IO); 95 3 5 6 ~ UNTIL (DIRE£-O) OR (DIREC=6); v~ ) S ? ' REPEAT 95 ] 5 7 ! NEARESTWALL(CL~SESTRANGE.DIREE); }6 ] S z a RUN~OTOR(FORWARD.IO); V~ )5~, SERVOTURN(SONARSERVO,DIREC); 9~ ]5b? RANGEFIND(WALLR~NGE); V~ 3S~C IF ((WALLRANGE*DELTA)>GLOSESFRANGE) THEN

l J ] JSV~ I F ( D I R E C = 6 ) THEN S E R V O T U R N ( W H E E L S E R V O , 4 ) IDI 35AS ELSE SERVOFURN(WHEELSERVO.2);; 102 JSB? IF ((WALLRANGE-DELTA)<CLOSESTRANGE) T H E N I~5 ] 5 B r IFIOIREC=6) THEN SERVOTURNIWHEELSERVO,2) lOG ~5C ~ ELSE SERVOTURNIWHEELSERVO.4);; I~5 35D" SERVOTURN(SONARSERVO,3); 1 3 b ]5D~ RANGEFINDIWALLRANGE); 137 35E~ IF(WALLRANGE<STOPRANGE) THEN 106 35ED ENDFL~G:=TRUE ELSE ENOFLAG:=FALSE; 109 )SFA UNTIL ENDFLAG; 11J, )SF F END.

Final version

Acknowledgement

The author wishes to acknowledge the help given to him .by E Smith and T Clegg (both of the Micro Unit) for their help in mouse construction.

A p p e n d i x

Source listings of both the first and the final versions of test programs are given below.

j = , ~ i : ~ , ~ = 1 , ~ ¸

12 v g " C : C , A . ;

372 microprocessors and microsystems

Page 4: Euromicro 80: Micromouse competition

~ J4~I END;

31 P~OZCDURE CUN~OTOklM~TURD[~ : CPAR;OIST*NCL : INTECEEIVAk STOPFLAa : BOOLEAN); ~ VA~ CGUNT,TI~EOUr : IN1EGER; ~ OPIO,LISTOPTO,OPIOIIT,CDTOM6SK : CHAR; I~ 3 ~ Z ~EGIN ~ ]4f~ STCP~LA~::FALbE; s~ )R~ OPIOKASK:-¢HR(~); 37 3 6 V ? OUTPO~TIPO~Tm,WOTRtDI~); ~ J497 I I p , FOUT:=O;

4J )4AI WHILE (COUNT(DISTANCE) ~ND (TIMEODT(255) OC 41 ]4~I PEGIN ~ ]4~1 INPORT(pORTP,OPTO); 4~ )~6g ANIIOPlO,ORTO~IS~,OpTOFIT); ~R 04C0 IF (LASTOPTO=CBR(2)) AND (OPTO~IT'CHR(O)) THFh ~s ]~u] COUNT::COUNTII ; G6 D40~ LA~TOPTOI :OPTO~IT;

~* J&DD RAN~NO:=RANONO+I; 6~ )4E? IF (~ANDNO:L551 T~EN C~kDNOI:V; 5] ~ F 7 T ] M E O U T ; : T I ~ O U T + I ; Sl 34rF END; 5e ]501 iF (TI~EOUT=Z55) THEN 5TOPFLAB:=TRUE; $5 }5C~ CUTpORT(PGRTA,ZERO); S& 3517 END; 5S pROCEDURE TH~EERO[NT(TURNDIR : CHAR); $~ VIR POINIS,F,R : INTEGLR; 57 }51 : BEGIN SS 351C SERVOTURN(SONAR$~RVO,}); 59 J523 IF (TURNOIR='L') THEN 6O ]S~C BE~IN 61 3s2c 62 0531 6~ 0~3~ 6~ ]53~ ~s ~39 66 3539 ~7 3 S ~ e s os~

?~ 3560 ~6 056S 75 )572 END; 7 6 357~ ENe;

7g PROCEbURE GETUN$TUCK(STUCK~ENSE : CHAR); 79 3575 BEGIN s3 ~ ~579 IF (STUCKGENGE=FO~WAR~) THEN 5TUCKSENSE:=REVERSE EZ 3585 ELSE STUCKSENSe:=TORWARD; 85 ~592 REPEAT 66 ]592 IF(STEERING>~) THEN STEER|NG:=O 85 35A1 ELSE STEER|NG: :6 ; ~6 35AS SERVOTURN(WHEEL$ERVO,STEERI~G); 87 ~ S B ~ RUNmOTOR(STUCKSENSE,2.$TOpPED); 8S 05BE UNTIL NOT $IOPPEO; e9 osc~ ENd; 90 91 pROCEDURE MOVE(SENSE : CHAR); 9Z ~§C5 BEGIN 95 ~5C9 EN~FLAG::FALSE; 9& ]5CF REPEAT 95 ]$CF SERVOTURN{SONARSERVO.O); 96 05~7 RANGEFIND(LEFTWALL); 97 OGO0 IF (TeACKINGOIST>LEFT~ALL) THEN 98 05E8 STEERING:=3* (9* (TRACKING~IST+IO-LEFTWALL) ) o |v TRACKINGDIST 99 )GFR ELSE

13~ ]Gaz STEER1NG:=Gm(Vw(LEFTWAL~-IO-TRACKZN~DIST)) DIV TRACKINGDIST; I ] 1 361B IF (STEERING>6) THEN 5TEERING:=e; la2 )620 IF (STEERING<O) THEN STEEnIN6 :=O;

F : :6 ; R::O;

ENO ELSE eEGIN

F:=O; R::O;

FOR pOINT$:=~ TO ~ DO BEGIN

SE~VOTUgNIWHEELSERWO,R); RUN~OTORt~EVE~SE.2.SIOPPED); SERVOIURNlWHEELSER¥O,F); RUNROTOR(FOEWARDI~.STOPPEB);

io] aG]n ~oq a65o l o s ~659 10~ 366~ I0l ]675 108 ~67D 109 3685 110 0691

l ~Z ] 6 1 r 11} ]bB&

~lS ~6a5 11~ 36a9 117 06B9 11g 3689 119 )6BE l Z3 ~ c s 1~1 36C~ l ~Z 36E0

1z~ 36o l 1 IS ]eE~ 1~6 36F4 I~7 ]6F9 128 ]6FE I~? 370~ 139 aTo~ 151 ] 7 0 3 ~S~ 3~03 1 ~ 37U~ 1 ~ 3703 1~5 3703 156 ]701

1 ~ 370~ ~ 37o5 1~3 ~70S 1~1 ]?os 1 ~ 3705

1~5 ?70A 166 3?CF 167 )716 1 ~ o r t a 1 ~ 372~ IS3 37Z~ 151 ]72 ~ 152 3~3n 15~ JZ~?

15) O?&l 157 37{~

16) ) r b ?

1 5 ~ ) 7 7 T leS )77F 16~ )?IF

165 37~?

1?o J~AS 111

IF (LEFTWALL>(WALLSEP÷TRACKZNGDISI)) THEN STEEEING:SG; SERVOTURN(WNEELSERVO.$TEERING); RUNMOTOR(SENSE,3*STOPPED); IF STOPPED ANDtSENSE=FORUARD) THEN GETUNSTUCK(SENSE); SERVOTURN($ONARSERVO,3); RANGEF[ND(WALLRANGE} ; IT (WALLHANGE<4e) AN D (SENSE=FORWARO)

THEN ENOFLA~:©TaUE; ze (SENSE=REVERSE) AND STOPPED THEN ENOFLAGt=TRUE; UNTIL ENDFLAG;

ENO; ( 'NAZN PROGRA~ STAr tS HARe*) BE~IN

(*START BY ]N IT1AL~SING VARIABLES ANO SETTING UP PORT A AS ALL OUTPUTSIPORT 8 AS ALL ]NPUIS • ) PORTA:=¢HR(O); (*PORT AORTA REG') pORT~;¢EHR(1) ; (*PORT B OATA REG*) ZERO:=CHR(O); WHEELSERVO::CHR(1); (*WMEELSERVO IS 8 I T O/pORT A*) SOWARSEgVO:=CHR(2); (*SONARSERVO IS B IT I lPORT A*) SONARTX::CHR(~); (*SONAR fX PIN IS B IT 2,PORT A* ) P O R T : = C H R t ? ) ; V A L : = C N R ( 2 5 5 ) ; O U T P O R T ( P C g T , V A L ) ; p O R T : : ( ~ ( 3 ) ; O U T P O R T ( P O R T , I E ~ O ) ; FORWARD:=CHR(~); (°FORWARD IS B I T 3 = I . p I T ~ = ~ I p O R T K*) REVERSE::CHR(~) ; ( *REVERSE i s B I T ~ : I , B Z T ~ = t , p O e T ~ * ) OELTA:= IG; (*ADJUST THIS FOR TRACKING CONTROL*) (*poRT A LOOKS L tKE :

ND NO ND FR ~0 ST ss ws * ) (*poRT B LOOKS LIKE:

b i t 7 e S 4 3 2 1 E ND N~ No ND NO N. OP RX *)

('WH~E:No ~ T ~E1 ~EFINEe FR FC~WA~DI,EV~,S( CONT~OL,O=FORWAQD MO ~OIOR ONII=ON ST SONAR TX LEAD,I=OULSE TX SS SONAR SE~VO W$ WHEEL SE~VO OR OPTO PICKUP ON WHEEL ~X SONAR RX ~NPI)T,I=ECHO . )

SERVOTURN{5ON'RSERVO,6); H~NGEFINC(RIGHTWALL); SERVOTURN($ONRRSERVO,~); RANGEFINO(LEFTWALL); W~LLSER::RIGHTWALI.LEFTWALL; TRACK]NGDIST::(WALLSER) OIV ? ; REPEAT ~OVE(FORWk~) ; SERVOTURN(SONAkS~k~G,C); RANGEFINb(W~LL~E);

LEFTCLEAR:=FkLSE; RIGHTCLEAR:=~ALSE; i~ (WALLR~NGE>WALLSE ~) TwE~ LEFTCCEA~::TRbE;

~ANG~F~N~(WALLK~N~); ~F (WALLRAN~c>WALLSEP) THEN RIGHICLE~C:=T~UE; RUNWOT~R(FOR*ARO,~,STO~PtO); IF (LFFTCL~AR Akb RIGHTCLEAR) THEN EGIN

IF (~ANONO MOO ~ ) : ~ THtN C H O I C E I = ' L '

T~WEEPCINT(EHO:EE); L~STTU;Nt:CHC~CE;

~LS~ ~'EG:N

~TA~ IF L~FTCLEAR T-E~ ~ErIh LA~TTbW~::'L';Tp&~EDOI~T(tL ' ) END ~?~& ~LS[ ~F R~MTCLFA~ l hLN [ ~ G I N T H R E E P O I N T ( ' Q I ) ; L A S I T U R N : : ' R ' [K~ ]7C~ :LS~ ~TvE<:=~RUF; ;

]?CE IF STUCK THEN

] l O ~ TMGEEpOINT(L~brTIJGN);

]7DD UNTIL fALSE;

the new international journal covering the study, research and techniques of all design

First issue July 1979 C o v e r a g e inc ludes: • Design as a discipline • Studies of designer behaviour • Computer-aided design • Management of design • Developments in design methods • Participation in design • Design in general education • Appraisal of designed objects and systems

Annual subscription (four issues) £48 (Reduced rate of £12 for memebers of the Design Research Society)

Further details from: Christine Mullins, IPC Science and Technology Press Ltd, PO Box 63, Westbury House, Bury Street, Guildford, Surrey GU2 5BH, England Telephone: 0483 31261 Telex: 859556 SCITEC G

vol 4 no 9 november 1980 373

Page 5: Euromicro 80: Micromouse competition

STERLING MOUSE Nick Smith, runner-up-pr ize w inner

After several weeks of thought, Sterling Mouse was con- ceived on 2 February 1980 when two small second hand stepper motors costing £3 each were discovered in my local electronic junk shop. Seven months, £120 and 600 man-hours later, a 2 Ib 1 oz, 5½" diameter baby mouse with the potential to solve a maze was born.

The overall structure of the mouse is shown in Fig~Jre 1. It can be seen that there are basically two independent parts. The mouse control handles sensor information, motor control and builds up a bit map of the maze. The maze solver takes the bit map of the maze and builds a decision matrix on which the mouse acts.

Being an analyst/programmer by trade, the author first developed the maze solver. Electronic and mechanical parts came later, the author having no knowledge of these subjects. The mechanics were started when a neighbour, a little reluctantly at first, began building the mouse. The computer came last. Therefore the parts of the mouse will be described in this order.

Maze solver A mouse must be both fast and intelligent. To meet these objectives the maze solver has been written as a timing routine for the stepper motors so that the mouse need not stop to think. Each time it is called the solver uses the current bit map of the maze to build and improve the decision matrix which points to the shortest estimated route from every square in the maze to the goal. The maze solver has no knowledge of the current position of the mouse.

In theory it is possible that the mouse can overtake the maze solver but at worst, whilst learning the maze, the mouse will go a short distance in the wrong direction before correcting itself. The maze solver will find the shortest route from start to finish of a typical completely known maze in under 3 s.

A small bonus of the method is that the slower the mouse goes, the more intelligent it gets as the maze solver has more time.

Mouse mechanics The mouse moves from square to square building up the bit map of the maze and interrogating the decision matrix to decide where to go next. In the same way that the solver does not know where the mouse is, the mouse has no knowledge of the maze beyond its current square.

Although described as circular the mouse is actually octagonal with a driving wheel on each side and a cup mounted ball bearing for stability and ease of movement front and back. A pair of stepper motors (one for each wheel) drive the main wheels under direct CPU control. To get a good top speed the motors are accelerated from rest using an acceleration table derived by trial and error. Direction control is achieved in a tank-like manner by accelerating and decelerating the wheels independently. Turning is accomplished by reversing one of the wheels. The mouse has eight switch selectable speed ranges to allow for actual conditions on the day and also variable battery power.

The position of the mouse is calculated by keeping a tally of the number of steps moved over time. To allow for cumulative errors and the possibility of the motors

Moze mop

RAM

Decision motrix

Figure 1. Overall structure o f Sterling Mouse

A IA=Too for I_ B ** IB:OKoclose

1-]

\ J I1 Side view Front view

Figure 2. Side sensors

dropping Some steps the mouse position is reset whenever a wall is encountered in front or whenever a wall disappears on either side, i.e. about half way between two squares. A maximum error of about five inches can be tolerated.

Lack of electronics knowledge meant that the sensors had to be mechanical tough contacts. There are seven sensors in total: one microswitch on the front and three sensors built from old relay contacts mounted on wings on each side. The wings, shown in Figure 2, essentially tell the mouse whether there is a wall present and i f so whether the mouse is too close or too far from it on each side. The mouse will run down the centre of the maze, within a fixed tolerance, as long as at least one side wall is present. When there are no walls on either side the mouse travels in a straight line.

Computer The brain of the mouse is made up of the six chips detailed below.

RCA CDP 1802 RCA CDP 1851 RCA CDP 1859 RCA 4069 M ostek 4118 Hitachi 2716

cPu (CMOS) Programmable I/O interface (CMOS) Memory management chip (CMOS) Hex inverter (CMOS) 1 k x 8 static RAM 2k x 8 5 V PROM

The requirement of low powel; consumption makes the use of CMOS chips highly desirable. Unfortunately space limitations and the need for hand wiring precluded the use of the lower density CMOS memories.

Maximum use of the 1802 CPU has enabled a powerful program to be produced using little memory. The 1802 has 16 x 16-bit internal registers and all mouse status and control information is kept in these registers. Only 1 byte of RAM is required, and is used for logic and arithmetic operations. The 16 x 16 byte map of the maze and the 16 x 16 byte decision matrix are also held in RAM. Total EPROM requirements are about 800 byte made up of 700 byte for the main control program and 100 byte for the maze solver.

Acknowledgement The author wishes to thank his neighbour Geoff Pike for construction of the mouse, and Geoff Ellis of VSI for his encouragement and provision of chips for the project.

374 microprocessors and microsystems