[Manual version - 4 October 2015] This manual provides all the information necessary to get your new Zero2 robot working. It tells you how to use the software that has been provided for you by InterGalactic Robots Ltd, how to program the robot yourself using very simple BASIC routines, and how to use the software interface to Logo. The manual also includes a section on how the robot works, and how it is possible to expand the system so that you can use plug-in boards and software written by third parties, or even add-ons you have designed and built yourself. The appendices contain all the information on circuit diagrams, machine code listings etc. We hope you enjoy programming Zero2 and have as much fun using and playing with it as we had designing and building it. Index CHAPTER 1 - Your Zero2 Robot What Is A Robot What Can You Do With It? Unpacking Zero 2 Setting up Zero2 Using The Software Provided How Does It Run? Expansion Modules CHAPTER 2 - Programming Zero2 Serial Port Zero2 Controls Drive Motors Pen Motor Indicators Sensors Programming in BASIC Using ZeroDrive Programming in Logo Programming in Machine Code And Finally CHAPTER 3 - Using Zero2 with Logo CHAPTER 4 - How Zero2 works Hardware Mechanical Construction Electronic Construction Circuit Description Circuit Expansion Send and Receive Data Format Writing to Zero 2 Motor Control Indicator Control Line Follower and Hole Detectors Fenders CHAPTER 5 - Further Ideas Add-Ons Programming Zero2 Application of Zero2 1. GAMES 2. EDUCATION APPENDIX 1 - Bibliography Magazines Books - General, Robots, Logo, Interfacing/Machine Code programming, 6502 APPENDIX 2 - Setting up the Serial Port APPENDIX 3 - ZeroDrive Robot Interface - Interfacing to Logo/BASIC A) LOGO Procedures for use with Zero2 B) BASIC subroutines for use with Zero2 C) Machine Code Calls D) ZeroDrive Interface area - machine code variable locations Error Codes Sensor numbers/addresses APPENDIX 4 Transfering SpectrumLogo to Microdrive Transfering cassette based software to disc on the BBC APPENDIX 5 Zero2 PCB Component Layout Circuit diagram APPENDIX 6 - Manual update history COPYRIGHT 1986 Copyright 2006 INTERGALACTIC ROBOTS LTD: David Buckley UNIT 208, 22 HIGHBURY GROVE LONDON, N52EE, UK.



CHAPTER 1 - Your Zero2 Robot

What Is A Robot The idea of robots has been with us for many hundreds of years. The word 'android' was in use in Greek times, meaning 'a man like object'. In the seventeenth and eighteenth centuries many people wrote about mechanical arms, hands and automata, which were the forerunners of the robots we know today. Unfortunately, over the past hundred years, since the rise of science fiction as a popular sub-culture, the concept of what a robot is has evolved into the realms of fantasy. Famous robots in science fiction, like Robby in Forbidden Planet and CP30 in the Star Wars films, have encouraged people to think of humanlike robots being just around the corner. This is not true, and it will be many, many years before we possess the technological capabilities to mass produce such machines for them to become commonplace. Robots today are very simple systems compared to our science fiction produced concepts. The vast majority of robots in use are on production lines, making cars or consumer electronics. Zero 2 is the most basic type of robot, within the commonly accepted definition of that term as being a machine which can be programmed to do a multitude of tasks, mechanically or otherwise. Zero2 can move around the floor or tabletop, under instructions from a host microcomputer. It has a pen which can move up and down, thus allowing drawing or writing to take place under program control, (usually this is done through the high level language Logo). It also has a line follower, which allows it to follow lines 5mm wide. It also has a couple of lights which you can switch on and off or flash when turning corners for example. An audio circuit with a two tone horn and a loud speaker is built-in. Zero2 has been designed to be as flexible as possible. As well as using the educational language Logo, it's very, very easy to program in BASIC, and anybody with even a limited knowledge of that language can make the robot move, and do other things. What Can You Do With It? Zero 2 was designed to be expandable. The main printed circuit board has been designed with a number of connector points, such that many other devices, like a fourth stepper motor, can be plugged in and controlled using the electronics on the main board. One of the connectors on the main printed circuit board, allows you to plug other printed circuit boards into the system. These can be speech and sound synthesis, edge detectors to detect the edge of a table for example, obstacle detectors (fenders) which will allow the robot to avoid bumping into things, ultrasonic long range distance finding - the list is only limited by your imagination. IGR will be providing a number of these plug-ins, as well as an infra-red, remote control unit which allows you to run the robot from the computer without having to use the connecting wire (umbilical). This provides a very flexible basic robotics unit for educatio and hobbyist use. It is also possible to plug a number of units into the pen holder in the rear of the robot, which will allow Zero2 to take part in many games and even perform very simple tasks like watering plants, for example.
Unpacking Zero 2 Your Zero 2 comes packaged in a box designed for safe carriage. Carefully remove your packaging and place Zero2 onto a flat surface. In the built version of Zero2 the appropriate interface for your computer is included in the packaging. If you've bought the kit version which is sold without an interface then you will have to either assemble or purchase it separately. With the computer switched off or unplugged, plug the interface adaptor into the back of the computer, as shown in the diagram. Setting up Zero2 See Figs 1,1, 1.2, 1.3 With the power switched off, plug the robot power supply into the mains and the 3.5mm jack plug into the socket on the side of the interface. Now plug the lead from the interface box into the socket on the top of Zero2, making sure that the umbilical support, or halo, is pushed into the holes on the penslide pillars. IGR supply different hardware interfaces for each computer. Switch on the computer. The LEDS on the front of the robot pcb may flash briefly to show you that power is reaching the robot. You can now use Zero2. The simplest method is to run the software on the cassette or disc provided. Chapters 2 and 3 of this manual teach you how to program the robot using BASIC or Logo. It is advisable to run through the software provided so that you get a good understanding of how the robot works.
Using The Software Provided Each computer uses different methods for holding the software. IGR ships the software for Zero2 on cassette, unless otherwise specified. The first task is to transfer the programs on cassette to the media you will be using normally. Details of doing this are enclosed with the specific software for your machine these should be refered to now.
All cassettes, discs etc sold with Zero2 contain the following programs; 1. Some BASIC or machine code routines demonstrating the capabilities of the robot. 2. A machine code program that is used by either BASIC or LOGO, for example, to control the robot. 3. Some LOGO procedures allowing the user to program the robot from within this language. The specific software for your machine is fully documented on separate sheets enclosed with the cassette disc etc. How Does It Run? Zero2 receives signals from the host computer via the communications port, the interface adaptor and the umbilical. Zero2 will work from any computer with has an RS232 port. This means that Zero 2 is completely independent from the computer. It means that it is possible to write a program in machine-independent language, like Logo on, say the BBC, and run the same program on the Spectrum and the robot would perform the same tasks.
Expansion Modules

