Robot Beacon
Page 1
 


Robot Beacon uses a PIC12C508A OTP (One Time Programmable) 8-pin microcontroller. There is a lot of controversy over the type of microcontroller that should be promoted in a project such as this. 
There are at least three manufacturers of microcontrollers suitable for this application and it's a nightmare trying to work out the best type to promote. 
The problem is: each type has its own language and its own set of idiosyncrasies. Some chips have good features and others have different features, some chips have lines that are input-only, some have more lines or more memory, etc etc etc.  
To gather up all the facts, prepare a set of instructions, present all the information on the operation of the chip, create sample programs and design a project to teach how to write a program, takes months and months of development time. 
It boils down to this:
The PIC family have the most amount of information and back-up available on the web in the form of projects and examples. Check it yourself. For the other types, it is almost non-existent. 
We have already done a complete exercise for the PIC12C508A and PIC16F84, and to wander off to a different processor requires starting the development process all over again. 
The cost of all processors in the low-end range is almost the same and the features are very similar (when you are not using it to its limit), so why not go with the "swim."
It is most frustrating that each processor has its own language, as this is an enormous barrier to incorporating a second or third range of devices into a development course.
We have already provided all the software and hardware for the development of a number of projects using the PIC12C508A and there is little point jumping to another device, just because it is the "flavour of the month." 
Only when something startling (such as re-programmable) comes along in an 8-pin device, will we change. 
"Nothing is either good nor bad, but thinking makes it so."
 Colin Mitchell - Editor. 

 

Robot Beacon is available as a kit or ready built
There are at least three ways you can build the Robot Beacon: 
You can buy a ready-built Robot Beacon.
You can buy a kit with a pre-programmed chip,
You can buy a kit with a blank chip, 
You can buy a kit with a blank chip and modify the program using a PIC16F84 and adapter socket.

You will need the Multi Chip Programmer to burn your own chip if you don't get it pre-programmed in a kit.

Files and information:
How to re-burn a '508A.
All Robot Beacon files. This window contain notepad.exe  Click on notepad.exe and it will open. Drag a file to notepad and the contents will display!
Multi Chip Programmer - will burn your chip.
MPASM - assembles your .asm file into a .hex file for burning.
ICPROG.exe  and a help file: ICPROG-Help.zip - software for burning.
(See Burning A Program for help on setting-up ICProg)
Logic Probe (kit) - a very handy piece of test equipment - again, using a PIC12C508A!

Robot Beacon is a rotating light. We have called it Robot Beacon as it has been designed as an addition for a robot, but it can be used for many applications. 
It can be used as a mast-head beacon on a boat or as an "all-round" warning light on a bike. The author saw a similar device in a "What's New!" store for $99!
This is another project to show the versatility of the PIC12C508A. It's a handy little chip for all sorts of applications. 
Even in a project such as this, it takes the place of at least two chips. But the LEDs are switch-mode at a duty cycle of 50% at 500Hz and it would be difficult to produce this with less than 3 chips. Switch-mode saves nearly 30% in current (from 30mA to 20mA). A full explanation is given in the article. You can modify the effect, make it reverse, invert the effect or randomize it. This would normally take 4 or 5 chips. The display can be turned off in bright light. A photo-darlington transistor has been included to detect surrounding light level. 


Complete Robot Beacon

There is more in this article than a chip and a few LEDs.  
It's a good start to two of the topics we are covering in our electronics course. 
These are:
Programming a PIC12C508A chip
Using a Logic Probe


Designing a project involves three separate areas of work. The author has one area where he builds the prototypes. It has a soldering iron, test equipment and all the parts needed for prototyping. 
Another area is where the hand-writing takes place, including circuit designing and where the pages of books are laid out, plus the library of reference books. The last area has the computer, multi-chip programmer and is where the pages are typed on the computer for the web (and future books).  
I think yours will be the same. Most often the workshop is separate from your computer and you will have another section called "library," holding books and where things can be written and laid out. 
This project involves all these areas, and more. It introduces the use of a Logic Probe to help with the design and testing of a project and how to produce program for the 8-pin PIC12C508A.
Even a project as simple as this can require trouble-shooting and the Logic Probe we have designed is one of the best. 
It is both a logic probe and a pulser as well as producing a number of tones and tunes to test audio amplifiers. 
We cover its assistance with this project, in the text. 
We also show how to produce a program for the PIC12C508A. This chip is normally very difficult to use as it is not "user friendly." It is a One Time Programmable device and if the program does not work perfectly, the chip has to be thrown away. 
For developing a program, you need a number of EPROM versions (also called "window" versions) as well as an ultra-violet lamp. This adds considerably to the cost of development and makes it impractical for the hobbyist. We have "cut around" the costs and developed a brilliant new approach. 
It is also discussed in the article. 
There's a lot to be covered, so let's start . . .

