Silicon ChipPICMAN Programmable Robot - January 2000 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Switch those computers off when not in use
  4. Feature: Protel 99: Much More Than A PCB Design Tool by Peter Smith
  5. Review: B&W Nautilus 801 Monitor Loudspeakers by Louis Challis
  6. Serviceman's Log: They came in two by two by The TV Serviceman
  7. Project: Spring Reverberation Module by John Clarke
  8. Project: An Audio-Video Test Generator by Leon Williams
  9. Product Showcase
  10. Project: PICMAN Programmable Robot by Andersson Nguyen
  11. Order Form
  12. Project: Parallel Port Interface Card by Peter Smith
  13. Vintage Radio: Building a vintage radio replica by Rodney Champness
  14. Project: Off-Hook Indicator For Telephone Lines by John Clarke
  15. Book Store
  16. Back Issues
  17. Market Centre
  18. Advertising Index
  19. Outer Back Cover

This is only a preview of the January 2000 issue of Silicon Chip.

You can view 33 of the 96 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Items relevant to "Spring Reverberation Module":
  • Spring Reverb PCB pattern (PDF download) [01101001] (Free)
Items relevant to "An Audio-Video Test Generator":
  • Audio/Video Test Generator PCB pattern (PDF download) [04101001] (Free)
  • Audio/Video Test Generator panel artwork (PDF download) (Free)
Items relevant to "Parallel Port Interface Card":
  • DOS and Windows software for the Parallel Port Interface Card (Free)
  • Parallel Port Interface Card PCB pattern (PDF download) [K2805] (Free)
Items relevant to "Off-Hook Indicator For Telephone Lines":
  • Telephone Off-Hook Indicator PCB pattern (PDF download) [12101001] (Free)
  • Telephone Off-Hook Indicator panel artwork (PDF download) (Free)

Purchase a printed copy of this issue for $10.00.

