3

Strip A runs the full length of the board, with no cuts. Strip B is cut only at B39. The 12 V or 9.6 V power supply goes to the screw terminal Diodes protect each transistor switch from voltage spikes induced when the coils are switched off. Any small signal diode, such as a 1N4148 is suitable.

About this book

This is a book of practical robotics written for beginners but also catering for those who have progressed a little further beyond that stage. It describes the mechanics of robot construction, how to build the electronic circuits, and finally goes into the details of programming robotic systems. The first half of the book is a cookbook of information, ideas, tips, and suggestions for the first-time roboticists and others. Much of the content will be of interest and practical use to students in...

Aluminium stock

Most DIY stores hold a range of aluminium stock, and it is inexpensive. It is usually sold in lengths of two metres and there is a variety of sizes and cross-sections. The drawing shows some of them. Aluminium is also available in sheets, commonly 1.5 mm thick. This material is easy to drill and to cut, using a hacksaw. Strip and square-sectioned stock can be bent by hand, provided it is not too thick. So can rod. It seems too obvious to point out that aluminium has the advantage of being a...

Analogue input

The Scooter (p. 166) is an example of using an AD converter. The robot spins around, continually reading the light level ahead of it, until it locates the direction of the brightest light in its view. Then it moves forward towards it. In this robot the forward-facing LDR is connected to pin 19, which connects to the AN0 input channel. If you are planning a robot and think that you may want to read analogue input, reserve pin 19 (AN0) and possible pin 18 (AN1) for this purpose. If we are...

Analogue to digital converters

Analogue input is fed to the converter through any one of 14 channels. For this discussion we will refer only to channel AN0, which is at pin 19. At power-on, all the PIC's output channels are automatically set as analogue inputs. The analogue selection register ANSEL, which is in Bank 2, is used to define which are to be reset as digital inputs. If bit < 0> is '1' this makes AN0 (pin 19), an analogue input. At the same time it disables the weak pull-up and the interrupt-on-change function....

Avoiding obstacles

The LEDs are mounted on the body of the robot and directed on a single central point about 100 mm ahead of the robot. If an object is present at this point, and assuming the object is large enough and fairly reflective, the amount of light received by the LDR will be significantly greater than normal. The robot detects this situation and takes avoiding action. The robot will respond also when it approaches a wall or furniture, so it is able to scoot about the room indefinitely, though it may...

Brass stock

This is useful for some of the smaller parts of mechanisms. It is obtainable from model-making stores. Brass is available in most of the same sections as aluminium stock, but in smaller dimensions. It is often sold in 200 mm lengths. Brass is more expensive than aluminium but fortunately we do not need a lot of it. Brass is easily worked with drill and hacksaw. The thinner stocks can be bent by hand. The photo of the gripper on p. 311 shows how it can be bent to form jaws. Its distinguishing...

Brush

This converts our gantry into an artist. The base panel of the brush tool is bolted directly to the underside of the x-frame. The tool incorporates its own pulley mechanism for raising and lowering the brush. This is driven by the M3 winch on the y-frame. The brush is mounted on a four-sided frame loosely bolted at the corners. This allows the brush to be moved up and down while remaining vertical. When the brush is down, in the painting position, it rests lightly on the paper. It is pulled...

Building the wheel system

We chose a typical food storage box, with a snap-on lid. The corners are rounded (see photo). The best way to use this type of box is upside down. The lid (now underneath) has the motor, the drive wheels and the castor mounted on it. The circuit boards and parts of the robot are housed in the box. An electric motor spins too fast to drive the wheels directly. Use a motor with a built-in gearbox. We chose a 6 V (nominal) DC motor which included a kit of plastic gear wheels. These are assembled...

Camera

This is a one-pixel digital camera It has a single LDR as its sensor. Its output is an analogue voltage ranging between a few millivolts when focussed on a black object and several volts when aimed at brightly lit white objects. Because it has a lens to focus a life-size image of the object on to the sensor, the camera has high sensitivity and a narrow field of view. These features are important when the Gantry is playing a board game or when registering the layout of a drawn maze. But,...

Circuit board

The components of an electronic circuit are nearly always assembled on a rectangle of circuit board. This is made from insulating material and has conducting copper tracks on its underside to make the connections between components. In the circuits described in this book, we use components that have wire terminals. The wires are pushed through holes in the board and soldered to the tracks on the other side of the board. Another type of component is the surface mount device (SMD) which has...

Companion website

This website carries downloadable files of the MPASM versions of all the programs and subroutines listed in the book. In addition there are files of programs for the Quester and the Gantry that are too long to be included in the book. All downloads are free of charge. The site also carries the same programs in the form of hexadecimal files. What sort 2 Getting down to detail 4 Controlling the robot 5 Programming a PIC 6 Simulating the PIC 8

Comparators

The 16F690 has two voltage comparators, each of which has its own control and register. For comparator 1 (C1), this register is called CM1C0N0, at address 119h in Bank 2. We will look at programming C1. Programming C2 is similar. The comparator has the usual properties of a comparator circuit. It has two inputs, C1VP (positive, or non-inverting input) and C1VN (negative, or inverting input). The non-inverting input is supplied either through the RA0 pin (pin 19) or from an internal voltage...