This project has 4 different levels of involvement. 
1. You can buy it ready-made.
2. You can buy a kit with a ready-programmed 8-pin chip. This only requires soldering and does not involve any programming. 
3. You can buy the kit with a blank PIC12C508A and burn your own program. (You will need the Multi Chip Programmer.) 
4. You can modify the circuit, use the Logic Probe to check it, write a program in a PIC16F84, use an adapter socket, burn a program in a PIC12C508A and be involved in the project to its fullest. 

THE CIRCUIT

TRANSISTOR TYPES
In most of our projects, we specify BC 547 and BC 557 to indicate an NPN or PNP transistor that has no special requirements. It represents a simple, basic, general-purpose transistor. 
The specifications for this type of transistor is generally accepted as:

Voltage handling capability collector-emitter: 
about 25v
Current handling capability:
about 100mA
DC gain:
about 100

Some magazines use the term TUN and TUP for Transistor Universal NPN and Transistor Universal PNP. 
BC 547 and BC 557 are the "lowest" or "simplest" transistors you can get. They have a minimum current handling capability and a fairly low voltage capability and this means almost any other transistor can be used as a substitute. Using transistor types such as BC 547 and BC 557  is common in many magazine all over the world. They were one of the first transistor types to be readily accepted in the design of equipment and all technicians understand their characteristics. 
If we specified types such as BC182L or  BC214L many readers would immediately say "Why has this transistor been used?"
We want to keep the circuit easy-to-understand and that's why we specify the simplest type. Most of our circuits will take any of the general-purpose types and when we indicate a type other than BC547 or BC557, you will need to look at the specifications, to find the reason. 
Generally there are two reasons for selecting a type other than BC547 or BC557. It is usually HIGH VOLTAGE and/or HIGH CURRENT. 
These requirement increase the cost of a transistor enormously and that's why we don't specify them unless it is absolutely necessary.

HOW THE CIRCUIT WORKS
The circuit uses five outputs of the chip to drive 16 LEDs. Two LEDs are placed in parallel on each output (something you should not really do) so that they are illuminated at the same time. Four lines are used to produce a "run-of-four" or "4-chase" and one line is used to select between two banks. When the select-line (GP4) is HIGH, the BC 547 transistor is turned ON and the first four LEDs in the sequence are activated by the outputs mentioned above. When the select line is taken LOW, the next four LEDs in the sequence are activated. This gets the action to 180.   LEDs on the other half of the display are also activated during this time and thus the sequence is complete. Two LEDs run around the display at the same time. 
You will notice each output drives a pair of LEDs in parallel. In our case, they cannot be placed in series as the voltage drop across each LED is 2.2v (they are high-bright LEDs). The voltage across two LEDs would be 4.4v plus .35v across each transistor and this does not give any meaningful voltage for the current-limiting resistor. If the supply drops 1v, the LEDs would not illuminate. 
The only problem with this type of design is the need to match the LEDs. In other words, the LEDs should come from the same batch or manufacturer. 
If two LEDs with different characteristics are used, one LED will be robbed of turn-on voltage and will produce a very dull output.
The LEDs in the kit are all high-bright and can be seen at 100meters (yards).
Now we come to some of the other components. 
The three components across the power rail are important. 
The 100n across the chip is to provide good start-up for the oscillator inside the chip. 
The 100u electrolytic helps maintain brightness of the LEDs when the battery is low and the 10k resistor bleeds the 100u when the circuit is turned off. Without the resistor, a very small voltage will remain in the electrolytic and this will maintain memory in many of the cells inside the chip. 
When the chip is powering down, the content of some cells gets jumbled and if the micro is turned on in this state, it will fail to start-up (the chip does not have "brown-out" detection).
The MEL-12 Photo-Darlington transistor puts a low on the input line of the micro when it detects light and the program is held in a loop, looking for a high on this line. 
The operation of a photo transistor has been covered in our Basic Electronics Course, on page 47.
By using a low value resistor on the collector, it requires a high level of brightness to turn the circuit off. If a high value is used for the load, the slightest amount of illumination will turn the circuit off.  
The program executes one cycle before closing-down in bright light, to prove the program is working. 
A small black hood can be placed over the photo transistor to keep the circuit operating at all times. 