CHAPTER 2 - Programming Zero2

Zero 2 is very easy to program, whether YOU use BASIC, Logo or any other language, including machine code, which allows you to send data direct to the serial port. If you are proficient in the use of such languages then read on, otherwise first use the programs in the software provided to get familiar with the robot. Serial Port Before using the robot, the serial port (either RS232 or RS423) must be set up to the correct baud rate. This is the rate at which Zero2 expects the computer to send data to it. Zero2 is supplied to work at 4800 baud. The method of changing the computer baud rate varies with different machines, and details are normally given in the user manual provided with the computer. Commands for the more common computers are given in Appendix 2. When sending data to the robot from the Spectrum, the screen border will flash. This is normal. Zero2 Controls Every function of Zero2 can be controlled and monitored by the computer. To communicate directly with the robot you must tell it which part of the robot (device) is to be involved, and what that device is to do. Each device has a numeric address, to which the control data is to be sent. Valid addresses are from 0 to 7, though not all addresses have anything there as yet. The following addresses are currently in use, or are reserved for future use: Address Effector device Sensor device 0 Drive motors Line/Edge detectors 1 Pen motor Left bumper 2 Indicators Right bumper 3 Speech 4 Speech/Sound 5 Sound If you wish to fit other devices of your own, for example an arm or gripper, you should avoid using any of these addresses. See the chapter on 'How it Works' for additional information.
Once you have identified the address of the device you wish to control, you need to send this number together with the data to the robot. This is sent as one value, by multiplying the address by 16 and adding the data. Data values can be between 0 and 15. For example, to send a data value of 5 to the indicators: Address = 2 x 16 = 32 Data = 5+ Value sent to port = 37 The data to be sent varies for each device, as can be seen by a quick look at the next section. This is because each of the controls in the robot is connected to one of four electronic switches, each of which can be on or off. The data you send decides which switches are on and which are off. The following table shows which switches are on for each of the data values (1 means on, 0 means off): Data Switch Data Switch 3210 3210 0 0000 8 1000 1 0001 9 1001 2 0010 10 1010 3 0011 11 1011 4 0100 12 1100 5 0101 13 1101 6 0110 14 1110 7 0111 15 1111 Drive Motors Each motor is controlled by two switches, switches 2 and 3 for the left motor, switches 0 and 1 for the right motor. To make each motor move forwards you need to send instructions in the order 01,00,10,11. By checking the above table, you can see that to move the right motor only, you can send the data as 1,0,2,3. To drive the left motor only, you send 4,0,8,12. To drive both motors forward send 5,0,10,15. To drive the motors backwards send the data in the reverse order. To turn the motors in opposite directions send 6,0,9,15 or 9,0,6,15. This is a lot of numbers, but on closer examination thay are all obtained from the original 1,0,2,3 and 4,0,8,12 by adding the value for the step position of one motor to that for the other. You start at one end for one direction, and the opposite end for the other. Try it and see. 1 0 2 3 ( 3) 2 0 1 3 + 4 0 8 12 (12) 4 0 8 12 ---------- ---------- 5 0 10 15 6 0 9 15
Each time you send a data code to address 0, one or both motors will move one step. If you send the data out of sequence the motors will not operate properly and will probably just judder. You will need to keep a note of the current position for each motor in its list of codes. We will come back to this when we discuss programming in BASIC and Logo. Alternatively if you don't mind the robot moving 4 steps at a time, then by always ending on 15 the codes will remain in sequence. I.e. forward - 5,0,10,15, backward - 10,0,5,15, right - 6,0,9,15, left - 9,0,6,15. Pen Motor The pen is controlled by the same kind of motor as the wheels, and the same codes are used to control it, except that only switches 0 and 1 are involved. One step of the motor is 1/48 of a complete turn. Normally you will want to move the pen motor half way round each time which is 24 steps, so you would send the full sequence of steps six times. Remember that the pen is at address 1, so you should add 16 (1 x 16) to the step code before sending it to the robot. The position of the pen should be initialised to 'up' by sending individual steps until the pen is 'up', then the software and the pen will be synchronised. There is no need to send the codes to reverse the motor. 24 forward steps from 'up' will lower the pen to 'down' and another 24 forward steps will raise it to 'up' again. Indicators The LEDs and horn are connected to the switches at address 2 as follows; Green LED Switch 0 Red LED Switch 1 Low Horn Switch 2 High Horn Switch 3 To switch on the red LED, for instance, you need to send the 'on' code for switch 1. Unfortunately, if you send just that, you will switch off the other LED and horn if they were on. Every time you send a value to an address it replaces the previous value. You must keep a note of what was previously sent to the address and make allowances when sending fresh data. Assume the low horn and green LED are already on, and you want to turn on the red LED. The last data sent to address 2 was 5 (0101 - see table). The code for red LED on is 2 (0010), Add these numbers to get 7 (0111) which will give you the new data. Add on the address x 16, send it to the robot and on comes the red LED. Now, suppose you want to switch off the green LED. The code for green LED on is 1. Subtract this from the last data value of 7 to get the new data. By experimenting with different data values you can make the robot beep the horn and flash the LEDs in different ways. Sensors Each time a value is sent to a robot address. Zero 2 will send back a code relating to any sensors connected to that address. Address 0 can have up to six switches connected to it but the other addresses can only have up to four each. At present, only address 0 has sensors connected, these being the three line follower sensors, connected to switches 0 to 2 (switch 3 is always off).
Whenever either drive motor is stepped, the line follower sensors will send back a value from 0 to 7 which you can use to allow Zero 2 to follow a line. A value of 0 means that all the sensors see a dark surface, while 7 means they all see a bright one. If you examine the left half of the switch table above, ignoring switch 3, you will see the combinations of patterns between these extremes, with 0 meaning dark, and 1 meaning light. It is now possible to see how the various functions of the robot can each be controlled from a program, with information being passed back and forth between the computer and Zero 2. The BASIC and Logo Sections will explain how to use the robot from these languages. Machine Code programmers should also read these before turning to the section on Machine Code. Programming in BASIC Most BASICs are fairly slow when dealing with the real world, so do not expect rapid response when programming Zero 2 directly from BASIC. Nevertheless, full control is possible using the principles discussed in the previous section. A very simple program to drive the robot forward 100mm is given below, assuming you have already set the baud rate: 100 DIM A(4) 110 A(1)=5: A(2)=0: A(3)=10: A(4)=15 120 FOR S=1 TO 100/2 :REMark because 4 steps are 2mm 130 FOR X=1 T0 4 140 LPRINT CHR$(A(X)); 150 NEXT X 160 NEXT S 170 END The LPRINT command sends the characters to the serial port rather than the screen and may need to be changed with certain machines. For example, the Spectrum would use 'PRINT #n' where n is the channel number. For the BBC computer, if the RS423 port is set up as the only output device, then a simple PRINT statement is all that's needed. The semicolon is to prevent a linefeed character being sent, as the robot doesn't understand that. Some BASICs send a linefeed anyway after a certain number of characters. It might be possible to use a command such as WIDTH 255 to switch this off. Try changing the values in the array to get the robot moving in different directions. Remember to follow the correct sequence for each motor as explained in the previous section. Some BASICs are very fast and a delay loop may be necessary to slow things down.
While this program allows you to move Zero2, it is a bit limited, and you can only move in multiples of four steps. Here is a better version: 100 DIM L(4),R(4) 110 R(1)=1: R(2)=0: R(3)=2: R(4)=3 120 L(1)=4: L(2)=0: L(3)=8: L(4)=12 130 LP=1; RP=1 140 INPUT "B,F,L,R,X";D$ 150 IF D$="X"THEN END 160 IF D$="B"THEN LD=-1:RD=-1 170 IF D$="F"THEN LD=1 :RD=1 180 IF D$="L"THEN LD=-1:RD=1 190 IF D$="R"THEN LD=1 :RD=-1 200 INPUT "Distance" ;NS 210 FOR S=1 TO NS 220 LPRINT CHR$(L(LP) + R(R(P)); 230 LP=LP+LD; RP=RP+RD 240 IF LP>4 THEN LP=1 250 IF LP<1 THEN LP=4 260 IF RP>4 THEN RP=1 270 IF RP<1 THEN RP=4 280 NEXTS 290 GOTO 140 300 END This program holds the codes for each motor separately and uses LP and RP to point to the position in the left and right arrays. LD and RD are added to LP and RP respectively after each step, having been set to the correct direction according to the command D$. When the pointer steps past the end of its array it is sent back to the other end. In this way each motor is stepped through its array without affecting the other. This would be a good routine to start building a library of commands. You will need to add extra lines for error checking and to allow you to examine the line detectors, for example. Using ZeroDrive On the software supplied with Zero2 are one or more BASIC programs. The Spectrum tape has two: "zerol__BAS" and "zero2__BAS". Other versions will have slightly different names to meet the requirements of the host computer, e.g. ZEROBAS on the BBC. These programs are designed to work with ZeroDrive, which is a set of routines that make using Zero2 even easier. As They are written in machine code, the robot will move much more quickly. ZeroDrive for the Spectrum is on the tape cassette as file "ROBOT__BIN". Like the other programs, the first part of the name is seven characters long, padded with spaces as necessary (in this manual a space is represented by _). Do not forget these when loading the files otherwise the Spectrum will not find them.
For the BBC there are two ZeroDrive programs: "ZERO" for BASIC and "ROBOT" for Logo. ZeroDrive contains all the commands to drive the robot, with additional features such as setting the scale for each forward/backward step, setting the speed of the motor and adiusnng the accuracy of plotting. The described commands are numbered from 0 to 50, as sbown in Appendix 3c. The first routine called should be routine 0, this initialises the robot. To call the other routines from BASIC you will need to know the routine number and the arguments. For example if you wish to move forward 100 steps, checking Appendix 3c shows the routine number for forwards is 1 and that it requires two arguments. Each argument is a number from 0 to 255. If the distance to be moved is less than 256 then this is the first argument, and the second is 0. If the distance is greater than 255 then the first is the remainder after dividing by 256 and the second is the result of the division. The largest value allowed is 32767, nearly 33 metres! In our example the arguments are 100 and 0. If the move were 1000 steps the arguments would be 232 and 3 (1000/256 =3, remainder 232). To carry out the move, you place the routine number and arguments into memory locations known to ZeroDrive as 'routine','arg1','arg2','arg3'. A call is then made to ZeroDrive at'usercall'. On completion of the command, ZeroDrive will return any results it may have, also in 'arg1' to 'arg3'. It will also return any error code in the location known as 'error'. The memory addresses of these 'letterboxes' and the error codes are given in Appendix 4. As far as possible these locations will always be in the same place for any particular machine, whatever version of ZeroDrive is used. You can write your program with the current version, and they will not need much alteration should you upgrade later to a new version with, say, speech commands. The full command sequence to move forward 100 using the Spectrum is: 1 CLEAR 63200: LOAD "ROBOT__BIN" CODE: REM load ZeroDrive 2 POKE 64981,0: REM initialise 3 RANDOMISE USR 64966: REM call ZeroDrive 10 POKE 64981,1: REM forward 20 POKE 64982,100: POKE 64983,0: REM 100 + 256*0 30 RANDOMISE USR 64966: REM call ZeroDrive 40 IF PEEK(64976)<>0 THEN PRINT "ERROR": REM check for error Lines 1 to 3 need be run only the first time round. A bit easier than the first example, and quicker too. Now, using Appendix 3, experiment with sending commands to Zero 2 using the facilities offered by ZeroDrive.
Details of similar programs for other computers are given with the enclosed notes. zero1__BAS To make things even easier, "zero1__BAS" contains subroutines which do all the poking and peeking, leaving you to concentrate on the main tasks of deciding where and why the robot moves. Where space is limited, the less commonly used subroutines may be held in different files, named "zero2__BAS" and so on. The subroutines start at line 9000, and the first thing your program should do after loading "ZeroDrive" is to GOSUB 9000. This will set up the other subroutines and initialise the robot. In place of 'argl' to 'arg3', the routines use 'a1' to 'a3' for input, with replies returned in 'o1' to 'o3'. Arguments greater than 256 do not need to be split between 'argl' and 'arg2', but are simply assigned to 'a1'. The Spectrum usefully allows us to call subroutines by name, and this feature is fully used. A program to move forward 100 steps, turn right 90 degrees move back 50 steps and flash the LEDs becomes: 1 CLEAR 63200; LOAD "ROBOT__BIN" CODE: REM load ZeroDrive 2 MERGE "zero1__BAS": REM load subroutines 3 MERGE "zero2__BAS": REM if required 4 GOSUB 9000: REM initialise 10 LET a1=100: GOSUB fd: REM forward 100 20 LET a1=90: GOSUB rt: REM rotate right 90 30 LET a1=50: GOSUB bk: REM back 50 40 LET al=3: GOSUB setleds: REM swop LED state 50 PAUSE 20: REM wait a bit HEM 60 LET a1=0: GOSUB setleds: REM LEDs off 9000 REM zero BAS loads here The BBC computer allows similar facilities with its procedures, with the further advantage that values need not be assigned to variables directly, and line 10 would have the format "10 PROCfd(100)". You may like to modify the subroutines to improve on their performance. For example, few of the routines check for errors on return from ZeroDrive. Adjust The routine 'adjust' allows you to adjust the distance and angle through which the robot moves. Although the error is slight, slippage of the tyres on the paper or other surface will cause Zero2 to move a little more or less than 1 mm for each step. 'Adjust' uses geometry and algebra to calculate an adjustment factor to offset the slip. Once set up, Zero2 will be accurate to within half a degree or millimetre. You may need to use 'adjust' two or three times to get the best result and again if you change the paper type or run Zero2 on a different surface.
Programming in Logo Logo is an excellent language for programing Zero 2, and several commercial packages are available which link directly with the robot. Sinclair Logo for the Spectrum and Logotron Logo for the BBC computer are supported already, and others are being added. Because of these direct links,the basic movement and pen commands are used to move both the screen turtle and Zero2. The code to convert these commands is contained in ZeroDrive, which is on the supplied cassette as file "ROBOT__BIN" on the Spectrum or "ROBOT" on the BBC. Also on the cassette are one or more files containing procedures to extend the basic set. These files are "zero1__LOG", "zero2__LOG" or "ZEROLOG". The file names may be slightly different for different computers. Load Logo in the normal way. Before entering any program or procedure, type the command STARTROBOT, for the Spectrum or USE "ROBOT for the BBC machine if using Logotron Logo. Logo will then look on the cassette or disc for the file, load it, set the baud rate and initialise the robot. Ensure that the Zero2 interface is properly connected, otherwise the computer will hang up, waiting for a response from the serial port. From then on the basic commands (primitives) will also apply to the robot. ZeroDrive contains all the commands to drive the robot, with additional features such as setting the scale for each forward 'backward step, setting the speed of the motor and adjusting the accuracy of plotting. The commands are numbered from 0 to 50, as shown in Appendix 3. Routines 1 to 4 and 12/13 duplicate the Logo primitives and can be ignored. Some versions of Logo, eg Logotron, may have additional commands linked directly as primitives. To call the other routines from Logo, you will need to know the routine number and the arguments. For example if you wish to move the left wheel forward 100 steps, checking Appendix 3 shows that the routine number for left forward is 5 and that it reqires two arguments. Each argument is a number from 0 to 255. If the distance to be moved is less than 256 then this is the first argument, and the second is 0. If the distance is greater than 255 then the first is the remainder after dividing by 256 and the second is the result of the division. The largest value allowed is 32767, nearly 33 metres! In our example the arguments are 100 and 0. If, instead, you had wished to move 1000 steps the arguments would be 232 and 3 (1000/256 =3, remainder 232). To carry out the move, you place the routine number and arguments into memory locations known to ZeroDrive as 'routine','arg1', 'arg2','arg3'. A call is then made to ZeroDrive at'usercall'. On completion of the command, ZeroDrive will return any results it may have, also in 'arg1' to 'arg3'. It will also return any error code in the location known as 'error'. The memory addresses of these 'letterboxes' and the error codes are given in Appendix 3.
As far as possible these locations will always be in the same place for any particular machine, whatever version of ZeroDrive is used. You can write your program with the current version, and they will not need much alteration should you upgrade later to a new version with, say, speech commands. The full command sequence to move the left wheel forward 1000 steps using the Spectrum for example ans assuming you have already used "STARTROBOT" is: .deposite 64980 5 .deposite 64982 100 .deposite 64983 0 .call 64966 if .examine 64976=0 [] [print "ERROR"] A similar program can be written using Logotron Logo, using the correct addresses. By comparing this with the example given for BASIC programming, you will see that direct programming from Logo is iust as easy, with the benefit of being able to build up procedures from lower level commands quickly and easily. Now, using Appendix 3, experiment with sending commands to Zero2 using the xtra facilities offered by ZeroDrive. "ZERO___LOG" "ZERO___LOG" contains procedures which do all the housekeeping, leaving you to concentrate on the main tasks of deciding where and why the robot moves. The less commonly used procedures may be held in separate files, named "zero2__LOG" and so on, where space is limited. The procedures are structured in the same way as the primitives, so that as well as being able to say "FD 100" which uses a Logo primitive, you can say "LFD 100" which uses a defined procedure. This command replaces the direct commands in the example above with two words! As with the BASIC subroutines, you can modify the procedures to suit your own requirements. Adjust LOG The procedure "adjust" will be in the "zero___LOG" file or, if there is not enough memory available, in a separate file called "adjust_LOG". The purpose of this procedure is to adjust the distance and angle through which the robot moves. Although the error is slight, slippage of the tyres on the paper or other surface will cause Zero2 to move a little more or less than 1 mm for each step. 'Adjust' uses geometry and algebra to calculate an adjustment factor to offset the slip. Once set up, Zero2 will be accurate to within half a degree or millimetre. You may need to use 'adjust' two or three times to get the best result and again if you change the paper type or run Zero2 on a different surface.
robot__LOG The Spectrum cassette contains another file called "robot__LOG". This holds simple procedures as a demonstration of the turtle graphics commands. The program requires "zero___LOG" to be loaded first. Other Logo procedures may be included in your software: These are for demonstration purposes and are documented separately. Programming in Machine Code By now you should be able to write sustantial programs in either BASIC or Logo using ZeroDrive. If you wish, you can use ZeroDrive with your own machine code routines. Unless there is no alternative, you should not call the routines within ZeroDrive directly. Use your routines to place the appropriate routine numbers and arguments into the letter-boxes and call usercall. This way, should you later upgrade to a new version of ZeroDrive, your programs will still work, with little or no alteration. You may have to re-assemble your code, however, if memory locations clash, as discussed later. You can extend ZeroDrive to include additional commands of your own, using routines 25 and 26 (j.usr1 and j.usr2). Calling either of these routines Will result in ZeroDrive jumping to the address held in 'usr.1' or 'usr.2' (see Appendix 3). At present these locations each hold the address of a return statement. Once your routine is in place, replace the return address with the start of your routine and it will be called whenever you use the routine number. Use 'arg1' to 'arg3' to pass values to and from your routine. Your routine must end with a return from subroutine statement. If you intend to call it from a high level language it must also comply with any restrictions of that language on machine code calls. The Spectrum, for example, requires that the alternate" HL pair is preserved in a call from BASIC. Calls from Sinclair Logo must return with the A register set to 0, otherwise it will report a "ROBOTPROBLEM" error. Users of early versions of ZeroDrive will see this if they give two PD commands without a PU in between. ZeroDrive may occupy different locations in memory as different versions are produced. The interface area will, as far as possible, remain static and hold pointers to where the main code will load. You need to know where this is to avoid loading your own routines directly on top of Zerodrive. The start address of ZeroDrive is held in location 'zdstart' and the end in 'zdend'. The interface area itself starts at 'usr.loc' and ends at 'allend'. Versions of ZeroDrive after 1,42 will also hold pointers to the start of the machine-dependent parts of the code dealing with RS232 initialisation and sending data to/from the robot. These will allow you to write your own i/o routines if you wish.
And Finally The software supplied for differeni machines may have games or demonstration programs written by IGR or members of the Zero 2 Users Club. Instructions for loading and running these programs will be supplied with the software. If you write an application you feel might be of interest to other users, why not tell us about it. If you have any suggestions for changes to ZeroDrive or any other enhancements, let us know, and we will see what can be done. Should you find an error in the software, please advise us giving full details of how it arose, so that we can recreate and rectify the fault.

CHAPTER 3 - Using Zero2 with Logo

The Zero 2 robot works with a number of commercial Logo packages, In some of its versions it also comes bundled with this software. At the moment Zero 2 is provided with interface routines to hook into Sinclair Logo for the Spectrum, and Logotron Logo for the BBC. As other versions of the Zero2 software and interface are released then the software for these versions will be included in the cassettes. If you are using computers other than the Spectrum and the BBC then the appropriate information will be included in the software pack. Please read that first before continuing this chapter. Logo is a high level language that was initially designed for educational use, although it has now been extended to become a very powerful language which can be used For a multitude of purposes, both in business and for home or hobbyist use. Its obvious advantage is that it uses Turtle graphics, which are designed to construct various geometrical shapes on the screen, depending on how the screen turtle has been programmed. Quite complex structures can be constructed in this wasy, and you are advised to read through the introductory chapters of the manual supplied with the Logo software before continuing further into this chapter Using Zero2 as a Logo Turtle In the software supplied with your Zero2 is a program called 'ROBOT__BIN', or 'ROBOT'. This contains the interface routines to the most commonly used Logos; in the case of the Spectrum this is Sinclair Logo; for the BBC, Logotron Logo; and for the Commodore 64 Commodore's own Logo. Other software houses will be providing their own software interfaces to Zero2, and if you have another version of Logo, then please contact that manufacturer. Using Zero2 with The Spectrum Once Sinclair Logo has been loaded into your computer insert the Zero2 cassette into your tape recorder, and type after the question mark on the screen, STARTROBOT. Then push the play key on the cassette recorder, and after a few minutes the complete robot binary routine Should have loaded into your computer. Now whenever the turtle on the screen is given a command the robot will mimic it. Appendix 4 gives details of how to transfer the Logo program from cassette to microdrive operation. You can now load in the procedures titled zero1__LOG and zero2__LOG and save these on the microdrive too, if you have one.
Using Zero2 with Logotron Logo Logotron Logo comes in an integrated circuit (ROM) which is plugged into the appropriate socket on the BBC computer Please read the instructions for doing this first. Once it is installed typing '*Logo will switch the BBC computer from operating in BASIC to operating in Logo. The Robot driving files should now be loaded from the cassette or disc, by typing USE "ROBOT after the ? prompt. Other Logo procedures can be loaded by typing LOAD "ZEROLOG. The Logo Procedures/Additional Primitives A set of useful utility procedures and, for the BBC. additional primitives, are provided with the robot. These are in the file titled zero1__LOG and zero2__LOG on the Spectrum, or ZEROLOG on the BBC. They are detailed below. SETSCAL: allows you to set the distance that the robot moves for each unit in the Logo commands. ADJUST: allows you to compensate for slippage on different surfaces, wear and other effects that can detract from the accuracy of the unit. SETSPD: varies the speed of the robot. SETSPD 255 is the maximum and makes the robot move at around 10cm/sec. SETSPD 200 is recommended for accurate drawing. SETPEN: The pen is operated by a stepper motor. The computer does not know whether it is up or down, SETPEN should be used following a PENUP instruction to set the pen to its upper limit of travel. SETHORN: allows you to program the horn from within Logo SETHORN 0: turns both horns off SETHORN 1: toggles the low tone SETHORN 2: toggles the high tone SETHORN 3: swaps the tones SETLEDS: allows you to program the leds from within Logo. SETLEDS 0: turns both LEDs off SETLEDS 1: toggles right (green) LED SETLEDS 2: toggles left (red) LED SETLEDS 3: swaps the LEDs Details of further procedures are given-separately for your computer.

CHAPTER 4 - How Zero2 works

Hardware Zero2 has three stepper motors, two indicator LEDs, a two tone horn and three photosensors to enable it to follow a line. The machine is driven by two stepper motors, each controlling a wheel in half millimetre steps. The pen is raised or lowered by a third stepper motor. These three motors and the pen lift mechanism are mounted on a rigid aluminium framework, a 'pelvis', which in turn is mounted on the transparent baseplate. Towards the front of the baseplate there is a nylon glider, or 'toe' to prevent Zero2 falling over. All the electronics are mounted on a 4" by 2.5" PCB which in turn is fastened to the pelvis. At the top of the PCB is a socket, similar to a telephone connector socket but with a different polarization, to take the power and control umbilical. All the works are protected by the easily removable cover; in buggy mode leave it off. The umbilical is held clear of the pen by the wire loop 'halo'which plugs in the top of the body. To allow Zero2 to be independent of the make of computer used to control it. the computer end of the umbilical is a special interface box which has a connector for serial ports of either the Commodore 64, BBC-B, Spectrum, Atari or QL or a 25-way industry standard RS232 D-type connector for all other computers including Amstrad, Research Machines, Apple or IBM PC. Mechanical Construction Some of the parts such as motor drive bosses and rubber axle supports are bonded together with adhesive and this is done in the factory so that if you are building the kit only a screwdriver is necessary to complete the assembly. Electronic Construction The PCB is very densely populated with components and consequently has to be double-sided with fine tracks and many plated through holes; because of this it is supplied as a ready assembled and tested item onto which plug the leads for the three motors and the speaker. Circuit Description A 6402 UART is wired to accept and send serial data, 8 bits, parity disabled, with 2 stop bits at 4800 baud.
The received data is split into high and low nibbles as in Figure 4.1. D7 is discarded and D4, D5, D6 are used to address a 3 to 8 line analog decoder. The UART's Data Ready output goes high when a received byte has been transferred to the output buffer and is stable. It is routed through the decoder to form the select clocks S0 to S7. Only S0 to S2 are actually used and these enable the drive motor latch, the pen motor latch and the indicators latch as appropriate. S0 is also used to route the line follower sensor output to the UART for transmission back to the cmputer. The latches used have 'Q' and 'not Q' outputs and these are routed from the latches at address 0 and 1 through Darlington drivers to control the stepper motors. Two more Darlington drivers are used to switch the LED's at address 2. The other two data bits at address 2 are used to gate two oscillators, the outputs of each being routed to the speaker. Circuit Expansion All the necessary signals and power are routed to a 16-pin header (double row of 8 pins) in the centre of the PCB to enable expansion boards to be simply plugged on the front. For those boards which need a Ready line, such as speech boards, D6 of the parallel data accepted by the UART is available; this line is wired so that any peripheral board can pull it low. Consequently the particular board does not have to be polled. 1 +5V supply 3 ED0 Effector Data D0 5 ED1 Effector Data D1 7 ED2 Effector Data D2 9 ED3 Effector Data D3 11 ED4 Effector Data D4 13 ED5 Effector Data D5 15 ED6 Effector Data D6 2 GND 0V 4 LS Loud Speaker 6 SD0 Sensor Data D0 8 SD1 Sensor Data D1 10 SD2 Sensor Data D2 12 SD3 Sensor Data D3 14 SD4 Sensor Data D4 16 DR Data Received strobe from UART On the pcb a number of spare input/outputs have been brought out to connectors on the edge of the board. These take a 0.1" pitch 5-pin plug which can be used to expand the system directly, see Appendix 5. Using these connectors it is possible to easily add a fourth stepper motor, and edge/hole detectors.
Send and Receive Data Format
D7 -- not used
D6 \  device 
D5  } address
D4 /  on robot
D3 \  data from
D2  \ device 
D1  / addressed 
D0 /  at last write
D7 -- not used
D6 -- wireORed ready
D5 -- not used
D4 \  hole detectors
D3 /  at address 1
D2 \  data from device
D1  } addressed 
D0 /  at last write
Writing to Zero 2 When writing to Zero 2 each device, or device group, has an address which forms the first three bits of the upper nibble. These are allocated as follows. Address Device Data bit allocation 0 Drive Motors D3 D2 D1 D0 left right (port) (starboard) motor motor 1 Pen D3 D2 D1 D0 for future Pen lift allocation motor 2 Indicators D3 D2 D1 D0 Horn Horn Left Right High Low LED LED Tone Tone 3-7 for future for future allocation use
Motor Control In a small Stepper motor the control sequence codes are normally: Binary Decimal 0101 5 1001 9 1010 10 0110 6 0101 5 In Zero2 this is generated from two data lines with two inverters * * I*I* (I=inverted signals) 1 1 3 0101 5 0 1 1 1001 9 0 0 0 giving 1010 10 1 0 2 0110 6 1 1 3 0101 5 Each full motor step results in the robot travelling 0.5mm When used, the ZeroDrive robot driver software limits the minimum resolution to two full steps ie. a linear distance of 1mm and Codes 1 and 2 correspond to integral millimetre steps. A two bit data code stream of 1,0,2,3,1,0,2,3,.... will cause either drive motor to move the vehicle forwards. so FD mL mR each wheel moves 2mm, ie move 2mm forward 1 1 0101 5 0 0 0000 0 2 2 1010 10 3 3 1111 15 BK mL mR each wheel moves 2mm, ie move 2mm backward 2 2 1010 10 0 0 0000 0 1 1 0101 5 3 3 1111 15 RT mL mR each wheel moves 2mm, ie rotation of 2deg. 1 2 0110 6 0 0 0000 0 2 1 1001 9 3 3 1111 15 LT mL mR each wheel moves 2mm, ie rotation of 2deg. 2 1 1001 9 0 0 0000 0 1 2 0110 6 3 3 1111 15 RF mL mR only left wheel moves forward 2mm, ie rotation of 1deg. 1 3 0111 7 0 3 0011 3 2 3 1011 11 3 3 1111 15 LF mL mR only right wheel moves forward 2mm, ie rotation of 1deg. 3 1 1101 13 3 0 1100 12 3 2 1110 14 3 3 1111 15 Pen spare pen address=1 0 1 0001 1 +16 17 0 0 0000 0 +16 16 0 2 0010 2 +16 18 0 3 0011 3 +16 19 repeating the sequence 6 times will move the pen cam through 180deg. Indicator Control A data bit high causes that particular function to be ON. eg set horn and right LED off and Left LED on address Indicators required code 2 D3 D2 D1 D0 binary dec. Horn Horn Left Right High Low LED LED Tone Tone 10 0 0 1 0 100010 34 Reading from Zero2 When reading data from the robot, bits zero to three (D0, D1, D2, D3) contain the status data of the sensor device selected by the address of the previous WRITE while bit six (D6) is the wireORed ready line. Bit seven (D7) is not used .In addition at address zero, bit 5 (D5) in conjunction with bit 4 (D4) can contain the hole sensor information.
Address Device Data bit allocation D4 D3 D2 D1 D0 0 Line follower left centre right 0 Hole detector left right 1 Fenders right back side corner front 2 Fenders left back side corner front [figure should be labeled Fig 4.3] Line Follower and Hole Detectors A data bit high indicates a bright surface while a data bit low indicates a dark surface. For D4, D3 a dark surface is synonymous with a hole. Fenders A data bit high indicates an obstacle