Configuration word

This is a 14-bit word that is stored at a special address in memory and which sets up the way in which the controller is to operate. One of the first things to be done by a program is to define this word (p. 135). Without going into details about several of the functions, the word used for the programs listed in this book is made up as follows Functions enabled or disabled for simplest operating, set to 000011. Make pin 3 (RA4) a digital input, set to 0. Select INTOSCIO, internal oscillator...

Connecting wire

Single-stranded insulated connecting wire, 0.71 mm diameter. Used for wiring up circuit boards. Can be bought by the metre, and a metre or two in two or three different colours is worth keeping in stock. Multi-stranded flexible insulated connecting wire (sometimes called bell wire), 13 x 0.12 mm (that is, 13 strands, each 0.12 mm diameter). Use for connections to offboard components such as motors, and for connections between boards. Stock a few metres in a few different colours. Tinned copper...

Connections between boards

See the drawings on p. 264 and p. 268, and the table below. The photo on the previous page illustrates the way the 0 V and +6 V lines are daisy-chained from board to board. The PIC is not in its socket, and will not be there until the whole system has been tested. No. of wires From connector To connector Light sensor LDR Light sensor Processor * Pin 0.9 mm pin on the board, socket on the lead. t 2-way and 3-way polarising header plug on the board, socket on the lead. Begin testing by checking...

Connectors

This book is based on the idea of circuit modules. These modules can be put together in many different ways to build a variety of robots. Modules also have the advantage that their circuit boards are small and so will fit more easily into that small space in the cramped interior of the robot. A modular system can be improved, added to and revised without having to re-build the whole system. There are several types of connectors suitable for robot circuits. The cheapest are the 0.9 mm or 1 mm...

Contact

By this we mean physical contact between the robot and an obstacle such as a fairly massive object or a wall. Typically, the robot has bumpers or possibly wiry 'antennae' arranged so that they are touched when the robot runs into anything. The usual response is to reverse a short distance, turn slightly to left or right, then move forward to try again. If the robot has a pair of bumpers, at front left and right, it is possible for the robot to work out which is the best direction to turn....

Control panel

The control panel switches power supplies for the motors (12 V) and the logic (6 V). Power distribution circuit. The switches SI and S2 are on the Control Panel. Note the 0 V line which connects the 0 V terminal of both batteries to the 0 V terminals of the processor board and all the sensor and actuator boards. In this way all modules in the system have reference to the same ground (0 V) level. Signals may be exchanged between the modules. From B2 From B1 +6V +12 V TP11 OTP5 The Control panel...

Controller board

Keeping to the theme of small compact units, the controller board is minimal in design. It is essentially a 20-pin IC socket with socket strips for the connections. The controller has socket strips on each side for push-in connections. Note the cuts in the copper strips to isolate the pins on the two opposite sides. Sockets at C1, D1 and E1 are connected as a group by running a blob of molten solder between them on the rear of the board. This group is for the positive supply voltage. It is...

Controlling the robot

The first robots (they were called automatons in those days) were purely mechanical, driven by clockwork or steam power. The arrival of electronics greatly increased the scope of what robots could be made to do. Modern concepts of robotics began to emerge. The big advances came when engineers started putting complex digitial circuitry on a single chip. These were microprocessors, capable of millions of operations per second. Microprocessors are widely used in computers, robots, and many other...

Cutting tools

A junior hacksaw, with a 150 mm long blade is good enough for most jobs, such as cutting wood or plastic, and for circuit boards. For cutting aluminium or brass stock a regular hacksaw is faster and gives a straighter cut. If you have problems with cutting things square or if you need to cut at a particular angle, a mitre saw is a great help. It keeps the saw blade vertical and perpendicular to the length of the workpiece. It has gauges to help cut pieces to equal lengths. The frame that...

Data transmission with the USART

The 690 has an Enhanced Universal Synchronous Asynchronous Receiver Transmitter, or USART for short. We use this to take a byte of data and transmit it serially (that is, one bit at a time) to the USART of another PIC. The second USART receives the serial data bit by bit and assembles it into a byte that can be read from a register. Transmission can be by a single wire (if the 0V line is common to both PICs) or by a radio link. The output from the USART is at RB7 (pin 10) and the input at RB5...

Designing tools

These are the things that are used during the design stage before you get to actually building the circuit. A bench power supply unit (PSU). This should be able to supply a range of DC voltages up to 12 V regulated at a current of up to 1 A. A cheaper alternative that will cover most demands is a plug-top PSU. This is the sort that looks like a mains plug and goes directly into a mains socket. An even more basic supply is a battery box holding the number of cells needed to produce the required...

Detecting and responding to light

Sight is probably the most important of all human senses. The same applies to mobile robots. Some can detect a lamp which is several metres distant, and aim themselves towards it. Or maybe they will go in the opposite direction, to end up in the safety of a dark corner. The Quester robot homes on a source of light. The Quester robot homes on a source of light. The important feature of light is that it is detectable at a distance. This makes it ideal for long-range sensing. One of the problems...

Developing the Quester

