complete dialing alarm the size of a pack of cigarettes.
- its features will amaze you . . .
This is the lowest
cost dialing alarm on the market and shows what can be done with an 8-pin
microcontroller. The complete circuit is shown below. You cannot
see all the features of this project by looking at the circuit - most of
them are contained in the program. So, read on and see what we have
included. . .
Click on the 5
red dots to see each section operating
has a single input (although a number of sensors can be placed in
parallel on the same input line). The circuit requires a trigger pulse to
turn on a BC 557 transistor. This delivers power to the
microcontroller. The micro starts to execute the program and outputs a
high on GP2 to keep the "turn-on" circuit active. It also turns on the LED
in the opto-coupler and this causes the line to be "picked up" via a
high-gain Darlington transistor. The micro then dials two phone numbers
and executes a series of events to alert the called party of an intrusion.
The circuit also has a sensitive microphone with a high-gain amplifier.
This is connected to the phone line when the alarm is triggered.
the first number is dialled, a Hee Haw signal is sent down the line to
alert the listener of an intrusion in the "target" area. Amplified audio
of the room is then passed down the line. This signal is clear enough to
detect conversations and/or movement in the target area and the listener
can determine the situation. A second number is then called and the
process is repeated. The two numbers are then called again and the alarm
closes down. Simple but brilliant. The flow Diagram for the
alarm is shown below:
Dial Alarm-1 Flow
Use Dial Alarm-1 as a "Back-Up" Alarm
This alarm has been developed in
response to a number of recent large robberies reported in the
news. Robberies are a constantly increasing crime, but very few are
reported, unless they have a "twist." Recently, the robbers navigated the
conventional alarm system and broke into the night safe in the Manager's
office. The haul was quite significant and it's surprising such a large
amount of cash was kept on the premises. The weakest link in most
alarm systems are the PIR detectors, used to detect movement. It's a known
fact that they are very easy to foil. It's so easy we are forbidden to
print details of how to do it. But many thieves must be aware of the trick
and that's why a back-up system is essential.
The cheapest back-up
system is the use of the phone line. I know what you are going to say.
Cutting the telephone line is an easy matter and offers little security.
But finding the line in a premises is
not very easy and if there are
two or more incoming lines, it's difficult to know which is connected to
the dialler. Nothing is infallible, but for a lot less than $50 you can
build this project and have a back-up to protect your
The other advantage of our design is the "set and
forget feature." The alarm is designed to ring your mobile and if you keep
your phone beside you 24 hours a day, you can have this peace of mind,
whether you are in your office, factory, holiday house or quietly dining
at your favourite restaurant.
You can protect any area where a
telephone line can be installed. This includes houses-under- construction
and outlying sheds.
Talking Electronics has been producing
security devices for more than 15 years and this project is a culmination
of those years of experience.
The high-sensitivity amplifier is our
development and comes from our highly successful Infinity Bug. This
device connects to the phone line anywhere in the world and when the
number is rung, the infinity
bug answers the call and lets you listen
in to the activities in the room. It's just like being there. We
have used the same circuit in this project. When it is activated, you can
easily work out if it has been triggered by staff, a family member or an
intruder. At least it prevents 90% of false alarms and offers
enormous peace of mind.
The secret lies in the placement of the
triggering device. We have provided only one input (trigger input).
And there's a reason for this. The idea is to place the sensor near the
target area or on an actual device, near the microphone.
it you are protecting a house, a thief always goes to the main bedroom and
rummages through the drawers and cupboards. In this case a drawer that is
never used should be wired with a magnetic switch (reed switch) or a
movement detector such as a mercury switch. These switches can be
housed in a plastic case for easy screwing to a wall or door and are very
reliable in operation. When the drawer is pulled out or the door opened,
the switch is activated. If you are protecting a wall safe, the
switch is placed near the safe in a clipboard or picture so that when the
board or picture is moved, the alarm is activated. If a room is to
be monitored, the switch is placed on the door so that when it is opened,
the alarm is activated. If other valuables are being protected (such
as a VCR, scanner etc) a suggestion is to place a clipboard against the
item. The idea is the clipboard has to be moved to get at the
"valuables." The clipboard contains a magnet and the switch is nearby. The
clipboard keeps the switch open (or closed) and when it is moved, the
alarm is activated.
The ideal arrangement is to avoid touching the
clipboard, drawer, door or other "prop" during normal activities and this
keeps the alarm activated at all times.
Another suitable trigger
device is a pressure mat. This is something that can be avoided by
"those in the know" and you can monitor an area during your absence.
The alarm can be used for other things too. You can determine when your
business premises are opened up in the morning by placing a pressure mat
or reed switch on a door. The same can apply to a particular room in your
The purpose of this article is not only to produce
the worlds smallest dialling alarm but also show you how the program runs
so you can modify any of the routines to suit your own particular
The program can be re-written to dial only one number
for two rings then hang up, or three rings, then again after 2 minutes or
any combination to suit your requirements. Many mobile phones identify the
caller on the display and you can keep track of the exact time of arrival
and departure of different personnel.
The alarm can be programmed to
monitor machinery and dial your mobile when a breakdown occurs. It can
monitor water level or even your mail box. The possibilities are unlimited
and it's just a matter of modifying the program to suit your own
But before you change any of the program you have to
understand what the program does and be capable of changing the
instructions without upsetting the operation of the
Remember: A little knowledge is a dangerous thing.
Before doing any re-writing of the program you need to read our notes on
programming and carry out one small modification at a time.
is really a very advanced project. The fact that is looks simple is the
power of the microcontroller. It's taking the place of at least 10 chips
in a normal alarm.
Timing, tones and tunes have all been
converted to instructions of a program. And the advantage of a program is
the simplicity of alteration. A time-interval can be changed or a phone
number altered with a few lines of code. Even new features can be added
without the need for additional hardware. This project uses the '508A to
its maximum and shows what can be done with an 8-pin
microcontroller. Before we go any further we must state that this
project cannot be connected to the public telephone system. Only approved
devices can be connected to the Public Phone System and any experimental
device must be approved for experimentation and connected via a "telephone
Line Separating Device." These are available from Altronic Imports for
This is unfortunately the case and when we discuss
connecting the project "to the line," we are referring to an experimental
telephone system such as the one we have put together at Talking
Electronics, to test and develop projects such as these.
section "Testing The Project" on Page 2 for more details of the Test
Circuit. It consists of 27v derived from 9v batteries, a 12v relay, a
telephone and a socket, all in series. The 12v relay is included to limit
circuit consists of 6 building blocks.
THE TURN-ON CIRCUIT
The project is connected to a 6v supply at all times and to
extend the battery life, the circuit turns off after use. The
current drops to less than 1uA and the only components connecting the
battery to the project are the "turn-on" items.
These consist of
a BC 557 transistor, 2M2 turn-off resistor, 100k bleed resistor, and the
top 100u electrolytic. The components to turn on the "turn-on"
circuit are the sensing device such as a reed switch or mercury switch,
the lower 100u electrolytic and 100k bleed resistor. The components
to keep the turn-on circuit ON, are the microcontroller, diode and
100k separating resistor.
It sounds quite complicated but here's
how it works. The trigger device must be AC coupled to the project so
the alarm only carries out one alarm operation and resets. If the
trigger device was directly coupled to the turn-on circuit, the project
would never turn off, even though we could design the
program to carry
out only one dialing operation.
The sensing device must only give
a TRIGGER PULSE to the circuit so it can reset after its operation, ready
for another trigger pulse.
The only way to turn a reed switch
activation into a pulse is to AC couple it. To pass the signal through a
capacitor. This is what we mean by AC coupling - it means PULSE
COUPLING or NOT DIRECT COUPLING.
The way the turn-on circuit
works is this: The top electrolytic is charged very quickly by connecting
its negative lead to the negative rail of the project.
effectively charges the capacitor and supplies a voltage to the base of
the BC557 to turn it on.
Energy from the electrolytic passes into
the base of the transistor and allows current to flow between collector
and emitter leads.
This flow of current activates the rest of the
project. The microcontroller starts up and and the Watch-Dog Timer
resets the program to the beginning after about one second (if the program
did not start correctly) and takes over the job of turning on the BC 557,
by taking GP2 low via the diode and 100k resistor. This action keeps
the top 100u charged.
Going back to the action of the tilt
switch; instead of taking the top 100u directly to the negative rail as
discussed above, it is taken to the negative rail via an uncharged 100u
and this is similar to a "piece of wire" when it is in a discharged
condition. It gets charged (to approx 3v) and the project turns
If the reed switch remains closed and the micro goes through
its set of operations and closes down, the top 100u discharges while
the lower charges to 6v. This will take a long time but eventually the
transistor will turn off, even though the reed switch remains closed.
When the reed switch opens, the circuit cannot be re-activated until
the lower 100u is discharged (or partially discharged) and this will take
a long time through the 100k across it (and the upper
What an enormously complex operation for such a
At the end of an alarm-cycle the micro is placed in a
holing loop at Main8. To get the micro to re-start at address 000, the
chip must see a definite LOW. This will naturally occur when the project
is sitting for a long period of time, waiting for a trigger pulse. If you
are experimenting, make sure the rail voltage has been completely removed
before re-starting the project.
2. THE TONE DETECTOR
The simplest building block in the project is the
Tone Detector. It is designed to detect any tone of about 500Hz on
the phone line such as a whistle or DTMF. When this tone is detected, the
alarm will turn off. In this case the hardware does the
The circuit amplifies the signal on the phone line
and this turns on a transistor. On the output of the transistor is a 4u7
electrolytic. It is charged via a 100k resistor. The stage sits with the
collector at rail voltage, due to the biasing components keeping the
transistor off. When a signal is delivered, the transistor turns on and
the collector goes low. This causes the electrolytic to get discharged via
the diode. At the same time, the electrolytic is getting charged via the
100k and if the frequency of the signal is rapid enough the electrolytic
will be fully discharged and this will be detected by the micro as a
Designing a project is a combination of good circuit and
good program design. This section is a typical example. Originally, the
signal was fed into the micro and a program detected the high's and low's.
This was very unreliable. By adding the diode and electrolytic, the
circuit does all the detection and the program only has to detect a high
or low. Much simpler to implement and guaranteed to work.
THE DTMF WAVE-SHAPING CIRCUIT
Dialing a phone number is carried out by sending
a tone down the line. So that whistling can not carry out a dialing
operation, the telephone company decided to make the tone impossible to
produce "by accident."
Each dialing tone consists of two frequencies,
sent at exactly the same time. These frequencies must be in the shape of a
sinewave as the detecting device "locks onto" each of the frequencies at
time and produces a very-fast result. The only problem
is a micro can only produce a square wave.
To convert a square
wave into a sinewave, we need a wave shaping circuit. In essence this
consists of charging and discharging a capacitor with a square wave and
"picking off" the waveform.
The charging of a capacitor is
exponential but if we take the beginning of the curve and compare it to a
sinewave, the two match up fairly closely.
That's what we
have done. We have charged a capacitor very quickly via a resistor so that
it is nearly fully charged and then we begin to discharge it. The result
is a fairly "peaky" sine wave. The waveform
is picked off the capacitor
via a high value resistor and passed into a high impedance
emitter-follower circuit. The two tones are produced separately by the
micro and combined after wave-shaping. This reduces interference between
one waveform with the other.
The component values have been especially
chosen to produce a high amplitude signal, as the emitter follower
transistor does not increase the amplitude, only the current-driving
capability into the phone
The choke has been placed in the emitter of the driver
transistor to have the maximum effect on the signal. When it was placed in
the collector, it had no noticeable improvement.
The effect of a coil
(choke) is to "smooth out" the shape of a waveform. It does this by taking
some of the energy from a rising signal and delivering it during a fall in
amplitude. This makes the "peaky" waveform "rounded."
coil actually produces a negative feedback on the circuit. You already
know that a rise or fall in amplitude on the base of a transistor will
create a fall or rise in the collector voltage. Well, the same thing
happens if you keep the base fixed and raise or lower the voltage on the
emitter. The voltage on the collector rises or falls by a larger amount.
This is due to the gain of the transistor.
The improvement made
by the choke increased the dialing accuracy from 80% to 100%.
improvement in the waveshape could not be detected on a CRO so it's not
always possible to get test equipment to help you with a design. Sometimes
it's your knowledge of componentry that gets you through.
DTMF generator to work was one of the most difficult parts of this project
as the tone detectors at the exchange are very "exacting" and critical. To
improve the chances of instant recognition, we have included a crystal in
Although we have generated the tones in the micro,
there are tone-generating chips and these have a 16 tone capability, with
only 12 tones used on the telephone keypad. The additional 4 tones
are shown on the diagram below as A, B, C and D. The two symbol keys
are called "star" and "hash."
The extra tones can be generated by the
program but are not needed in our situation. In the early days of DTMF,
the 4 extra tones were used by the telephone companies to route the calls
and create call-charges. The basis of defeating these charges was through
"blue boxes" held to the mouth-piece, while creating the extra tones.
Things have been tightened up since then.
4. THE HIGH
high gain amplifier is the two-transistor amplifier at the bottom of the
circuit. It is used to pick up sounds in the target area during an alarm
activation. It is directly coupled to the phone line via a bridge.
The bridge delivers the correct polarity to the circuit, irrespective of
the polarity of the phone line and the change in impedance of any of the
components connected to the phone line will result in a signal being sent
down the line. The output stage of the high-gain amplifier is one of these
components and it is biased ON via a 220k resistor. This turns it ON only
very slightly, so that the audio signal will drive it correctly. The
"load" for the transistor is all the other components connected in series
with the transistor and this includes the "holding-in" relay and any
isolating transformer at the exchange. The components across the
transistor do not form part of the "wanted" load and they actually reduce
the output. However they must be included as part of the DTMF section.
So, we have a two-transistor high-gain amplifier. A 20mV signal
from the microphone will produce a 1,000mV signal on the collector of the
first transistor and this will be passed to the output transistor.
amplitude of the waveform across the output transistor is about 2
The unusual layout of the circuit may be confusing. The
pre-amplifier section is powered from the 5v supply while the output
transistor is driven from the phone line. Although the voltage on
one side of the 100n on the base of the output transistor is different to
the other side, this does not affect the operation of the circuit. It is
the AC signal through the 100n that is amplified by the buffer (output)
transistor and providing the negative rail of the pre-amplifier and the
emitter of the buffer transistor are fixed and rigid with reference to one
another, no motor-boating (instability) will occur.
amplifier is gated "off" when the DTMF tone is sent down the line. The
supply for the pre-amplifier is obtained from an output of the micro and
this line goes high before the tone is transmitted. This charges the 47u
and the voltage across the BC 557 is very low. Without the ability to
amplify the audio in the target zone, the signal on the phone line will
not be upset when the DTMF is transmitted.
5. THE OPTO-COUPLER
The opto-coupler is the device that
does the job of a normal phone. In other words it "picks up the phone
line." The micro outputs a LOW on pin 5 (GP2) as soon as the program
is activated by the mercury switch and this keeps the "turn-on" circuit
activated. This line also goes to the opto-coupler and a LED in the
opto-coupler is also turned ON. The illumination of the LED turns on a
phototransistor inside the opto-coupler and the resistance between
collector and emitter leads of the photo-transistor is reduced and this
pulls the base of a Darlington transistor towards the positive
The Opto-coupler can be connected directly to the phone
circuit but the transistor must be turned on much harder. This requires
the LED in the opto-coupler to be driven much harder and puts a very heavy
demand on the battery.
At the conclusion of each "telephone call"
pin 5 goes HIGH and this is the same as "hanging up the phone." The
electrolytics in the "turn-on" circuit will keep the micro active during
the short period of time between phone calls.
6. THE MICROCONTROLLER
The heart of the project is the
microcontroller. It is an 8-pin chip with 5 input/output lines and one
output-only line. The output lines change from low-to-high-to-low
very quickly and each line can deliver a maximum of 25mA.
program inside the micro determines what happens on each of the lines and
the parts around the micro are merely interfacing components. In other
words they adapt or modify or amplify a signal to suit the micro or phone
The micro never stops "running" and it executes
instructions at the rate of one million per
second (1 MIPS).
You need to
understand PIC language to program the micro and Talking Electronics has
Programming pages on the web to help you develop a program.
THE PHONE VOLTAGE
Before designing any project for operation on the phone line,
you have to understand how the 50v line operates. It's not like a normal
50v power supply. You cannot simply design something for 50v and connect
it to the phone line.
The phone line is actually a 50v battery
(actually slightly higher than 50v - about 52v. However some of the newer
phone systems deliver a voltage as low as 35 - 40v) with a 1k relay in
series with one line. When you short the two phone lines together, the
relay pulls in to indicate the handset has been lifted. Under these
circumstances the current flowing through the line will be 50/1,000 =
50mA. The relay will drop out at 15mA and so you can add devices to
the phone line until the current falls to about 15mA without the line
dropping out. It is best to keep the current high to prevent the line
Most phones drop about
8 - 12v across them when they are working and this voltage can be used by
the phone for the amplifying circuits, tone generators etc. Our design has
a separate supply, however it could be designed to use the phone voltage,
if you wish. The 10v across the BC 337 audio output transistor gives the
transistor plenty of voltage for a good output waveform. The
audio is sensitive enough to hear a clock ticking in the target
than one trigger device can be fitted to the alarm provided they are
connected in parallel as shown in the diagram below.
BUILDING THE PROJECT
All the components fit on to a PC board labelled
Dial Alarm-1. The placement of each component is clearly shown by
the overlay on the board and the only components requiring careful
attention are the opto-coupler and bridge.
The opto-coupler has
line running down one side of the chip and when viewed from the top, with
the line towards you, pin one at the left.
The chip may also have a dot
or dimple indicating pin 1 and/or a cut-out at one end.
bridge has positive (+) and negative (-) marked on the top of the chip as
well as AC inputs indicated by squiggle lines.
Don't get the BC
557 confused with the BC 547 or BC 338 transistor. They all look the same
and have the same pin-outs, but their function is different. The outside
case of the electret microphone must go to the negative rail. The
microphone can be fitted to a short length of twin lead or fine screened
microphones lead (as supplied in the kit) so it can be positioned near the
audio you wish to detect.
Solder the 8-pin IC socket for the
microcontroller to the board so that the cut-out, covers the cut-out on
the board. This way the chip will always be fitted around the correct
telephone cable comes with 4-pin plugs crimped on each end. A 4-pin
modular telephone socket is soldered to the board.
Click on the 5
red dots to see the circuit working
- 100R 1/4 watt|
2 - 18p ceramics
1 - 22n
1 - 33n ceramic
1 - 47n
2 - 100n ceramics
2 - 1u
1 - 4u7 25vw
1 - 47u 25vw
3 - 100u 16vw
1 - 4MHz crystal
- electret microphone insert
2 - BC 547
transistor or similar
2 - BC 557 transistor or
1 - BC 338 transistor or
1 - BD 679 transistor
- 1N4148 signal diode
1 - DF 04
1 - 4N25 opto-coupler
1 - 6 pin IC socket
- 8 pin IC socket
1 - 4-cell AA battery
4 - AA cells
1 - mercury
3m - 4-core telephone cable with
crimped on the ends
2m - fine screened microphone
3m - very fine solder
1 - Dial Alarm-1
The project is
tested either on a 50v line or the Test Circuit shown in the
diagram below. The supply is three 9v batteries.
It does not matter
which way around the phone or Dial Alarm-1is connected as both have a
diode bridge to accept either polarity. When the mercury switch is
activated, the alarm sends a Hee Haw tone down the line and this is
detected by listening to the line via another telephone connected in
series with the Dial Alarm-1 project, as shown in the diagram
above. The audio from the room is then sent down the line. After 15
seconds the Hee Haw is produced again over the audio and this is
repeated at a further 15 seconds. The project then closes down, waits a
few seconds then dials the second number and repeats the operation.
The two numbers are dialled again and the Alarm closes down.
repeat the sequence in the Test Circuit and during the listening period,
push any of the buttons on the phone to send a DTMF tone down the
The project will close down. The actual closing-down of the
circuit takes a while as the electrolytics in the shut-down circuit have
to "bleed" though high value resistors. The micro stays in a holding loop
during this process, with a CLRWDT instruction.
If the input of
the alarm is connected to a reed or mercury switch on a door, the door
will have to be closed again to reset the tilt circuit.
IF THE PROJECT
project doesn't work you will have to go to one of the following
1. The turn-on circuit.
To test the
turn-on circuit, short between collector and emitter of the BC 557
transistor. The project will come on and operate.
Put a 10k resistor on
jumper leads and connect it between the base of the BC 557 and ground.
This will turn the transistor on. If not, the transistor is faulty or it
is a BC547! If this works, take the jumper from the join of the two
electrolytics and ground. This will also turn the transistor on. If not,
may be open between the join of the electro's and the base of
the transistor or the top 100u may be very leaky and have a very low
Finally place a jumper lead across the tilt or reed
switch. If this doesn't work, the lower 100u may be open circuit. If it
does work the tilt or reed switch may be faulty.
2. The tone detector amplifier
The tone detector transistor is
normally gated off and the collector will be at rail voltage. At the same
time, the 4u7 electrolytic is fully charged via a 100k resistor. When a
signal is detected, the transistor turns on and discharges the
electrolytic. This is very easy to monitor via a multimeter on line
3. The DTMF Section.
The quickest way to determine if this
section is working is to pick up the phone and activate the alarm, by
tilting the mercury switch.
You will hear the DTMF tone being
sent down the line.
If these tones are not heard, you can produce a
constant dual tone for say "0" by inserting the following instructions
into the program.
Make sure they are removed after the testing is
At the end of the SetUp routine
last instruction in DTMF1 must be delineated i.e: ;DECFSZ
Placing a piezo
between pin 6 and ground will allow you to hear one of the tones and
between pin 7 and ground, the other tone.
The tones will be produced
continuously and you can view them on a CRO and observe their waveshape
entering the phone line. To view one tone at a time, the micro can be
put into an old 8-pin
socket, with one of the output pins missing -
this way none of the components have to be removed from the
To see if
the opto-coupler is "turning on," short between pins 4 and 5 with a jumper
lead. This will turn on the BD 679 transistor. If you also turn on the
TURN-ON circuit with a jumper lead between the join of the two 100u
electrolytics and ground, you will be able to hear the room-audio, through
the telephone. The opto-coupler is turned on by activating the LED between
pins 1 and 2. The illumination of the LED turns on a photo-sensitive
transistor between pins 5 and 4. The LED only needs a few milliamp to turn
on the transistor sufficiently to drive the BD 679 into saturation, as it
is a super-alpha device.
The micro takes pin 5 low to turn on
both the "turn-on" circuit and LED in the opto-coupler, but you cannot do
this manually as you may damage the output line of the
When the project is operating you can check the voltage
across the 560R resistor. This does not tell you very much except that if
it is about 3v, the LED inside the opto-coupler and micro are
Check the voltage across the pins
4 and 5 of the opto-coupler. It should be about 2v. If it is higher than
5v, the opto-coupler is not being turned on enough. It could be
insufficient current through the LED or a faulty
5. The High-Gain Audio
amplifier consists of two stages. The pre-amplifier (the low-signal stage)
and the buffer stage (output stage).
The pre-amplifier section
consists of a standard common-emitter amplifier with AC coupling
(capacitor coupling) to the microphone. It may look unusual because
it is a PNP stage. This has been done so that one of the lines from the
micro can be used to gate the audio amplifier OFF.
You will need
either a CRO or an audio tracer to listen to or observe the signal from
the microphone through to the output transistor.
Our circuit had a
gain of 50, with a 20mV signal (whistle) from the microphone producing
1,000mV (1v) signal into the base of the buffer stage, (output
stage). The output transistor amplifies this to produce a signal of
about 3v on the phone line. You will need a CRO to view the
waveforms if you think the audio amplifier is not operating correctly. A
dual-trace CRO is best so you can observe the input and output of a
particular stage at the same time.
This completes the coverage of
all the individual building blocks in the circuit. If a fault still
persists, the best way to tackle the problem is to get another electronics
person to check the board. It may be a simple mistake such as swapping two
components, a solder bridge or dry joint.
As a last resort, you can
build another kit and with the second project working, compare the
USING AN EMULATOR
One of the biggest tasks is finalising
a project. As with most projects, the program is built-up of a number of
sub-routines from other projects and are known to work correctly. The same
with the circuitry. It consists of a number of building blocks from
previous projects. Individually, everything works. But the challenge is
getting all the sections to work together.
There are two methods.
The first is the simple but "tricky" method, and the second is the use
of "high-level tools of assistance." High-level tools are a
CRO and Emulator or Single-Stepper. They are nice to have but
relying on them is a crutch. You tend to think they will solve your
This is a dangerous misconception because, in most
cases the final solution can come from going back to basics. They
can be of assistance, but I am going to show the real way to
problem-solving is using "tricks-of-the-trade."
The big problem with an
emulator is INPUTS. If you have a push button in a circuit, the emulator
does not carry out the operation of the push button.
delays take a long while to execute and either the emulator skips over
them or takes a long time to execute. Output devices are also a problem.
How is the emulator going to tell if the output code to a 7-segment
display is correct? The pattern on the display will depend on the wiring
and it may be multiplexed, so another line is also needed to activate the
I have used a single-stepper and emulator for the PIC and
these are some of the problems it did not solve.
By far the best
method is MINE. It's simple but it works every time. It's back to
Put an instruction into a program that takes the micro to a
small routine that outputs a tone to a piezo diaphragm or blinks a
Put a GOTO instruction into the program, say before a CALL
instruction. If the LED blinks, the micro has reached the instruction.
Then put the GOTO after the CALL. If the LED does not blink, the micro has
not come out of the sub-routine. It may be stuck in the sub-routine or
jumped to another address. Go to the sub-routine and work your way through
each line with the GOTO concept.
It may be time-consuming but it is the
only real way to follow the actual progress of the microcontroller. This
approach was used to solve a problem with the original tone routine in the
Dialling Alarm. The investigation solved the problem and also showed the
sub-routine was not well-designed. A much simpler routine was put in
its place. So, the hands-on approach solved two things at the same
A CRO was also used initially to check the quality of the
DTMF waveform. It appeared to be perfect on the screen but was only being
accepted by the exchange 80% of the time. With the addition of a choke in
the circuit, the acceptance rose to 100%. The difference between the two
waveforms could not be seen on the CRO. This is another case of going back
to basics and using your knowledge of electronics (inductors) to
improve the quality of a waveform.
The point I am making is this
. . .
All the tools of assistance for getting a project
up-and-running have been provided in the publications produced by the
author and on Talking Electronics website. The only test equipment you
need is a multimeter (either analogue or digital) and a Logic Probe. Don't
be dreaming: "If only I had an emulator!" or "If only I had a CRO."
You can do it all with basics and that is what the Talking Electronics PIC
course is all about. Building this project and some of our other
projects will show you how things go together, so you can design your own
As I said above, one of the biggest problems is
working out the correct order for testing a project. Things have to be
done in the correct order and this quite often requires stripping the
project down to the simplest circuit. In our case the first section to
work on was the DTMF tones. Once they were 100% accepted by the exchange,
the turn-on circuit and opto-coupler sections could be added. Then the
audio amplifier had to be placed in parallel with the DTMF section without
affecting the quality of the waveform of either the tones or the audio.
This was quite a challenge and even though the final circuity is simple, a
lot of testing had to be done to make sure other designs were not better.
The DTMF circuit was loaded with capacitors and resistors to see if the
tone was still recognised by the exchange. This way you know you have a
margin-of-error and any tolerances generated in the building of the
project will not affect the outcome.
As each problem was
solved, the project got nearer completion. By working with basics, the
feeling is the project is advancing.
With the Dialling
Alarm, there were more than 10 things to sort out.
The DTMF tone
- duration, amplitude, clarity, getting 100% acceptance on the
The opto-coupler, the Darlington transistor
The audio amplifier, reducing hum, reducing motorboating,
improving output amplitude, gating.
The tone detecting
None of these would have been helped with an emulator or CRO.
There is too much circuitry interdependence and the big problem with a CRO
is the introduction of hum when the earth clip is connected to the
If there is any magic package or device that speeds up the
process of development, I will let you know.
MODIFYING THE PROGRAM
To work on the program, you need to
assemble an 8-pin to 18-pin adapter shown below. This will allow a
PIC16F84 to be plugged into the project so you can easily modify the
Alternatively you can build our Pseudo'508 module. The
8-pin plug on the module is then plugged into the '508A socket on the
Dial Alarm-1 board.
The next thing you will need is an
assembly program to convert the .asm file to .hex - called
Your program is written in a text editor such as Notepad or
Textpad and it has exactly the same layout as the program below. You must
call it xxxxxxxx.asm (up to 8 characters then .asm). MPASM
takes this file and produces a .hex file. It also produces a
.lst file that shows any mistakes you have made. If a major mistake
is made, MPASM will not produce a .hex file, only a .lst
file for you to see where the fault is located. If a slight mistake such
as leaving the designator off an instruction, MPASM will assume you want
the default designator etc and produce a .hex file. Each time
you save the file, you must give it a new name. This can simply be a
different letter of the alphabet such as Dial-A.asm, Dial-B.asm etc. This
way the program being run will definitely be the latest version. In
addition, the MPASM will not produce a .hex file if the file is
currently being used by PIP-02, for example. In any case, you MUST give
each saving a NEW NAME.
When your program is mistake-free,
MPASM will produce a .hex file.
To download the latest
version of MPASM (v02.70), click HERE.
are now able to modify the program without wasting any chips. Any of
the routines can be altered to suit your own requirements, as explained
adapter for GP0, GP1, GP2, GP3 and Xtal on pins 2&3
Type B has 4k7 and 22p on board.
BEFORE BURNING A
Before a '508A chip is burnt, you must make certain the program is correct,
as you cannot easily alter it and re-burn the chip.
The only thing you can do is burn down unwanted instructions to 00. We
have used this "trick' to re-burn the phone numbers (see below) so the
chip can be re-burnt with a new number.
To save any hassles, make sure the program is operating correctly by
testing it with a PIC16F84.
When you are satisfied, burn a '508A.
Next, Table1 must be increased to at least 100 RETLW 0FFh to allow for
reprogramming of phone numbers. Make sure none of the program goes
into the second page of the '508A as the CALL instructions will not
work. To be absolutely accurate, it is the routine you are CALLing that
must reside within the first 256 bytes of memory.
The DIAL-08.asm program shown below (and in the .zip file) has
been designed to work for both the PIC16F84 and PIC12c508A micros. Only
files and port lines common to both chips have been used. In addition,
the start-up routine contains instructions that will be assembled correctly
for both chips.
Next, go to the Main routine and decide if the time duration for each
activation will suit your situation. We have allowed approx 15 sec of
listening to the target area, then producing a Hee Haw down the line,
a further 15 seconds of listening, then dialling the second phone number.
This cycle is repeated one more time before the alarm shuts down.
Next, insert the digits of the phone number you wish to call, IN PLACE
OF the 10 random digits in Table1. The phone number can have any
number of digits. End the number with RETLW 0E.
The RETLW values for the digits coincide with the numbers 1-9, except
for 0 = 0A as 0 represents ten pulses and ten in hex is 0A!
1 = RETLW 01h
2 = RETLW 02h
3 = RETLW 03h
4 = RETLW 04h
5 = RETLW 05h
6 = RETLW 06h
7 = RETLW 07h
8 = RETLW 08h
9 = RETLW 09h
0 = RETLW 0Ah
E = RETLW 0Eh - End of phone number
Do not code-protect the chip as the table values must be able to be
removed when re-burning it. This is done by burning down the old digits
to 00 00 and the next RETLW 0FFh locations are converted to digits for
TO RE-BURN A '508A CHIP
If you need to change the phone number, the old digits are turned into
00 00 (including the RETLW 0E command), and the new digits are put in
place of the RETLW 0FFh's.
This can be done until all the RETLW 0FFh locations are used. That's
why you should have up to 100 RETLW 0FFh when you first burn the chip
as you need a RETLW 0FFh for each new digit. For example, a 10 digit
number, plus RETLW 0E uses 11 RETLW 0FFh's.
The complete program for the alarm is shown below.
The .hex file has not been provided because there are a number of
things you have to change before burning a chip. The original program was
tested with the author's telephone numbers and these must be replaced with
your own. That's why the program has been left open. The timing sequence
is shown on a Flow Diagram on a previous page and this consists of calling
the first number then listening to the target zone for 15 seconds, sending
Hee Haw down the line then listening for a further 15 seconds before
calling the second number. This sequence is repeated again and the alarm
switches off. The lengths of any delay can be increased or
decreased, according to your requirements.
Alarm-1 PROGRAM |
;DIAL-08.asm for burning '508A chips
NOTE: This program does not dial a recognised phone number.
;These are the files common to both the F84 and '508A:
;0Eh loop file
;10h jump file for tables
;12h Count file
;13h Carrier DTMF
;14h Low tone
;15h decrementable low tone
;16h High tone
;17h decrementable high tone
;19h delay routine
;1Ah delay routines
;1Bh delay routines
;1Ch delay routines
;1Dh File to ring second number
;1Eh Ring numbers the second
SetUp MOVLW 08
;Put 0000 1000 into W
;Make GP3 input
;Clear port 6 of any junk
;Prescaler bit2 = WDT x 128
;Prescaler assigned to WDT
;Turn on TURN-ON circuit
;Turn off audio
;Table 1 for digits of YOUR two phone numbers
Table1 ADDWF 02,1
;File 02 = Low bits of program counter
;E = End of number
;E = End of number
RETLW 0FFh values are placed here
;for future phone numbers:
DTMF Low tones
Table2 ADDWF 02,1 ;File 02 = Low bits of program
;Table3 DTMF HIGH tones
Table3 ADDWF 02,1 ;File 02 = Low bits of program
;Short delay between tones approx
Del1A DECFSZ 1A,1
;Will produce 256 decrements
1B,1 ;64 decrements
of file 1B
;General purpose Delay approx 0.7sec
Del2 MOVLW 03
1A,1 ;After one pass,
files 1A, 1B will be
;256 and will produce the longest
Del3 MOVLW 0C
;Approx 5sec delay
any DTMF tone or whistle
Detect1 BSF 06h,0
;Turn off audio
;Allow 1u electro to discharge 0.7sec
;Allow 1u electro to discharge 0.7sec
;Clear detect file
;Input will be low when tone detected
;Turn on audio
dials the DTMF phone number
decrementable low tone
decrementable high tone
Dial1 MOVF 10h,0
;Put file 10h into W
;Put W into 13h - carrier
;Look for E - end of number
;Is 13h = E?
;File 13h will be 1,2,3 ..0A
;Get low-tone value
;Put low-tone into 14h
;Put high-tone into 16h
;100mS delay between tones
DTMF1 MOVLW 80h
;80 loops of tone
; to produce 1/10th sec
DTMF2 DECFSZ 17h,1
;Decrement high-tone file
;To toggle GP0
;To re-load high-tone file
;Re-load high-tone file
DTMF3 DECFSZ 15h,1
;Decrement low-tone file
;To toggle GP1
;To re-load low-tone file
;Re-load low-tone file
;Decrement loops file
;Turn on output & audio off
;Turn off output
Hee1 MOVLW 0C0h
Haw1 MOVLW 0FFh
;Keep alarm ON after Hee Haw
;Turn on audio
Main1 MOVLW 02
;to ring 2nd number
;to ring numbers second time
;to keep circuit ON
Main1A CLRF 10h
;Jump value for Table1
Main2 MOVF 10h,0
;Look for NOPs in Table1
; so chip can be re-burnt
Main3 CALL Dial1
;Silence after dialling
;Turn on audio
MOVLW 04h ;Put 4 loops
Main4 CALL Del3
;5 second delay
;Has tone been detected
;Shut off alarm
;Hee Haw sound
;Put 4 loops into W
Main5 CALL Del3
;Has tone been detected
;Shut off alarm
;Hee Haw sound
MOVLW 04h ;Put
4 loops into W
Main6 CALL Del3
;Has tone been detected
;Shut off alarm
;Hee Haw sound
;To hang up phone
Main7 CALL Del2
;5xDel2 before ringing
1C,1 ; 2nd number
;To pick up phone line
1Dh,1 ;File to ring 2nd number
1E,1 ;Ring numbers the
Main8 BCF 06,2
;To turn project off
;Micro will reset when it detects 0v
You will also need a text program such as TextPad or NotePad
You cannot use the .asm file above as a .asm for TextPad as it has added
spaces. These spaces will upset MPASM when it tries to compile the .asm
file to produce a .hex file. If you get an error on a line (from
MPASM) that seems to be correct, try re-typing the line(s) as it may contain
unseen spaces! To download Dial-08asm file as a .zip, click
You will need the: Multi
Chip Programmer - for burning '508 chips
You will also need to download the program PIP-02 to burn