MARK-SPACE RATIO
A LED is capable of being turned on and off very quickly. It produces light by the passage of current though a crystal and not via the heating of a filament, such as in a globe. This means the LED will turn on and off very quickly as there is no filament to take time to warm up and cool down. 
There are two ways of activating a LED. One is to deliver a fixed current and the other is to deliver pulses of current. 
One of the amazing things about a LED is the delivery of pulses of current. If you deliver a slightly higher current in short pulses, the illumination produced is the same as a constant current at the lower mA value. 
Providing the pulses are delivered at a repetition rate above 100Hz, you will not be able to detect any flickering and the overall energy taken by the LED will be lower. 
That's what we have done in this project. The LEDs are not turned on with a constant current but pulsed at about 500Hz.


 PARTS LIST
 Kits for this project are available from Talking Electronics. 

 

ROBOT BEACON
PARTS LIST
au$29.50 plus $2.20 post

Order kit

2 - 100R     all  1/4 watt    5% resistors
4 - 470R
1 - 4k7
1 - 47k 
1 - 100n monolithic capacitor "monoblock" 
1 - 100u 16vw electrolytic 
16 - 5mm red LEDs 
1 - 1N 4004 power diode 
1 - BC 547 transistor or similar 
5 - BC 557 transistors or similar 
1 - MEL-12 photo Darlington transistor
1 - black sleeve for MEL-12
1 - 8pin IC socket
1 - PIC12C508A chip (with routine)
1 - Battery Snap
1 - 4-AA cell battery holder
4 - AA cells
1m - very fine solder 
1 - Robot Beacon PC board

Kits for Robot Beacon can be obtained from Talking Electronics:
http://www.talkingelectronics.com
 

Adaptor Socket 
PARTS 
au$5.40 plus $2.20 post
us$3.40 plus $5.50 MAX post

SOLDERING
The kit comes with very fine solder to introduce you to the "best aid ever devised for soldering."
Fine solder makes soldering so much easier. The quality of your soldering improves enormously and you will not want to go back to thick solder again. 
Make sure you apply a small amount of solder to the actual joint as the only real item you want in the solder is the flux. It's the flux that makes the joint small and shiny, It makes everything "stick" better. You can see the edges of the joint have a better adhesion to the track-work when fresh solder is used. 
All our boards are pre-tinned and have a solder mask around the lands to the solder will only adhere to the required places. 
It's not until you work with one of our boards that you will never go back to a board without the same features. 
Here's an unusual question: "What's the life of solder?"  
"About 5 seconds!"
Solder is absolutely useless without rosin (or resin) and the rosin must be melted to provide its cleaning properties. 
So, the life of solder is only during the time when the rosin is melting and evaporating.  That's why you have to apply the solder at the joint. Trying to carry hot solder on the tip of a soldering iron is impossible. It is absolutely DEAD by the time it reaches the joint. Sometimes you can "tack" a component by using dead solder on one lead. You can then solder the other lead with fresh solder and re-do the first connection by adding fresh solder. 