CHAPTER 5 - Further Ideas

Add-Ons One of the problems with umbilical controlled vehicles is the umbilical itself and one add-on that will shortly be available is an infra-red communication link. For the vehicle end there will be a backpack containing a rechargeable battery and an infra-red receiver/transmitter unit with a complementary infra-red unit at the computer. Most animals have learned the value of audible communication and while R2D2 may get away with squeaks, where humans are concerned speech is much more understandable, hence another add-on board will be a programmable speech system which will plug onto the Expansion Bus connector. Two other add-on boards that will plug onto the main board will be one for detecting obstacles in Zero's path and another for detecting holes or edges of tables or simply a coloured border round Zero's territory to prevent it from straying. Programming Zero2 Chapter 4 gives complete details for controlling Zero2 in its basic form. This is easy to do even from BASIC but to follow a line or detect obstacles bitwise comparison is needed and some version of BASIC do not support this. In these cases it is necessary to write a routine in machine-code. Application of Zero2 Most people, when they see a robot like Zero2, ask one question: 'What can I do with it?' These are a number of applications which IGR has considered, some may be developed by them, or third parties, during the next few months.
1. GAMES Dam Dozer: using Zero2 as a bull dozer to push blocks into position to dam the flood. The computer screen could show a map witn a river; also drawn on a board. A tidal wave makes its way up the river, shown on the screen, with noises of rushing water and a rising tone. When the water reaches the town the noises and visual display reach a climax. The object is to get the blocks into position to save the town (the blocks were scattered around the board to start with). Sound levels, colour of display and speed of tidal wave can be selected. You may have to avoid bulldozing people, placed around the board to make it more difficult. Railway Set: draw a thick black line on a large sheet of paper (or your white tiled floor?!) You then mark stations by adding double crossed lines. Zero2 can then drive round the track/making noises like a steam train, stopping at stations, blowing its whistle when certain other markings are passed, or entering sidings to pick up pallets and move them around. Obstacle race: You have to pilot Zero2 round a series of obstacles or perform certain tasks before, say. all the water has drained out of the screen-display tank. The level goes down with gurgling noises, taking, say, three minutes to empty with a satisfying squlerrrrk at the end. The tasks could be, to, get a ball into a flat ring: drive through a slalom, with points lost for each post knocked over, leave two balls touching one another, go round a curvy course, losing a point each time the line- follower detects a black line. 2. EDUCATION Teaching robotics: This could include collision avoidance and route finding. For example draw a room and some furniture - in thick lines. One side is 'HOME' and you have to write a program to get to some other point, avoiding any obstacle Zero2 comes across. Ditto for a program to cover the floor area as if mowing a lawn or vacuum cleaning a carpet etc. Estimating - A whole class can sit round as Zero2 draws a line. How long is it? (Zero2 knows precisely). All classes' estimates can be entered into a computer for mean and standard deviation (if you want) and/or the closest guess is the winner. Zero2 could even go and point to the winner! The same thing could be done with a square, triangle, star, bottle shape, free shape etc., asking estimates of the lenght, angles, areas, or whatever you like, Zero2 always knows the exact answer and can pick the best estimate. Now get Zero2 to start shapes, and the class has to guess: -how many sides it will have: the radius of the circle: will it cross the other line: lay your bets! Even more advanced ideas. Eg where exactly did an arc of curvature x : end and a different curve begin? What is the area beneath this sine wave.
Teaching Spelling: take a line of capital letters. With Zero2 moving up and down it, pointing to any letter (maybe using an accessory pointer). It stops and hoots at each letter. Who can guess first the word, or sentence, Zero2 is trying to 'say'? You can adjust the level, ie. speed, duration of stop, level of words. You also have the option to reset the position at any time in case it slips (or is pushed).