There is plenty of scope for combining some of the routines in this specification to make longer and more complex programs the PIC16F690 still has plenty of program memory to spare. Consider building some of the other sensors described in Part 3. Add them to this robot. For instance, the sound sensor has several applications ranging from responding to a hand-clap (everyone in the room has to keep very quiet when this is running) to allowing a pair of robots to communicate by using sound...

Diagnostic programming

No part of a program need be permanent and LEDs are useful indicators for finding out where the PIC has got to in the listing. Use these facts to make life easier. For instance, suppose you suspect that the PIC is not going to a particular subroutine when it should do. Add a line to the beginning of the subroutine, such as bsf portb, 2 (or some other output channel that powers an LED). What happens when you next run the program tells you where to start looking for an error. If the LED does not...

Digital output

The output of this circuit goes high when the light level rises above a preset amount. The output of this circuit goes high when the light level rises above a preset amount. This circuit is used for the LDR light sensor of the Quester robot (p. 258). The output of the CA3148E swings close to the supply rails, providing a clear signal for the controller. The Quester demonstrates another way of producing digital output. A CMOS logic gate changes state when input voltage levels are close to half...

Direct drive

The maximum current that can be sourced at any single terminal pin is 25 mA. The maximum current that can be sourced by the three ports at any instant is 200 mA. The same figures apply also to sinking current. A current of 25 mA is sufficient to drive a regular LED but not the high brightness or extreme brightness types, which take 30 to 50 mA or more. Driving an LED directly. Use the equation on p. 66 for calculating the -4-yJ'

Drive wheels

The car has four wheels, which turn in bearings on the sides of the body. We decided to use the rear wheels for driving the vehicle, and the front ones for steering, just as in a conventional automobile. The existing battery supply is from two type AA alkaline cells, giving 3 V. The motor gearbox unit chosen as the drive motor runs on 3 V and has an output shaft on either side. After considering various possibilities it was decided to push the wheels on to the ends of the output shafts. A short...

Dry run

No matter what ingenious programming software is available, there are times when the only practicable way to debug a program is to do a dry run. All you need are a pencil and paper. In a dry run you set out a table of all the registers and variables that are involved. You then go through the listing line-by-line and work out the values that are in each register. Enter these in the table and confirm that they are the right values. As an example, here is a segment of the listing for part of the...

Electronics

It is almost inevitable with any innovative project that some of the parts and components will be incompatible with some of the other parts and components. We have already come across this problem in the Mechanics section. A motor with a 2 mm output shaft has to drive a gear system based on 3 mm shafts, and sometimes our mechanism is held together by metric nuts and bolts plus a few rated in fractions of an inch. The same happens in the electronics for example, different components need...

Gantry and tool systems

The electronics of the Gantry consists of two separate but cooperating systems, each with its own PIC16F690. The gantry system moves the x-frame where it needs to go. This includes moving the y-frame. It also raises and lowers the tool. In other words, it switches the motors on or off and sets the direction in which they turn. This system also has pushbuttons and a switch used by the operator, plus a pair of indicator LEDs. It gives the operator control of the robot. It is based on a PIC that...

Gantry subroutines

This table lists the routines and subroutines used for moving the x-frame. It is a summary to use when building up gantry routines. move no. of rows and columns set by xpos and ypos move from current x to destination x move from current y to destination y scan right to left, left, right, back, forward to back, forward stopping on rightward scans, return to start lower hook until updown load removed

Gantry system

In the gantry system the two main items are PIC1 Operates on 2.0 V to 5.5 V DC. It needs only a few tens of milliamps to drive the LEDs. Motors Three of these running on 12 V DC at up to 500 mA. Under heavier load they would need more current but 500 mA is the most they are likely to take. The best supply for the PIC is a battery of four nickel-metal-hydride rechargeable cells. This produces 4.8 V (a little more when freshly charged). Two such batteries are convenient for running the motors....

Gear wheels

Gear wheels are often needed for drive transmission and for moving arms and grippers. They are available as packeted kits of plastic gear wheels of a range of diameters from various manufacturers. Tamiya produce sets of gears, including motors, that can be assembled into gearboxes of many different ratios. Meccano and Lego produce gear wheels too, and the kinds of mechanism that can be built from them are shown in the photos overleaf. Gear wheels transmit turning force by engaging their teeth....

Going places

The four one-step routines will take the x-frame to any part of the working area. This next routine takes it to location (0, 0), which is at the front and on the right. Starting from base where the frame was left after the routine of p. 338, it must take one step to the left followed by one toward the back. When the moving routines are used for a single step, only the flags < 0> bit needs to be set or cleared before calling the subroutines. To get from base to location (0, 0), just clear...

Going straight

The first thing to be done in almost every program is to turn the steering wheel so that the robot will run straight ahead. The wheel may have been left at an angle at the end of the previous session, so the robot begins the new session, not knowing which way it is heading. This is not a problem for robots with tank steering. The program turns the steering wheel in one direction until it triggers the limit switch on that side. It then knows where the wheel is pointing and turns it back by a...

Gripper

