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

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

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

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

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

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

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

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

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

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

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

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

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

O

The drive wheel assembly consists of a 6 V motor with gearbox and an output shaft on either side. The wheels are approximately 56 mm diameter. We used the same assembly as in the Scooter (pp. 169170) but with the shafts cut shorter so that the wheels are 104 mm apart (centre to centre). The steering wheel assembly consists of a pair of Lego wheels clipped to a special brick, as in the Scooter. The steering gearbox is built from Meccano parts. The motor with gearbox has a worm gear on its 4 mm...

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

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

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

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

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

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

Box, squarish, made of non-brittle plastic, possibly transparent. DC motor and gearbox with output shaft on both sides. Pair of wheels, with tyres, about 60 mm diam. Metal tubing to fit into wheels and fit over drive shaft of motor. Pulley wheel(s) about 25 mm diam for castor, with shaft about 40 mm long. Material for making castor wheel bearings. Nuts and bolts, mainly M3, bolts 6 mm and 10 mm long. The robot is controlled by a PIC16F690 microcontroller. Several other types of PIC could be...

Simulating the PIC

The software supplied with a programming deck usually includes its own assembler and, as already mentioned, may have a BASIC or C compiler built in to it. On the computer screen, type in the program (or part of it) using a text editor. This is usually supplied as part of the programming software, or use Notepad, which comes in the Windows package. Next comes the simulator. The simulator is another item which is provided with the programming software. It runs on the PC but behaves just like a...

Soldering tools

A soldering iron is an essential item. A soldering station with thermostatic control is nice to have but a simple electrically heated iron will do. The main points are that it should be low power, about 15 W, and the bit should be no more than 2 mm in diameter. If you have several models of iron to choose from, select the one with the above features and with a light-duty power lead. Some makes of iron are spoilt by having a heavy duty power lead capable of supplying a 1 kW device. The thick...

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

Speaker drive

A piezo speaker can be driven directly from a PIC output. The circuit is given on p. 90. If the sound is not loud enough, use a transistor switch to drive an 8 Q speaker. The circuit has the speaker in its collector circuit and needs a protective diode (see the drawing on the right, p. 91). With a 6 V supply and an impedance of 8 Q, the current has a maximum of 750 mA. Build the switch on a small board with no resistor in series with the speaker and a base resistor of 470 Q. Alternatively, and...

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.

Stepper motor control board

This interfaces the controller with the stepper motor inputs and consists of four transistor switches. The schematic of one switch is on p. 99. The circuit board layout is below. This board is run on the same supply as the controller (6 V), or its supply could be at higher voltage if the motor needs it. Top to bottom A2, B2, B3, -, Al, -, Bl, A3 The stepper motor (M3) control board. The board is most conveniently located at the back right of the shelf, next to the controller board.

Stepper motors

As their name suggests, stepper motors turn step by step. The commonest type has a step size of 7.5 , so that it takes 24 steps to make one revolution. This produces a slightly jerky motion but it is satisfactory for most purposes and the programming is simple. This description refers to unipolar stepper motors which have permanent magnets and 7.5 steps. The motor generally has six wires, which are connected to the windings as shown in the drawing opposite. The two windings of the stepper motor...

Stepper steering

Alternatively, the off-board connections and the I O table for this are on pp. 232-234. 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...

Switching board

This is the name given to the board that interfaces the PIC to the sensors and to the actuators other than the motor. There is room for a second board of this kind if the system is expanded later. Schematic and layout diagrams are overleaf. It is possible to provide current for LEDs directly from a PIC output, but this should not be more than 20 mA. This project uses high intensity LEDs to provide illumination for the light-activated proximity sensors. The LEDs require up to 70 mA each, so must...

The demo board

The PICkit 2 Low Pin Count Demo board has four LEDs driven by output channels at RC0 to RC3. These are useful when debugging a program, to indicate the state of the outputs. If your program has to send output signals through other channels, it may be possible to send them to RC0 to RC4 while the program is being developed, then change the destinations later after the program has been debugged. The board also has a push-to-make push-button SW1 on its front left corner. This is connected to...

Tool system

The tools and sensors used in controlling the tools are all under the command of a second PIC. This is referred to as PIC2. Its board is on the x-frame. Another function of this controller is monitoring the location of the x-frame. Only one tool is attached to the frame at any time, so most of the I O channels of PIC2 lead to terminal pins. There are more than enough pins to spare for the tools described on pp. 308-319, and for any that you are likely to design and build yourself. To save space...

Transistor switches

A device that requires more than 25 mA is driven by a transistor switch. Most often the transistor is an npn bipolar junction transistor, but n-channel MOSFETs are also used. Transistor switches are used for high-power LEDs, sirens and buzzers, motors, solenoids, speakers, relays and many other devices. The devices are referred to as 'the load' in the discussion that follows. non-inductive and (right) inductive loads. The current limiting resistor, R1, may not be necessary. The load is switched...

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

Wheels and steering

The Scooter has three wheels, which gives it stability on slightly uneven surfaces. It is interesting to contrast the wheel system of the Scooter with the very different system of the Quester. The Scooter's two front wheels are on the same shaft so it needs only one drive motor and only one motor control circuit. This makes the robot easier and cheaper to build. The third wheel is a castor. How this is constructed depends on what type of small wheel is available. We used a pair of Lego wheels,...

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