Magazines EDUCATIONAL COMPUTING EMAP Publications. London (11 issues) The first UK magazine specifically devoted to the use of computers in education. ELECTRONICS - THE MAPLIN MAGAZINE Maplin Electronic Suppliers Ltd, PO Box 3, Raleigh. Essex 2.80 (4 issues) Full of do-it-yourself projects for the home electronics fanatic. At least seven projects each quarter, most of them based around the Sinclair and Atari computers. Maplin are distributors for Zero2 and articles appear regularly for this robot. The INDUSTRIAL ROBOT IFS (Publications) Ltd.. 35-39 High Street. Kempston, Bedford, UK 47 (4 issues) A specialist industrial robotics magazine. PERSONAL ROBOTICS MAGAZINE KLH Publishing, PO Box 421, Rheem Valley, CA 94570. USA $16 (6 issues) PERSONAL ROBOTICS NEWS PRN Publishing Co., PO Box 10058, Berkeley, CA 94709. USA $145 (12 issues) Rather thin (4pages), aimed at professional users. Not all that newsy either.
ROBOTICA Cambridge University Press. Cambridge, UK 45 (12 issues) A quarterly journal aiming to cover all aspects of robotics but with emphasis on research. Seemingly fraught with production difficultie ROBOTICS AGE Robotics Age Inc., Strand Building, 174 Concord Street. Peterborough, NH 03458 USA $32 (12 issues) Rapidly becomming the Byte of the robot world. ROBOTICS INSIDER Fairchild Publications, 11E Adams Street. Suite 1400, Chicago, IL 60603, USA $250 (52 issues) Another thin (4 pages) industry newsletter aimed at the industrial user ROBOTICS RESEARCH MIT MIT Press Journals, 28 Carlton Street, Cambridge. MAQ2142, USA S68 (4 issues) A quarterly research bulletin usually about 60 pages long. Really for the research orientated only. ROBOT TIMES Robotics Industries Association, PO Box 1366. Dearborn, Ml 48121 USA (12 issues) Monthly newsheet of the RIA. Free to members. ROBOTICS TOMORROW Robotics Society of America. 200 California Avenue, Suite 215, Palo Atto. CA 94306, USA $25 (6 issues) The Journal of the RSA. Full of interesting small, articles. Subscription is for full membership of the RSA.
ROBOTICS WORLD Communication Channels Inc., 6255 Barfield Road, Atlanta GA 30328 USA $35 110 issues) Monthly magazine aimed at the industrial user of robots. Very glossy with good news coverage. SENSOR REVIEW IPS (Publications) Ltd., 35-39 High Street, Kempston, Bedford, UK 47 (4 issues) As its name suggests this magazine concentrates on sensors. Another expensive industry quarterly. Books GENERAL Mindslorms: Children, Computers, Powerful Ideas by Seymour Papert of M.I.T. (Harvester Press, 1980) 10. An eminent mathematician explains how to use computers in the classroom so that even maths is enjoyable: less teaching and more learning. The book that introduced LOGO and Turtles to the world. ROBOTS Complete Handbook of Robotics by Edward Stafford (Tab 1978) 358pp 6. What robots can do and how they work by Tony Potter and Ivor Guild (Usborne 1983) 48pp 1.99. One of Usbourne's kids books that seem to have more in their 50 pages than most 500 page adult books! A very good intro to the subject with lots of colour pictures and even a simple build it yourself project. DIY robotics and sensors on the Commodore computer by John Billingsley (Sunshine Books 1984) 130pp 6.95. A really good introductory book at the most basic level. All good stuff from the Micromouse originator. DIY robotics and sensors on the BBC computer by John Billingsley (Sunshine Books 19841 130pp 6.95. See above. Transducers, sensors and detectors by Roboert Seippel (Reston 1983) 299p. $26.35 The Personal Robot Book by Robin Bradbeer, Dave Buckley, Bazyle Butcher and Richard Greenhill, [Duckworth/Newtech 1985) 8.95. Written by the originators of Zero2. Good introductory book. [never finished!]
Robots (Macdonald 1985) 5.95. Looks at history and applications of modern robotics. Aimed at children more than adults. The Robot Book by Richard Pawson (Windward 1985) 7.95. Good introduction to robotic experimentation with lots of examples based on Logo and Fischer-Technik kits. Make and program your own robots by William Clarke (Beaver 1985) 2.95 A DIY guide to simple robot projects. LOGO [not OCRed]
6502 [not OCRed]