The gripper has one fixed and one movable jaw. The fixed jaw consists of a single brass strip bent to shape and bolted to the base panel. The movable jaw is double and driven by a motor with built-in gearbox. The two arms of the movable jaw are directly attached to opposite ends of the gearbox output shaft. The gripper is raised and lowered by the same pulley block as the hook, complete with the two limit switches. The single-sided jaw is opened and closed by the motor, through the gearbox. It...

Hello World

It is almost a tradition for beginners' books on programming to begin with the simplest of all programs displaying 'Hello World' on the monitor screen. This program is the robotic equivalent. It makes the Scooter show off its output capabilities in the simplest possible routine. At the same time it is a way of checking that the output circuits are working properly. The first thing the Scooter does when this program is run, is to stay motionless for about 5 seconds, waiting for everybody to give...

Highlevel languages

Assembler instructs the controller step by step. High-level languages, such as BASIC and C, provide the programmer with commands each of which takes the controller through many steps. This makes programming quicker and easier to follow. A good example is the WRITE command in PICBASIC. A single program line, 'WRITE 3, count', puts the value of the count variable into byte 3 of the PIC's EEPROM. Doing the same thing in assembler takes many more program lines. A program written in a high-level...

Hook

The hook is made from brass rod bent into shape and attached to a pulley block. The pulley wheels used here and in other tools are included in the pulley set from Tamiya . Two views of the hook, show it attached to a pulley block. The sides of the block are bolted together by two bolts at the top, with 6 mm spacers between them. A special mechanism raises and lowers the hook. The same mechanism is used to raise and lower the gripper. The principle of this is illustrated below. The winch motor...

Infrared sensor board

The infrared sensors in this robot are mounted below the lower deck, just behind each bumper, and directed downward. The rims of the shields are about 20 mm above ground level. The probes are built on small squares of stripboard (overleaf). The IR LED (D1) is a 5 mm type able to pass a maximum current of 50 mA. The IR photodiode (D2) is a BP104, which fits conveniently close to the circuit board, but other types can be used. When soldering in the diodes, note that they are mounted with opposite...

Input Output modules

The Quester has five input modules a light sensor, a pair of I R sensors, a pair of bumpers. It also has input from S3 and S4 on the Control panel, as already described. Excluding the drive motors, the robot has three output modules a bleeper, and two high brightness LEDs. It is not necessary for you to equip your robot with the same selection. To start with, you may build and install only the bumpers. Experiment with these for a while before adding some of the other sensors and actuators....

Inputs and outputs

Programs usually begin by clearing the ports and setting each channel as either an input or an output. We also need to think about which input channels are to be digital and which analogue. If a channel is a digital input, is it to have weak pull-ups Now we step warily through the various banks of Special Function registers. Incidentally, even though a linker file may have eliminated the need to type the equates, the list of registers on p. 135 is handy as a reminder of which bank each register...

Interference

The Gantry has several connecting wires that are 10 cm long or longer. These wires are liable to pick up spikes and other signals radiated from other connecting wires. For example, the wires from the Hall effect sensors to the PIC1 board are about 70 cm long, and this may lead to unreliable counting of the marker magnets. This problem may not arise but, if it does, the x- and y-frames do not move the correct distances. The effect is cumulative. The sensible solution would be to use screened...

Laser

This projects an intense but very small spot of laser light on the floor beneath the x-frame (overleaf). It is used to point out objects such as playing pieces. For instance it points to the piece the Gantry wants to move next. Or it can trace the Gantry's chosen path through a maze. The laser is an inexpensive 'laser pointer'. It has its own battery of button cells. The pointer is held in a springy clip of the type used for holding PP3 9 V batteries. The pointer has an on-off push-button. With...

Light sens or and LED s

As there was room for only four boards on the upper deck we decided to build these two modules on the same board. The schematics are on p. 75 (plus an op amp comparator as on p. 73) and p. 91 (left). See Shopping List, pp. 278-279, for component values. The light sensor occupies the upper half of the board, with the pair of LED switches on the lower half. The light sensor is nominally an ORP12, but any low-cost LDR can usually be substituted. Preferably it should be about 5 mm in diameter. It...

Limit switches

The x- and y-frames have IR or Hall effect magnetic sensors for determining the x- and y-positions of the tool. In addition, a pair of microswitches mounted on the main frame are used as limit switches. These detect when the x- and y-frames are in their base positions. They reliably put the tool at the front right corner of the frame. From there it uses the IR or Hall effect sensors to find its way to any other place in the working area. In other words, the limit switches provide a starting...

Location sensors

These tell the robot where it, or a particular part of it, is located in space. In the Gantry, for example, it is essential to know exactly where the tool on the x-frame is located. The Gantry can not perform its tasks without this data. For locating a robot or, more often, a part of a robot, over a range of a few tens of millimetres, we can use a technique based on a linear potentiometer. This is a variable resistor of the slider type, such as those often used for setting the frequency...

Machinegun sound effect

This routine generates a burst of white noise which sounds reasonably like a burst of machine-gun fire. It makes a good addition to the repertoire of a military toy robot. The sound is variable so it could have other applications. The random number generator (pp. 161-163) is made to run in a loop, generating a sequence of values of randval at high speed. As each new number is generated, its bit< 7> is read (by ANDing randval with 080h,) and channel RC7 of port C is set to the same value....