Remember PACMAN, that ubiquitous computer game of a decade (or so) ago? Here’s the new millenium version – PICMAN 2000 – only this one doesn’t run around a screen and chomp dots. He runs around, well, anywhere you tell him to. That’s ’cause PICMAN 2000 is a programmable robot and obeys your every command. PiCMAN A PROGRAMMABLE ROBOT 56  Silicon Chip P ICMAN 2000 is driven by a single PIC16F84 microcontroller and will perform up to fifty combinations of manoeuvres involving left and right, forward and back movements and a pause. Like all good robots, he lets you know when he’s turning and stopping with his built-in turn indicators and brake light. It’s a simple project which we believe will be very popular with schools as they move into this new phase of the information technology age. PICMAN 2000 will not only give hours of entertainment, it will teach a lot about how basic microcontroller programs work. Build PICMAN 2000 now and you could become the twenty-first century’s Bill Gates! Apart from the PIC microcontroller, there are not very many other components – just a few to supply appropriate power to the robot’s drive motors. There are also a few switches which not only control various functions (such as power on/off, speed, etc) but also allow you to program the PIC (and therefore the robot). Finally, there are the previously-mentioned blinkers and stop light which are LEDs driven directly from the PIC chip. Unlike some previous robots, PICMAN 2000 has a single 6V supply derived from 4 x AA cells. This provides power for both the logic circuitry and the motors. And also unlike some previous robots, the motors power the back wheels with a free-turning front wheel (castor). With the exception of the battery pack, three switches and the rear (brake) LED, all of the electronics is assembled on a single PC board. Mechanically, everything is mounted onto two small pieces of clear acrylic sheet (although other materials could be substituted) which are themselves glued to two back-to-back stepper motors. The drive shafts from the stepper motors are fitted with cogs which friction-drive the large rubber-tyred wheels. Turning is achieved by driving one wheel faster than its mate or even one wheel in a reverse direction to its mate. The circuit Fig.1 shows the PIC16F84 to be the heart (or brains) of the circuit driving PICMAN 2000 with PORTB outputs (RB0 to RB7) driving the four windings in the two stepper motors through pairs of NPN/PNP power transistors in a bridge or “H” configuration. RB0-RB3 drives the two fields of the left stepper motor and likewise, RB4-RB7 drive the right motor. Each end of each stepper motor winding is connected to the common emitter of a BD139 (NPN) and BD140 (PNP) transistor pair. Their common bases are biased by a single 100Ω resistor connected to the PORTB terminals. In this way, a low signal from the port would allow grounding of the end of the associated field. PORTB also doubles as the programming inputs to the PIC, depending on whether S2 is set in the PROGRAM or RUN mode. S1 turns the robot on, connecting 2000 DESIGN BY ANDERSSON NGUYEN Above photo shows PICMAN 2000 going away from you, while the shot on the facing page is comin’ right at ya! The front wheel doesn't steer: all direction control is performed by the instructions you give to the PIC which in turn drives the stepper motors. January 2000  57 Fig.1: the circuit might look complicated but it really is very simple, thanks to the PIC microcontroller. both the motor drivers (directly) and also the PIC chip through a reverse polarity protection diode, D10. This diode also drops the IC supply voltage to around 5.4V. Although the PIC can handle 4.56V, it is better to keep the supply in the middle of these extremes. MCLR (main clear) is also held high by this 5.4V rail. When in RUN mode, 6V is applied to the collectors of all BD139s, with 58  Silicon Chip the collectors of all BD140s earthed. A high signal from any of the PORTB outputs would take the base of the associated BD139 and BD140 high. Take, for example, when RB0 (pin 6) goes high. This would turn on transistor Q1 (NPN – BD139) and ensure Q2 (PNP – BD140) is turned off. Therefore the emitters of both transistors, along with one end of the attached field winding, would be raised to about 5.5V (allowing for some voltage drop across the transistor). Since the PORTB outputs are usually low, the bases of transistors Q3 and Q4 would be pulled low by RB2 (pin 8). The BD139 would be turned off while the BD140 would be turned on, effectively grounding the opposite end of the field winding. The field winding is energised, causing the motor to step forward. Conversely, a high on the bases of transistors Q3 and Q4 (with Q1 and Fig.2: the component overlay shows just how simple the electronics are – just a microcontroller and a few other components. Inset below is the DIP switch showing which switches do what! Q2 bases low) will cause the field to be reversed. It is a requirement of the particular stepper motors used that one field is activated in one polarity, then the other field is activated with this same polarity. Then the first field is reversed followed by the second field being reversed. This cycle is repeated to cause the motor to run in one direction. In order to reverse the motor, the sequence is applied in reverse order. In moving forwards, the two motors are driven in the same direction. In turning one is driven forwards, the other in reverse depending on the turn involved. In this way, a very tight turn arc is achieved. All these motor sequences are possible thanks to our nifty PIC! But that’s not all! In the program mode (when S2 is switched to PROGRAM ), PORTB is converted to act as inputs, switching power to D1-D8 and causing RA0 to go high, previously held low by the 10kΩ resistor to earth. D9 drops the input voltage to match the supply voltage to the PIC. D1-D8 serve the same purpose, in addition to isolating the PORTB terminals from each other, which could happen via DIP switches DIPa-DIPh. The terminals of PORTB are each held low by a 2.2kΩ resistor. Being significantly higher in value than the bias resistors (100Ω), these have no bearing on operation in RUN mode. Each of the diodes D1-D8 is connected to the terminals of PORTB via the programming DIP switches DIPa-DIPh. These enable the instruc- tions to be entered, effectively as an 8-bit binary code. DIPa = back, DIPb = left, DIPc = stop (pause), DIPd = right, DIPe = forward while DIPf,g,h represent the 3-bit binary code for the number of steps the robot will take with that instruction. For example, if DIPe is set along with DIPf and DIPh, and this is entered as the instruction and then executed, the robot will turn right for five arbitrary preprogrammed units of angular displacement. The programming is such that a turn of five units brings the robot around 90° and so a turn of one unit will turn the robot about 18° (with allowance made for any slippage, whether in the drive mechanism or between the wheels and floor). Similarly, a setting of DIPa and DIPf will cause PICMAN 2000 to move back an arbitrary preprogrammed distance of almost exactly 15cm. With these variations in addition to the 50 possible instructions, an immense number of permutations of manoeuvres may be carried out. The program switch array may then be separated into two areas, one being the command switches, the other being the magnitude (steps) switches. The command switches operate on a lowest significant priority. For example, if DIPa and DIPd were both set and entered as the instruction, the accepted command would be a ‘back’ command since DIPa is lesser in significance. There is, however, one exception, which occurs when both DIPa and DIPe are set. This is recognised as a repeat command and when encountered, the robot will return to the beginning of the instructions and execute them again from there. It is possible to enter instructions after the REPEAT instructions but these will never be acted upon. It should be noted that the REPEAT is infinite although at least one of the magnitude switches must be set. Irrespective of what state the magnitude switches are in, if none of the command switches are set and this instruction is entered, this is accepted as an ‘end of instructions’ command and is registered by the two blinkers turning on and staying on. No more instructions are accepted after this. In practice, it is not necessary to enter this instruction since, whenever switching to RUN from PROGRAM, the last entered instruction is recognised as the last instruction. If none of the magnitude switches are on when an instruction is entered (other than the ‘end of instructions’ instruction), there will be an error message indicated by the flashing of the brake light five times in rapid succession. The instruction can then be reentered with alteration to the magnitude switches. This mechanism prevents the robot from being instructed to perform an illogical operation such as: ‘forward 0 units’. In PROGRAM mode, power to the collector of the BD139s is removed to ensure that the setting of the program switches doesn’t energise the motors. C3 serves to hold the supply voltage January 2000  59 when S2 is switched from RUN to PROGRAM because there is a brief instant when PORTB is still acting as outputs and if any of the program switches are set, then this results in a short. Without C3, the IC powers down briefly but enough to cause all memory to be reset. RA4 is normally held low by a 10kΩ resistor to earth. To enter/execute or pause, it is pulled high by the momentary-acting pushbutton switch, S3. This switch is responsible for entering the instructions in PROGRAM mode. After each entry, the brake light will turn on and stay on for a duration of about one second. During this period, another instruction may not be entered. This delay prevents switch bounce from causing incorrect entries. In RUN mode, S3 will start the execution of the entered program. While the program is running, pressing S3 will cause it to pause indefinitely until S3 is once again pressed. At the commencement of execution of a program, the brake light will come on for a brief moment before the robot actually acts on its first instruction. When paused, the brake light will again be illuminated briefly before extinguishing. When instructed to PAUSE (in programming), the robot stops and the brake light slowly flashes to distinguish it from an external instruction to pause. Fig.3: compare the mechanical drawings above with the photos below and you’ll get a good idea of how PICMAN 2000 goes together. Drive is directly onto the rubber tyres from the stepper motors – it’s essential to get a good tight fit! The photo at right shows where the battery pack goes. It’s held in place simply by the switch at the front. 60  Silicon Chip Fig.4: these diagrams will assist you in constructing the various pieces for the PICMAN 2000 robot. All are to scale so you can also use them as drilling templates. Saves a lot of messy measurement, doesn’t it? January 2000  61 Parts List 1 PICMAN 2000 PC board, code 11101001 1 acrylic chassis, cut to size from 126mm x 3mm diameter circle 1 acrylic plate, 60 x 50 x 3mm 1 aluminium angle bracket, 70 x 25 x 25mm; 2 wheel brackets, 40 x 25 x 3mm 2 50mm rubber-tyred trolley wheels, 1/4-inch axle 1 30mm wheel castor 2 4-wire stepper motors 1 8-way DIP switch 1 SPDT mini toggle switch 2 SPST mini toggle switches 1 momentary pushbutton switch, PCB mounting (eg DSE P-7572) 1 4 x AA battery holder (flat type) 4 AA batteries (pref. alkaline) 4 32 x 3mm bolts & nuts 4 22mm spacers 2 ¼” x 1¾” bolts 4 nuts to match 4 shakeproof washers 2 plain washers 20 PC pins 1 18-pin IC socket 1 16-pin IC socket Semiconductors 1 programmed PIC16F84 (IC1) 2 5mm yellow LEDs (LED1, 2) 1 10mm RED LED (LED3) 1 IN4004 power diode (D10) 9 IN4148 signal diodes (D1-D9) 8 BD139 NPN transistors (Q1, 3, 5, 7, 9, 11, 13, 15) 8 BD140 PNP transistors (Q2, 4, 6, 8, 10, 12, 14, 16) Resistors (0.25W, 1%) 1 15kΩ 2 10kΩ 8 2.2kΩ 3 220Ω 8 100Ω Capacitors 1 100µF PC electrolytic 1 180pF disc ceramic 1 100pF disc ceramic Miscellaneous   Solder, hook up wire, contact adhesive etc. RA1 and RA3 of PORTA drive the right and left blinker LEDs respectively via 220Ω resistors. These flash and indicate the appropriate turn. At the end of execution of all entered instructions, both will flash repeatedly to indicate the end of the task (unless a repeat instruction has been included). At this point, the robot may be instructed to execute again, or a new program may be entered by changing to RUN mode. After executing the 50th instruction, both blinkers and the stop light come on. This differentiates the “50th instruction” from an “end of instructions”. Similarly, RA2 drives the Stop LED. In addition to being activated in the abovementioned circumstances, between programmed instructions the robot comes to a brief stop, indicated by the stop light going on for that duration. C1, C2, S4 and the 15kΩ resistor comprise an external clock connected to the OSC1 input. S4 switches a second capacitor, C1, in parallel with C2 to increase the time constant, slowing down the rate of operations and hence the speed of rotation of the motors. There are a number of other aspects of operation, functions and limitations of the robot which may be further explained by referring to the ‘WHAT IF’ table. Construction The program on the PIC16F84 and the PC board artwork are both copyright to the author and so it will be necessary to attain these and the appropriate motors from the author. The PC board must be firstly assembled, following the component overlay diagram of Fig.2. Tracks and pads are close together on this board so care is required when soldering. Because of the fine trackwork, it’s even more important than normal to check the PC board thoroughly before commencing construction. The lowest sitting components, resistors and small-signal diodes should be installed first, followed by the Fig.5: a close-up diagram of the drive mechanism (obviously one side only). The opposite side is mirror-image. capacitors and right and left blinker LEDs which should be bent parallel to and in front of the PC board. PC pins are used to make the external connections – these include the switches, power, brake LED and motor connections. Power diode D10 is installed vertically on the PC board with its cathode (stripe) closest to S3. It is advisable to use IC sockets for both the PIC and DIP switch as this will allow for easy replacement should there be any problems. The transistors and pushbutton switch should be soldered last. Take care with both the polarity and location of the transistors: on one side of the PC board they face one way, on the other side they face the opposite way. The pushbutton switch, too, must be installed the right way around – its flat side is closest to the PIC. The chassis The chassis of the robot is fabricated from a slightly larger than half circle of acrylic with a diameter of 126mm (see Fig.4) The cuts are made with a coping saw then trimmed with a sander. While in the original one piece of acrylic was cut to size then bent at 90° using a heat gun, you might find it easier to cut two pieces of Resistor Colour Codes No.   2   3   2   2   1 62  Silicon Chip Value 15kΩ 10kΩ 2.2kΩ 220Ω 100Ω 4-Band Code (1%) brown green orange brown brown black orange brown red red red brown red red brown brown brown black brown brown 5-Band Code (1%) brown green black red brown brown black black red brown red red black brown brown red red black black brown brown black black black brown acrylic and glue them together using a small right-angle aluminium bracket, as we have shown. Contact adhesive is used throughout. Fig.4 shows the cutting and drilling details for the acrylic chassis, the acrylic vertical strip, the angle bracket, the wheel brackets (two required) and the motor plate. Start with the motor/wheel plate assembly. Each plate is made from 3mm x 25mm strip, available from most hardware stores. The two plates are 40mm long. Accurate drilling of holes in the plate is necessary to ensure that the motor cog meshes adequately with the rubber rim of the wheels once assembled. The wheel and bracket are fixed to the motors by fitting protruding screws on the motors through the holes in the brackets and tightening with nuts. The wheels used are typically available from hardware stores (eg, as used in very small trolleys) and have a rubber tyre. They are 50mm in diameter and have a shaft hole suitable for a quarter-inch bolt. They are fixed to the wheel brackets with two nuts, one each side of the bracket, and shakeproof washers. The wheel should spin freely on its axle when not in contact with the motor cog. The two stepper motors are glued end-to-end with contact adhesive. Make sure the alignment is perfect because this will affect how true your robot travels. We also glued on an aluminium strip, 75 x 25mm, across the back of the motors. It’s there for good looks as much as to ensure the motors stay glued together! Once the glue sets, an aluminium angle bracket 70 x 25 x 25mm is used to attach both the acrylic chassis and the vertical acrylic strip to the front end of the motors, again with contact adhesive. The acrylic chassis is not flush with the lower edge of the motors but instead is about 12mm above them so the aluminium angle bracket is glued in position to accept this. While the glue is setting, you can prepare the rest of the chassis. A small castor with wheel diameter of 30mm is glued to the underside of the acrylic chassis in the midline as far forward as possible without impinging on the installation or operation of the front “WHAT IF” TABLE 1. The robot is turned on. The brake light will go on for about one second, then turns off. If S2 is on RUN, and the ENTER/EXECUTE/PAUSE button is pressed, the blinkers will flash to indicate the end of instructions since none had been entered. S2 may be switched to PROGRAM or, if already in program mode, the robot may be programmed by firstly setting the DIP switch array and pressing the ENTER/ EXECUTE/PAUSE button for each instruction. 2. S2 is switched to RUN after having entered a set of instructions. The robot will now execute the entered instructions if the ENTER/EXECUTE/ PAUSE button is pressed. 3. The ENTER/EXECUTE/PAUSE button is pressed during the    execution of instructions The robot will enter into an indefinite pause (as compared to an instructed pause – which is definite). The brake light will come on for about 1s, then extinguish and the robot will sit idle. It will await for either the ENTER/EXECUTE/PAUSE button to be pressed again, whereby it will continue executing the program from where it left off, or S2 may be changed to PROGRAM to enter a new set of instructions. If no new instructions are entered and S2 is switched back to RUN, the robot will retain the previous program instruction set and can execute the program from the beginning if the ENTER/EXECUTE/PAUSE button is pressed. 4. S2 is switched from RUN to PROGRAM and then back to RUN again without entering a new program. If this is done at the end of the execution of a set of instructions, then there will be no effect on the already entered program and the robot will execute the program again if instructed to do so. If the switch is actually changed during the execution of a program, the robot will stop and will retain the previous program instruction set which may be executed again from the beginning once in the RUN mode. 5. The robot is turned off, then on again at any time. If during the execution of instructions, the robot will obviously stop and all memory is lost and new instructions must be entered. 6. The speed switch is changed at any time. The speed at which the robot clocks and performs instructions is altered and so such things as the speed of blinkers, delay time of instruction entry and so on are altered. 7. S2 is switched from PROGRAM to RUN and then back to PROGRAM again. A new set of instructions can be entered from the beginning only. All previously entered data is lost unless S2 is once again changed to RUN without any programming changes. 8. ‘Repeat’ is entered as the first instruction. When switching to execute, the robot will go into an infinite loop and the brake light will remain on. There is only one remedy – switch the robot off to clear all memory. Watch this though. If you switch off and on too quickly, there is inadequate time for C3 to discharge and so memory can be retained. To avoid this, switch off and count to 10 before switching on again. 9. ‘End of instructions’ is entered as the first instruction. On switching to RUN and executing, both blinkers will flash to indicate the end of instructions since none were really entered. January 2000  63 (power) switch. The PC board can now be bolted to the chassis with 32mm long bolts with nuts and 22mm spacers. This provides adequate room under the PC board to house the 4xAA flat battery holder. The vertical acrylic plate, approx. 60mm wide and 50mm high, is glued to the aluminium bracket behind the PC board. This protrudes above the motors and the 10mm red LED is glued onto this to act as the brake light. Two fine holes are drilled through the acrylic for the LED leads. Glue the acrylic chassis/PC board assembly and the vertical acrylic plate to the inside of the aluminium angle bracket and set aside to dry. The three external switches are mounted in the places provided. Make sure S2, the program/run switch, is the SPDT type – the others can be SPST types. Of course, SPDT switches can be used as SPST if you ignore one terminal. The front switch (S1) also helps to keep the battery pack from slipping forwards. It’s best to leave S1 out until the battery holder (with batteries, of course) is inserted – but leave this until your robot is finished! Wire connections from the PC board to the switches, batteries and motors can now be made. Holes are provided in the acrylic chassis for the switch wiring to travel, in part, underneath the chassis. Twisting the wires together over their length is not only neater – it keeps them together. After this is done, tidy up all wiring with cable ties where required and you’re almost ready to go! Just make one last check that everything is where it should be, that all the nuts are tight and all wires are secured out of harm’s way. Then place your four AA batteries into the holder, slide it into position between the PC board and the acrylic chassis and then insert and tighten S1. Now you’re ready to go! Operation Naturally, you’re going to have to program the robot before it does anything. When you have that part nailed down, you’ll be amazed at how much control you can have over the PICMAN 2000’s actions. Get some friends together with your PICMAN 2000s and, laying multiple obstacles on the floor, attempt to navigate your path by guesstimate programming to avoid the obstacles through to the other side from a common start point. The first to achieve this wins! Remember that the robot will travel 15cm with each forward or back step and turns approximately 18° with each right or left turn step. With little slip, the robot is capable of very accurate and reproducible movements and having such big wheels, the robot has little trouble travelling over carpet and even relatively rough ground so you can have SC fun almost anywhere! WHERE TO GET THE PARTS Most components are commonly available at electronics stores. Specialised components (PC board, programmed PIC and stepper motors) are available from Andersson Nguyen, PO Box 338, Minto NSW 2566. Ph (bh) (02) 9820 4161. Prices are:   PC Board – $15.00   Programmed PIC - $20.00   2 x 5V stepper motors – $35.00   P&P on any/all items: $3.00 R VAL EAL UE AT $12 .95 +$ Or 5 ea P bu &P g y5 pos et themand tage free Order by phone or fax from SILICON CHIP - or use the handy order form in this issue 64  Silicon Chip