CONSTRUCTION
Before starting, decide on where you will be using the project so the positioning of the LEDs can be worked out.  They can be facing radially outwards or towards the front, to produce a miniature sign such as for a train layout. 
The type of LED can also be altered. The kit contains 5mm high bright LEDs but these can be changed for diffused LEDs of any colour and size. 
There is only one point to note. Each output drives two LEDs in parallel and they must be of the same type as the voltage drop across each must match very closely. For example, one LED in the parallel pair cannot be a different colour as each colour has its own characteristic voltage drop and the LED with the lowest drop will rob the other of voltage. If a LED does not see its characteristic voltage, it will not turn on AT ALL. This is one of the major differences between a LED and a globe. Alternate LEDs in the sequence can be a different colour.   
Fit the IC socket first. Use our resistor identifier to identify the 470R from the 4k7. Fit a maximum of three or four components at a time and cut the leads after soldering. If the LEDs are to face outwards, fit the leads down the holes and bend them over so the body just touches the edge of the board. 
Make sure the short lead is identified as the cathode and matches the line on the overlay. 
The short lead of the MEL-12 is the collector. Keep the Photo Darlington transistor off the board to prevent it getting too hot when soldering. 
The last item to solder is the leads of the battery snap. These can solder to the underside of the board to keep the appearance neat.
Fit the chip to the project and connect the 6v supply. The LEDs will rotate approximately two revolutions per second. If the speed is increased (by altering the value of the delay in the program), the effect is lost. Your eye sees too many LEDs ON at the same time.


ROBOT BEACON PC BOARD
Note the placement of Mel-12 photo transistor


USING A LOGIC PROBE
Hopefully, Robot Beacon will not work when it is switched on. This might be an amazing thing to say, but the only time when you will start to learn how anything works is when something goes wrong. 
The author has serviced more than 35,000 TV sets and thousands of other appliances and NOT ONCE, through the whole of his University course, did the concept come up, that a circuit may not work!
The whole approach of an instructor was: design this or that and it will work FIRST GO!  But that's not reality. 
Talking Electronics produced the first magazine in the world to include a section: "If it doesn't work." 
And when something doesn't work, that's when you really start to learn.
Even a simple project such as Robot Beacon can be used as a learning experience. 
You can use a multimeter to check the voltages on the outputs and a Logic Probe to check the lines to see what is happening. 
The Logic Probe designed by Talking Electronics has a number of features. It even produces a beep every 5 minutes to tell you to turn it off!


Logic Probe

It's ideal for trouble-shooting or testing a circuit before adding the chip(s) and switching on.. 
The author needed the Logic Probe for the prototype, to check the LED sequence, before the program was written. The wonderful part of a microcontroller is its versatility. Any of the outputs can be used in any sequence and if an output did not correspond to the sequence around the display, the program could be written to suit the layout. Similarly, if the track-work for the board could not be designed around the circuit diagram, any output pin could be changed to suit the track-work. That's why the final circuit diagram had to wait for the board to be produced.
The Logic Probe has an additional feature. It includes a PULSER. One end of the board is a Logic Probe and the other end is a Pulser. 
The pulser will inject a signal of approx 20mA into a circuit, with an amplitude of approx 5v and a frequency of 2Hz.  This will flash a LED without damaging it or put a tone into a speaker to see if it is working. The 2Hz signal has a 300Hz waveform within each HIGH.  
The low output current of the pulser is ideal for working on a finished project as you can probe around the various pins of the chip without damaging any of the outputs. 
A multimeter set to "current range" is very dangerous when used on a working project as it will put a  heavy load on an output pin and possibly damage the chip (a multimeter set to current is similar to a low-value resistor).
You cannot measure the output current of a drive-line without taking special precautions. This is a topic for further discussion. For now, use either a Logic Probe or a multimeter (set to volts) to detect the HIGHs and LOWs.

IF IT DOESN'T WORK
If you have assembled a kit, there should be very little reason why the project does not work. 
The chip is pre-programmed and the PC board shows exactly where each component is placed. 
The only possibility is a component around the wrong way. This could be a LED, IC or a cell in the battery box. There is one BC557 transistor. Make sure it goes in the right location.  Check all solder connections as a joint may be missed or a small amount of solder may be bridging two connections.
It's hard to imagine a resistor in the wrong location, but the 470R has only one colour different to a 4k7 and they may be in the wrong places. Get someone else to check your work as it is very difficult to locate your own mistakes. 
Use the Pulser end of the Logic Probe to turn on the LEDs. Pins 3, 5, 6 and 7 will each turn on 4 LEDs when the chip is removed from the board as the two sinking transistors must see a definite HIGH or LOW for only two LEDs to turn on. The pulser will pick up a reversed or damaged LED, a fault in the track-work or a missed solder joint. 
If the program in a PIC16F84 does not work, you have to get the project to a point where you can determine if the fault is hardware or software. 
Fit a pre-programmed chip to the project and make sure the circuit is working correctly before working on your program. 
Everything you do must be in small steps. This is the only way you can guarantee you are going to solve the problem.
Make sure the program in the PIC16F84 has been assembled for a PIC16F84 in MPASM and correctly burnt for a PIC16F84 in IC_Prog. 
Once the program for PIC16F84 in Beacon Files is working, you can start to modify the code to your own requirements. 