Setting up the Serial Port Spectrum Baud rate 4800 If you use ZeroDrive to communicate with the robot, call routine 0 to initialise the RS232 link. GOSUB 9000 from BASIC with "zerol BAS" loaded, or STARTROBOT from Logo. If you are not using ZeroDrive then: BASIC: use the command sequence: OPEN 3;"b":FORMAT "b",4800 LOGO : use the command: SETSER1AL 4800.
BBC Computer Baud rate 4800 If you use ZeroDrive, call routine 0 to initialise the RS432 link. Call PROCinit from BASIC with "zerol.BAS" loaded, or USE "ROBOT.BIN from Logo. If you are not using ZeroDrive then: BASIC :*FX 8,6 *FX3,7 Other computers This is documented separately


[not OCRed]


[not OCRed]


Larger view of Circuit Diagram is latest version 'C' 13-6-85

APPENDIX 6 - Manual update history

04Oct15 Programming in BASIC - A very simple program to drive the robot forward 100 steps changed to ' the robot forward 100 mm' 29Dec12 all .JPG changed to .jpg in html and filenames 03Jul11 html border=1 for FireFox & Chrome 20Nov09 Chapter 4 - Writing to Zero2, missing >, writing name didn't work in IE6 15Feb07 page23 Motor Control, RF, LF read 'roation of 2deg', changed to 'rotation of 1deg' 22Jan07 Fig4.2 reduced in size, table made with data bit allocations, was not clear 22Jan07 last para p24, added - D7 not used 18Oct06 Z2-PCBv3-Circuit150dpi.jpg large circuit diagram re-scanned from another copy 04Oct06 100/4 corrected to 100/2, Programming in BASIC page 10 23 July 2006 initial manual scan, update, and html version finished 1985/6 Manual written