Magnetic field sensor

The Hall effect device, which detects magnetic fields, has many applications. Its output is a voltage that varies according to the strength of the magnetic field passing through it. It is sensitive to the polarity of the field. The output from the Hall effect device may be measured as a varying voltage or can be converted into a digital signal as in this circuit. The PIC's built-in comparator can be used instead of the op amp. The output from the Hall effect device may be measured as a varying...

Magnetic probe circuits

Each probe (p. 317) is connected to the controller board by three leads positive supply, 0 V and output. The positive supply and 0 V are connected to pins at the top of the PIC2 board. The output leads run direct to pins 15 (RC1) and 14 (RC2) of PIC1. These are the comparator input pins. The motor control board mounted on the front panel of the Gantry. The y-winch motor Ml can just be seen on the right of the board.

Mode 1 Wanderer

In this mode, the robot bleeps once, then runs across the floor, bumping into furniture, walls and obstacles. Every time it bumps it switches on the LED on the side that it bumped, reverses a short distance, turns away from the side it bumped, switches off the LED and then continues on its way, flashing the LEDs and emitting bleeps as it does so. It repeats this sequence indefinitely. The Quester needs the two bumpers for this mode, but no other sensors. It is a good program for your first...

Mode 2 Light seeker

This program is best run with the robot in a curtained or low-lit room. It works most effectively if there is only one source of light. There should not be any obstacles on the floor. The robot needs the light sensor and the pair of bumpers. The Quester is made to detect the direction of the source by spinning round while continually reading the input from the light sensor. The tube on the light sensor restricts the angle of view to about 10 degrees ahead. As soon as the sensor detects light...

Mode 3 Line follower

The Quester follows a line marked on the floor or other surface. For this task, it needs the pair of infrared sensors. The ultra-bright LEDs on the front panel are not essential, but they add to the visual appeal of the robot, especially when it is operating in low light. It can, of course, operate in darkness or in bright room lighting. There is also the practical point that when the robot is spinning left or right to keep on a curving line, the LED on the side to which it is spinning comes...

Mode 4 Prisoner

This mode requires the pair of IR sensors and, optionally a pair of LEDs and the bleeper. The Quester is placed in an area completely surrounded by a continuous line. It is unable to escape because it is programmed not to cross the line. It wanders randomly and indefinitely within its two-dimensional prison. However, you could leave a narrow gap in the line and see how long it takes to find its way out, and then bleep triumphantly. The flowchart (overleaf) begins with a simple loop that keeps...

Mode select routine

The memory of a PIC is large enough to accommodate several different programs unless they happen to be blockbusters. For this reason it is convenient to have a number of programs in a single PIC chip and to be able to select any one of these at run time. The first program lines after the 'start' label usually initialise the ports and set any options that are in force for the whole program. Immediately after this comes the mode select routine. Leave it out if there is only one program on the...

More mods

For a toy vehicle, an amusing addition to the sensors is a downwardly-directed light sensor underneath, at the front. It could have its own light source, preferably infrared, or rely on ambient light. When the robot is running on a table there will be a change of light level as the front of the vehicle reaches the edge of the table. Program it to respond immediately by backing and turning before going forward again. A sensor that detects the Earth's magnetic field is unusual but inexpensive....

More tasks for the hook

Combining a program similar to the above with the random number routine (p. 161) can be the basis for a game of chance. One version is being played in the photo on p. 353. The playing area is a square of card marked out in, say, 5 rows and 5 columns of squares. The hook picks up the load from a fixed location and deposits it on one of the squares. Players win or lose according to the rules of the game, decided upon beforehand. Add excitement to the game by programming the Gantry to 'change its...

Motion sensors

A tilt switch could help prevent a disaster for a robot travelling on rough or steep terrain. The switch is mounted in the robot so that it is normally in the vertical position. The switch is open in this position. If the body of the robot tilts only a few degrees the switch closes. The simplest way to connect a tilt switch is to a digital channel that has a weak pull-up. Input goes low when the switch is tilted. Vibration switches are relatives of tilt switches. They make and break contact at...

Motor control board

This has an H-bridge for controlling the direction of the motor. It is mounted on the lid, beside the motor gearbox unit (photo p. 180). The motor control board has two connecting sockets for the supply lines. This allows it to be daisy-chained to other boards and units in the system. The motor control board has two connecting sockets for the supply lines. This allows it to be daisy-chained to other boards and units in the system. Connections are made to this board in the same way as to the...

Motor direction control

There are two ways of doing this with a transistor H-bridge, and by a relay. The H-bridge circuit is used in most of the projects in this book. It can be based on BJTs or MOSFETS. The circuit (see opposite) comprises four transistors for controlling one motor. Two of the transistors are npn (Q1 and Q3) and two are pnp (Q2 and Q4). There are two control inputs, A and B, which supply current to the bases of the npn transistors and turn them on when the input voltage is high. They sink current...

Mounting the boards and offboard items

