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.

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...

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...

Bits

Terms used in all the descriptions are defined as follows. The bits of a byte are numbered from right (bit 0, the least significant bit or LSB) to left (bit 7, the most significant bit or MSB). When we refer to a bit in a given register, we give the register name followed by the bit number in angle brackets. For example, the bit called RB5 (bit 5 of PORTB register) is referred to as RB< 5> . This is the convention used in the PIC data sheets. A range of bits is defined by quoting its most...

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...

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...

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...

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....

Controller board

This is the same as the controller board of the Scooter (p. 174) but has three pull-up resistors added to it. These are 10 kQ resistors soldered between E2 and F2, between E3 and G3, and between E4 and H4. The controller board is bolted to the shelf on the right and close to the front (see photo overleaf) where it is easy to remove and replace the PIC. Before wiring up the board, the programming of the stepper motor of the arm was developed and tested. The motor is on the right-hand wall, with...

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...

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 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...

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...

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...

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 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

The circuit is the conventional H-bridge. The PCB layout is seen opposite. This version of the circuit provides for two motors operating independently. The connection to the PIC, the control input, is a 4-way header plug on the left in the figures. The output to the two motors is another 4-way header plug, on the right. Check the completed board in the usual way by testing continuity and the absence of short circuits. For a functional test, temporarily connect the motors to the 'Out' terminal....

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...

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...

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...

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 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.

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 1

Si, S2 miniature toggle switches, spst or spdt. Ri R4 resistors 470R (2 off). R2, R3 resistors 47R (2 off). Ci capacitor, polyester, 100 nf. Di, D2 light-emitting diodes 5 mm (1 red, 1 green). Q1, Q2 npn transistors, BC548 or similar. PL2, PL3 2-way plug and socket (2 off). S1, S2 push-to-make push-buttons, PCB mounting (2 off). S3 miniature toggle switch, spst or spdt. IC socket, 20-pin d.i.l., turned pin. PIC2 Controller and tool motor control board R1 resistor 47R. C1 capacitor, polyester,...

Shopping list electronic 2

IC sockets (14-pin 3 off, 16-pin 1 off). PL2, PL3 PCB plugs and sockets 4-way (2 off). VR1 miniature preset potentiometer, 470 k. 0.9 mm terminal pins (5 off). Stripboard 5 strips holes. LDR1 light dependent resistor (ORP12 or similar). UGN3503U Hall effect magnetic sensors (2 off). Laser pointer. Ferrite magnets 10 mm X 10mm X 4 mm (12 off or more). Battery holder, 8 x AAA or 8 x AA, with wire or stud terminals. Battery holder, 4 x AAA or 4 x AA, with wire or stud terminals. PP3 type...

Shopping list mechanical

3 mm expanded PVC board or plywood approx. 140 mm X 166 mm. Balsa, 13 mm X 13 mm X 2 m. Craft glue (Tacky glue). DC motor and gearbox with output shaft on both sides. DC motor and gearbox, or stepper motor for steering. Pair of wheels, with tyres, about 60 mm diam. Metal tubing to fit into wheels and fit over drive shaft of motor. Pulley wheels (2) about 25 mm diam for arm. Insulating tape, coloured, for decorating robot body. Nuts and bolts, mainly M3, bolts 6 mm and and 10 mm long. This robot...

Song and Dance

A routine for producing a square-wave tone is described on pp. 150-155. This produces a single burst of sound at a given frequency and of a given duration. But before it can do this it needs three values to work on. It also needs editing to produce the sound signal at the specified pin. In the Android, the speaker is driven from Port B, channel RB5. Edit the listing to read portb instead of portc, trisb instead of trisc, and portb, 5 instead of portc, 0. To obtain the pitch of...

Sound sensors

The circuit shown below has a microphone to detect sound, an amplifier to increase sensitivity and a trigger circuit to send a logical high output to the controller when sound is detected. A crystal microphone generates a voltage spike that is amplified and used to trigger a flip-flop. A crystal microphone generates a voltage spike that is amplified and used to trigger a flip-flop. The voltage spikes across R1 are fed to the op amp. This is operating without feedback, as a comparator, so its...

Special function registers

These registers control all aspects of the operation of the PIC. They can be written to or read from as a whole byte of data or as individual bits. In some cases the bits are readonly or write-only. These, together with the 8-bit working register (known as w), are where the action is. The Special Function registers are located in four areas of memory, of which we can access only one at a time. These areas are named Bank 0 to Bank 3. Some registers, such as the STATUS Register, appear in the...

Steering

Steering is more of a problem because the front wheels are not able to turn from side to side. Also the front wheels are closely surrounded by mudguards so there is little space around them in which they could be turned if remounted. The answer to this is to raise the existing front wheels off the ground by a steering assembly similar to, but simpler than, that used in the Android. The similarity is that the wheels are a pair of Lego wheels with tyres (left below). The brick has a 4.5 mm hole...

Steering by stepper motor

The ordinary DC motor, M2, is replaced by a stepper motor of the same type as used for the arm. It has the advantage of more accurate and probably faster changes of direction. It might be more compact, too. The arrangement of motor control board is amended to a single H-bridge board for M1, the drive motor. This would be like the board used in the Scooter, p.175. The new steering motor, which is referred to as M2, needs a second control board like that used for M3.

Steering control

A pulse with the duration of a single call to delay is sufficient to turn the wheel fully in either direction. To steer straight ahead, first send a pulse to turn the wheel fully to right or left. Then send a shorter pulse to nudge the wheel in the opposite direction and into the forward (mid-way) direction. The pulse is obtained by calling shortdelay with 040h as the initial value of delay1. Adjust this value to suit your motor. The two pulses take only a fraction of a second, so the effect is...