MIGRATING
Moving a program from one processor to another can create a number of problems.  You have to know the differences and limitations of each processor. A transfer is really only possible within the same family. Fortunately, the PIC12C508A is a smaller version of the PIC16F84 and nearly all the instructions can be used. There are however, a number of instructions that cannot be used and a number of things that you must be aware of. 
A full list of differences is provided in the PIC Programming Course, page 24.
The table below is a summary of these differences and provided they are remembered, you can write a program for a PIC16F84 (using ONLY instructions that are common to both chips) and your program will not have to be altered when the code is assembled for a PIC12C508A:
 

PIC16F84 
(when migrating to a PIC12C508A)
 PIC12C508A
Files: 0Ch to 4Fh 
Only use files: 0C to 1F
Files: 07 to 1Fh
Only use files: 0C to 1F
Memory: 000 to 2FFh (1024 bytes)
Only use memory to 1FEh
Memory 000 to 1FFh (511 bytes)
Only use memory to 1FEh
Program is written in EEPROM - can be erased and re-written 1,000 times Program can be written only once in each location.    See re-burning a '508A 
CALL operates to full memory CALL operates to 0FFh
RETURN
RETURN is not available - use RETLW 00 to 0FFh
RB0 - in/out line
RB1 - in/out line
RB2 - in/out line
RB3 - in/out line
RB4 - in/out line
RB5 - in/out line
GP0 - in/out line
GP1 - in/out line
GP2 - in/out line
GP3 - input ONLY
GP4 - in/out line
GP5 - in/out line
Stack is 8-high Stack is 2-high
  ADDLW - not available
  SUBLW - not available
  OPTION 0DFh - Make GP2 an input and disable weak pull-ups
EEPROM - 64 bytes EEPROM - 0 bytes

The following diagram shows the input/output lines for the PIC12C508A matching the PIC16F84:



MODIFYING THE PROGRAM
The Robot Beacon program can be completely re-written or only partially modified to suit any requirement. 
It's very easy to see how the program works as it has been presented in a "flow-through style" called "linear programming" where the micro advances down the program and does not divert to sub-routines. This makes the program appear large because of the repetition of instructions. 
This has been done for a purpose. This type of program can be placed ANYWHERE in a PIC12C508A as no CALL instructions are required. If a CALL instruction is used, the program can only reside in the first 0FFh locations of a '508A.  
Normally a Delay routine would be CALLed after each output is turned on or off (and only one delay sub-routine would be needed) but in our case the delay includes a 50% duty cycle in which each output is turned on and off to pulse the LED with current and each delay routine is different. 
The select-line (GP4) cannot be pulsed as it selects between two different banks of LEDs and so each output (GP0, GP1, GP2 and GP4) must be pulsed. 
The diagonally-opposite LEDs are illuminated at the same time on the display and this feature cannot be changed. You can have one pair, two pairs or three pairs on at the same time, to achieve different effects. 
You can also alternate the effects if you intend to use the project as a miniature display on a train layout. The display can rotate forwards, then back, or stop, or flash. 
The chip will not be overloaded with any choice of illumination as the LEDs are driven via buffer transistors and the chip is delivering less than 10mA from each output. 
The chip, load resistor for MEL-12 and bleed resistor across the supply, take approx 2mA, leaving about 20mA for two LEDs in parallel. Since the on-time is 50%, the peak current through each LED is 20mA, making the average current 10mA. This produces a brightness equal to a constant current of approx 20mA. 

continued on Page 2 . . .                



To Top