The three boards are each supported on two M3 bolts. The exact positioning depends on the size and shape of the box. Remember to place the Controller board so that it is easy to remove and replace the PIC when debugging the program. Check that the motor and other items on the lid will not come into contact with the boards when the lid is on the box. Leave enough room for the wiring. Drill 3 mm holes in the box for the bolts that support the boards. Drill a hole in the bottom of the box for the...

Moving around

By definition, all mobile robots move from place to place. They need to be able to move forward, to reverse, and to turn to the left or right. Robots are often operated in confined spaces so it useful to be able to spin on one spot. Variable speed is less important and often unnecessary. The Quester (Project 4, p. 258) runs on three wheels. Two of these, to the left and right, are the drive wheels. Each has its own electric motor. The third wheel is a castor, used for balance. The panel on the...

Moving from A to B

The routine for moving from base to (0, 0) is the simplest example of moving from A to B. It is simple because there is only one step to the left followed by one step back. Now suppose the x-frame has already been moved to (0, 0) ready to begin an action that needs it to be somewhere near the centre of the work area. It will probably need to take two or more steps to the left and back to get there. Subroutines are to be called once for each step. Below is the listing for a routine to move the...

Moving from C to D

The AtoB program is a useful one for positioning the x-frame at the beginning of a session. It assumes that it is at (0, 0) and takes it to some other location to perform its tasks. Suppose the x-frame now has to go to another position. One way of doing this is to repeat the routines for moving it to base, then to (0, 0), and eventually to the new location. This takes time and it is quicker to go directly from one location to the next, without visiting base and (0, 0). This is the function of...

Moving the xframe

One of the advantages of a gantry is that the processor always knows where the x-frame is. So one of the important programming tasks is to put it where it should be. As explained earlier, the Gantry locates the x-frame on a square grid. In the prototype there are 6 rows of 6 columns, making a total of 36 locations. There are four core subroutines for moving the x-frame. They move it one step in each direction left, right, back, forward. Here is the listing of left, the subroutine that moves the...

Navigation

Given that a robot is mobile, it seems reasonable for it to know where it is. In practice, this is not as simple as it sounds. There are basic methods of navigation, such as line following, wall following, and homing on a light source. These need the fewest sensors and are the simplest to program. They are are fine for most purposes. Some operations require the robot to move around in 'free space', without reference to lines, walls or beacons. It might be thought that switching on the drive...

O

The prototype Scooter did not need this reinforcement. Because the lever has to turn freely on the pivot it can not be bolted firmly to it, so allowing it to sag. It needs to be thicker. The photo shows the solution. Before drilling the hole for the pivot, two small squares of plastic board are bolted to the lever, using two shorter bolts. Then the pivot hole is drilled through all three layers. The forward stop peg is seen in this photo. Before drilling the hole for the pivot, two small...

Offboard connections

The boards are connected by single-stranded PVC insulated connecting wires. The insulation is stripped from the ends of each wire for about 5 mm. The table below lists the connections needed. Cut the wires as short as conveniently possible. In a few cases, indicated by * in the socket columns of the table, the wires are soldered to the terminals. The positive supply also goes to the off-board LEDs and LDRs. For neatness, this line and the connections returning from the components are best...

Onebit input

The drawings show the main types of circuit to provide digital (high or low) inputs to the controller. The simplest is just a switch between the terminal pin and the 0 V rail. Input is normally logic high, and changes to low when the button is pressed. To use this circuit the channel must have a weak pull-up enabled. This means that it must be one of the channels of Ports A or B. The switch is drawn as a push-button, but there are many types of switch that can be used instead. These include...

Other peripherals

The speaker is a miniature piezo speaker, diameter about 30 mm. It is mounted inside the body just below the head. Drill a cluster of 2 mm holes in the body wall to allow sound to escape and glue the speaker by its rim to the wall, behind the cluster. If necessary, cover the perforated area outside by gluing a circle of fabric over it. Drill two holes in the head to take the pair of LEDs that are its 'eyes'. With Foam Board the hole can be a little smaller than the diameter of the LED. For 5 mm...

Other tools

Screwdrivers are obviously essential but only small sizes with regular blades up to 4 mm wide. Metric bolts usually need a small-size Posidrive screwdriver. A set of jeweller's screwdrivers is useful on occasions. An assortment of small files of various shapes is handy for smoothing cut edges and shaping parts of mechanisms. A set of needle files is also worth having. An engineer's steel rule 300 mm long, graduated in millimetres, completes the tool kit. Things to think about before starting on...

Other tools for electronics

A wire and cable stripper removes the insulation from the end of the connecting wire in a single action. It saves a lot of time. But most wire strippers are designed for use by electricians. They will strip the insulation from hefty mains cable, or TV antenna cables, but not from the thin wires such as we use in electronic hobby projects. Choose with care. Wire cutters of the side cutter type trim the component leads short after they have been soldered to the board or terminal. They give a neat...

Pic Io

For later reference, the table below lists I O connections to the PIC. A photocopy of this table mounted on card is handy to have on the workbench while assembling and testing For later reference, the table below lists I O connections to the PIC. A photocopy of this table mounted on card is handy to have on the workbench while assembling and testing The entries are grouped by I O port and list all the channels available on the PIC16F690. In the fourth column, the I or O indicates whether the...