Stepper motors

A typical stepper motor has four sets of coils, arranged so that the rotor is turned from one position to the next as the coils are energised in a fixed sequence. This is listed in the The sequence repeats and at any step, two coils are on and two are off. The sequence of pulses needed to drive the motor can be provided by a microcontroller. The sequence of pulses for running a stepper motor. The sequence of pulses for running a stepper motor. To get from step to step, first coils 1 and 2...

Summing up

Select a box of suitable shape (squarish), size (about 120 mm to 150 mm square), and material (non-brittle, drillable, cuttable plastic). Plan the layout of motor, gearbox , drive wheels, and castor. Try to give the robot as much clearance as practicable between its underside and the surface. For stability, the drive wheels should be as far back and as far apart as possible. The gearbox ratio should give the Scooter a speed in the range 20 cm s to 50 cm s. Ensure that the drive wheels do not...

The PIR1 and PIR2 registers

The two Peripheral Interrupt Request registers are helpful when you need to know the current state of the PIC's built-in peripheral devices. These are the analogue-to-digital converters, the USART receiver and transmitter, and the comparators. On being interrupted, the PIC goes to the interrupt service routine (ISR) and reads data from each of several sources to find out the reason for the interrupt. But reading from these devices before they have completed their current processing gives a...

Thermal sensors

You might design a robot that is attracted by the cosy warmth of your fireside, or an industrial robot might be programmed to enter danger areas and report back on the temperature there. In either case a thermal sensor is required. The most often used sensor is a thermistor. This is a resistive sensor. The negative temperature coefficient type, which is the type used for temperature measuring, decreases in resistance as temperature rises. Unfortunately its response is not linear. This means...

Varible speed control

The idea is that power is supplied to a motor as a stream of pulses. The pulses are at the full supply voltage (or the voltage available from an H-bridge) but the ratio between the length of a pulse and the interval between pulses can be varied by programming. The shorter the pulse and, therefore, the longer the interval, the lesser the power delivered to the motor and the slower it turns. This way of controlling speed is preferable to varying the voltage. It...

What sort

The first question is 'What sort of robot do we want to make '. When they hear the word 'robot', many people immediately think of the R2-D2 or the robots of the film I, Robot. These are robots similar to humans in some ways, but not in all. There are many kinds of robot, one major group being the mobile robots, sometimes called mobile platforms. Examples of mobile robots include the human-like robots mentioned above and a wide range that mimic animals. Some walk about on six legs, like insects,...

Wiring up the tools

Several of the tools have microswitches to provide feedback to the processor. One side of the switch is connected to 0 V. The other side goes to an input channel that has been defined as a digital input with a weak pull-up. Any of the spare channels in Ports A and B can be used (see table on p. 332). The hook is raised and lowered by the tool winch. There are two microswitches, MS1 and MS2 (p. 309). The switches operate by grounding the input. There are three leads from the pulley block to the...

Wood

Wood is rarely thought of as a robot-building material but, at times, it can be just what we need. It is strong for its weight and easily cut, drilled, painted, carved and glued. As well as a wide range of building and joinery timbers, mostly too large for robot making, DIY and model-maker's stores sell a very easily workable timber known as Balsa. Because of its low density and easy workability it is a firm favourite with flying model aeroplane constructors. For the same reasons it is useful...

Shopping list electronic

R2, R4 resistors, 22k (2 off). VR1, VR2 miniature preset potentiometers (trimpots) 100k (2 off). D1, D3 infrared Light-emitting diodes, 5 mm (2 off). D2, D4 infrared photodiodes, BP104 or similar (2 off). ici cmos 4011 quadruple nand gate. 3-way PCB plugs and sockets (2 off). 14-pin d.i.L. ic socket. 0.9 mm VCB terminal pins (4 off). Stripboard, 15 strips x 22 holes. Materials for the shields. R1, R2 resistors, 10k ((2 off). 2-way screvj terminal. MS1, MS2...

Software for programming

The most direct way of programming a PIC is first to write the program in assembler, using a simple text editing program such as Notepad. This, or something similar, is provided as part of the Windows package. The top photo opposite shows a screen-shot of an assembler listing in Notepad. When the file is saved, Notepad creates a file in text file format .txt . When asked for the file name to save it under, type the name with the extension '.asm' not '.txt', and not without an extension . It is...

The Intcon register

Pin Layout Pick 16f88

This register controls the processing of interrupts. The bits of interest are lt 7 gt GIE 1 interrupts enabled, 0 interrupts disabled. This bit is used to switch all interrupts on or off with a single command. lt 6 gt PEIE 1 enable peripheral interrupts, 0 disable these interrupts. lt 5 gt TOIE 1 enable timer TR0 overflow interrupts, 0 disable. lt 4 gt INT 1 enable INT interrupt, 0 disable. The INT interrupt is an external interrupt occurring when RA2 changes. The direction of change that...

Owen Bishop

AMSTERDAM BOSTON HEIDELBERG LONDON NEW YORK OXFORD PARIS SAN DIEGO SAN FRANCISCO SINGAPORE SYDNEY TOKYO Newnes is an imprint ofElsevier Linacre House, Jordan Hill, Oxford OX2 8DP 30 Corporate Drive, Burlington, MA 01801 Copyright 2007, Owen Bishop. Published by Elsevier Ltd. All rights reserved The right of Owen Bishop to be identified as the author of this work has been asserted in accordance with the Copyright, Designs and Patents Act 1988 No part of this publication may be reproduced, stored...