Pic Io Stepper steering

For later reference, the table below lists I O connections to the PIC. A photocopy of this table mounted on card is handy to have on the workbench while assembling and testing the circuit modules. Reference voltage, Comparator 1(C1IN+) Forward light sensor, Comparator 1 (C12IN-) The entries are grouped by I O port and list all the channels available on the PIC16F690. In the fourth column, the I or O indicates whether the channel is to be configured as an input or an output. AnI is an analogue...

PIC Programming

Branching instructions 141 Mathematical operations 1S7 Steering a mobile robot 144 Random numbers 161 As you can see if you look at the programming examples of the projects, there are program routines that we use over and over again. Some may differ in detail but essentially they are repeats. It makes more sense to save these as separate text files, so that you can load them and put them into your current project. They may need a little editing here and there but this is nothing compared with...

PIC1 controller board

This carries the PIC16F690 that controls the winch motors. The schematic for the board (opposite) shows that it also has push-buttons and a toggle switch for input from the operator. It has two LEDs, one red, one green, and a bleeper for simple output signals to the operator. The board has wired connections to the PIC2 board. This requires three wires signal from PIC1 to PIC2, signal from PIC2 to PIC1, and 0 V running from the front panel to the x-frame. The wires could get in the way of...

PICs and robots

The robot projects in this book are based on the PIC16F690 microcontroller, made by Microchip Technology Inc. But all PICs have a common basic architecture and electrical properties so the circuits described in this book can usually be made to work with several other types of PIC. Programming a PIC wwwwwwwwwwwwwwwvwwwwwB The PIC16F690 is especially suitable for hobby robotics because It uses the latest nanoWatt Technology. The standby current is only 1 nA when operating on a 2 V supply. At the...

Pins and ports

The F690 version that we describe here has a 20-pin double-in-line package (opposite). Other packages are obtainable, such as surface-mount devices, for example. All pins except 1 and 20 are available for use as input output pins. Those of Ports A and B can be individually set to have built-in pull-ups when configured as inputs. Also, as inputs, they can be programmed to cause interrupts when the input signal changes. Certain of the pins, though usable for simple input or output, can be...

Power control board

Note the common 0 V line. The power supplies for the PIC1. Note the common 0 V line. board FromS2 From SI board board FromS2 From SI board D1 and D2 are mounted on the reverse side of the board TP2, TP3 and TP5 are 1 mm plain pins switching board for the PIC1 system. This is bolted to the inside of the left side panel, low down and near the front. The bolts are 25 mm long and the LEDs at the rear of this board project through 5mm holes drilled in D1 and D2 are...

Programming

Unfortunately, their precision is low but they are fun to experiment with. The most practical solution is a gantry, described in the next section. A gantry robot operates over a clearly defined rectangular area. It picks up objects from any point in the area and sets them down at another point in the area. The tool (often a gripper) is suspended from a small trolley-like frame, and can be lowered and raised. The frame has wheels and runs on a pair of rails so that it can travel from one side of...

Programming a PIC

A controller operates according to a program. This is stored digitally in the controller's memory in the form of a code, called machine code. This code is very difficult to write by hand but, fortunately, a computer can help. Using special software, the program is typed in as a sequence of understandable instructions (or mnemonics) for the controller to execute. The software assembles the machine code from these instructions. A PIC (top centre) being programmed in a programming deck. This is...

Programming the brush

Like the hook, the brush is raised and lowered by motor M3, but it has only one limit switch. This is closed whan the brush is resting on the paper or is down into the paint in the well. It opens when the brush has been lifted high enough to clear the rim of the well. The sequence of a typical painting program is (1) move the brush to the well and dip it in the paint (2) raise it and move it to the beginning of the stroke (3) lower it on to the paper (4) move it to the end of the stroke (5)...

Programming the camera

The camera has a light dependent resistor, connected as a potential divider (p. 75). It can be used to measure the level of laser light reflected from a target (playing piece, playing board, maze map) in the working area. Instead of the laser, the light source may be one or more LEDs, or the ambient room lighting. When using the camera, the map or other target is best supported about 60 mm below the camera lens to bring it into focus. For distinguishing between white (or a light tone) and black...

Programming the gripper

The gripper is raised and lowered by the same mechanism as the hook, so the programming if up down actions is the same, including the feedback from the two limit switches. In addition, the gripper motor has to be controlled by on off and open close signals, and there is a limit switch that closes when the jaws close. One way of treating the programming is to make this an example of distributed processing. PIC1 controls the three winch motors and the sequencing of the operation. We use a second...

Programming the laser

The laser can operate as a simple pointer. In a board game, for example, it points to the piece it wants to move. Its other use is for scanning the working area. If it is solving a maze, the Gantry uses the laser to scan the map of the maze. It scans the map into its memory, then solves the maze logically, and finally uses the laser beam to trace out its calculated path through the maze. The laser can also operate in conjunction with the camera, as explained in the next section.

Projects

That was the cookbook now for some menus Part 6 takes the mechanical, electronic and programming ideas of Parts 3 to 5 and puts them together to make robots. If the individual ideas are the recipes for the courses, the robots are the tasty meals. Part 6 shows five ways of combining some of the ideas, but these are not the only ways of putting them together. For instance, take the infrared sensors of the Quester and put them on the Android. Then add the maze-solving routines of the Gantry. That...

Proximity sensors

A robot may frequently need to know if it is near to something such as a wall, the leg of a chair, or an object blocking its path. One approach is to install bumpers with microswitches to detect actual physical contact. The Quester has these. Generally it is better to detect objects when they are near by, but before actually running into them. The light sensors of the Scooter do this by responding to light reflected back from the object. The more light reflected, the nearer the object. The...

Pulley

The completed y-frame, showing the x-winch motor mounted on the motor panel at the left-hand end. The pulley for the counterweight cord is at the right-hand end. As shown on the right, the cross-members project beyond the width of the frame. The base-plates are approximately 16 mm square, so the cross-members need to project 17 mm on each side. The total length of a cross-member is (spacing between x-rails) + (width of channelling) x 2 + (projection) x 2 In the prototype, the dimensions are 57...

Pulley wheels

A pulley is a wheel with a grove around its rim, known as a race. Pulley wheels are mainly used for the transfer of force. In the Gantry, for example, they transfer the force of gravity to the chassis to pull it along the tracks when the winch unwinds. They are also used in the pulley system that raises and lowers the hook and some other tools. Another way in which force is transferred is by a belt drive between two pulleys. A pair of pulleys of equal diameter simply transfer force over a...

Road wheels

The main points about a road wheel are its diameter and the nature of its tread. A larger diameter is better on a rough or uneven surface because the wheel can more easily ride up over ridges and is less likely to get stuck in grooves. Also it allows there to be a larger clearance between the surface and the underside of the chassis. If the surface is smooth and even, for example the rails of a gantry, small wheels have the advantage of light weight. It is all too easy for a robot design to...

Robot Mechanics

The materials for building the body or framework of the robot must be strong enough for the job, easy to work, durable and low cost. Also it should look good have a shiny or attractively coloured surface. Some kinds of plastic food container have all of these qualities. Project 6.1 illustrates how to build the robotic mechanisms and circuits into a ready-made box. If there happens to be a spare unused box in the kitchen cupboard, it costs nothing. The main snag is that it may not be exactly the...

Scissors Paper Stone

For scissors, the hand is flat with the second and third fingers spread apart. For paper, the hand is flat with fingers together. For stone, the hand is clenched in a fist. On a given signal, the players swing their hands forward and upward to reveal their choice of scissors, paper or stone. If they have both chosen the same, the result is a draw but, if they have chosen differently, the winner is decided like this Scissors wins against paper because scissors cut paper. Paper wins against stone...

Seeking the light

In this program, the Scooter is set down in a room which has fairly subdued lighting. There is one brighter souce of light which may be either a table-lamp on the floor or (in daytime) a window with a low sill. The robot's task is to locate this source and to move toward it. The program is also an example of how to use the PIC's comparators. Before going on to the light-seeking program, here is a program intended for running while setting the variable resistor VR1 (p. 176). A diagnostic program...

Sensors

A robot needs to be aware of what is happening in the world around it. That is why all our robots are equipped with several sensors linked to the controller. This section lists sensors that are often used in robotics. Resistive sensors respond to changes in a quantity such as light or position and their response is a change in their resistance. A change in resistance is easily measured by passing a current through the sensor and generating a changing voltage which is sent to the controller....

Servomotors

A servomotor is designed to move to a given angular position. The motor has three connections to the control circuit. Two of these are the positive and 0V supply lines. The third connection carries the control signal from the control circuit, which may be a microprocessor. A small servomotor of the kind used in flying model aircraft and robots. The 'horns' (white levers) are used for connecting the motor to the mechanisms that it drives. The rotor of the motor has limited ability to turn....

Shopping list electronic

Ci polyester capacitor, 100 nf IC1 PIC16F690 20-way d.i.l. turned pin ic socket socket strip 2 x 12 sockets stripboard 17 strips x 12 holes Q1, Q3 BC639 npn transistor (2 off) Q2, Q4 BC640 pnp transistor (2 off) socket strip, 2, 3, and 6 sockets stripboard 8 strips x 21 holes VR1, VR2 horiz. trimmers 100K (2 off), optional socket strip, 3, 4, 5, and 8 sockets - D3 5 mm light emitting diodes, ultra bright (3 off) LDR1m LDR2 light dependent resistors (ORP12 or similar) S1 spst mini toggle switch...

Shopping list electronic 1

Ci polyester capacitor, ioon. C2 polyester capacitor, ion. 20-way d.i.l. turned pin socket. 2-way screw terminal. 0.9 mm PCB terminal pins (17 off). Stripboard 13 strips x 20 holes. Q1, Q3, Q5, Q7 BC639 npn transistor (4 off). Q2, Q4, Q6, Q8 BC640 pnp transistor (4 off). PCB plugs 4-way (2 off). 2-way screw terminal. Stripboard 16 strips x 21 holes. 53 miniature 3-pole, 4-way rotary switch. 0.9 mm PCB terminal pins (19 off). Stripboard 11 strips x 14 holes. R1 light dependent...