This is only a preview of the June 2003 issue of Silicon Chip. You can view 29 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. Articles in this series:
Items relevant to "Sunset Switch For Security & Garden Lighting":
Items relevant to "Test Your Reflexes With A Digital Reaction Timer":
Items relevant to "Adjustable DC-DC Converter For Cars":
Purchase a printed copy of this issue for $10.00. |
PICAXE APPLICATION SPECIAL
PICAXE Telephone
Intercom/Interface
Here’s a very commonly requested circuit:
something to link two telephones together so
they actually work! It works with just about
any modern (ie, touchtone-type) phone – and
will even work with cordless phones or a
combination of cordless/corded models.
S
omehow, just about every hobbyist has managed to
score a phone or two for his/her junk box. None of
them are ex-rental, of course – they have just somehow materialised. But wouldn’t it be nice if you could
actually do something with them – like make them talk
to each other?
Here’s a simple circuit which does exactly that. It’s based
on our new best friend, the PICAXE-08, which means it is
dirt cheap and easy to build. When either phone is picked
up, the other one will ring until it is answered or the other
phone is hung up.
And the really good news is that your calls don’t cost
you a cent.
Whether you build this as a toy for kids (that’s what the
circuit was originally designed for), as an intercom between
rooms or even buildings of your home, business, factory,
whatever; serious or flippant . . . this will do it.
Its range will depend to some degree on the cabling you
use but could easily be a couple of hundred metres or so.
And as we said before, you can even use cordless phones
(or one of each) and make a fully wireless intercom.
Incidentally, phones make really great intercoms in
noisy areas because the earpiece is so close to the ear –
and you can yell into the mouthpiece to get the message
across!
Design by
David Lincoln
so all we have to do is simulate the phone exchange, right?
That’s pretty much how this circuit works. And we don’t
need a big building full of electronics! Fig.1 shows a block
diagram of what is required.
A line interface does exactly what its name suggests:
interfaces each phone to the line. That means we need
two of them. We also need a transmission bridge, which
connects the speech signals together. A controller determines when one phone is taken “off hook” (ie, the receiver
is lifted) and so rings the other phone. Finally, a power
supply provides all the voltages necessary to make the
whole thing work.
Fig.2 shows the circuit diagram, again broken up into
its functional blocks. First of all, we will look at one of
the line interfaces. These may look a little complicated at
first but they are really quite simple.
It works like this: when relay RLY1 is at rest (normally
closed), power is supplied to the line via the two 330Ω
Connecting two
phones
Unfortunately it’s
not simply a matter of
plugging one phone
into t’other and expecting them to work.
Phones rely on signals,
voltages, etc from the
telephone exchange –
18 Silicon Chip
Fig.1: the Telephone Intercom in block diagram. You
can compare these blocks to the circuits in Figs.2 & 3.
www.siliconchip.com.au
resistors. With a supply of around 30V, this means line
current will be around 35mA (depending on the line resistance and type of phone).
When RL1 pulls in, the normally open contacts close
and “ring current” flows in the phone line, causing the
phone to ring.
What causes RL1 to pull in? The circuit detects an “off
hook” condition by measuring the voltage across R2 (a
330Ω resistor). Zero volts across R2 means there is no
current flowing, therefore the other phone is on-hook.
When the phone is off-hook there will be up to 12V
across R2 (again, depending on the line resistance and
type of phone).
The circuit around the base of Q1 performs the off-hook
detection. R4, R5 and R6 form a voltage divider network
across R2. Their combined resistance is high enough to
have no effect on the line current. C1, in conjunction with
R4 and R5, filters out any AC components which may be
present in the line current.
The lower half of the voltage divider, R5 and R6, turn
Q1 on and off. When line current flows, the voltage at their
junction is high enough to fully turn Q1 on. The voltage
at Q1’s collector is compatible with TTL levels and is fed
directly into the PICAXE, which is programmed to detect
this as “off hook”.
Q2 and its associated
10kΩ base resistor (R8)
form a circuit which
will operate RLY1 when
there is a TTL-level
signal at the “ring”
terminal of the line interface. Obviously, this
signal also comes from
the PICAXE.
D1 protects the transistor from the back-EMF generated
when RLY1 releases.
The speech signal appears directly across the speech
terminals of the line interface and is connected to the
other line interface via the transmission bridge (two 2µF
capacitors). These capacitors block DC while allowing the
speech signal (AC) to pass. Some of the speech signal will
be lost due to R2 and R3. In a simple circuit such as this,
with reasonably short distances between phones, there
should be no problem, with enough speech signal left over
to “drive” the other phone.
The controller
The PICAXE-08 microcontroller is programmed to read
the the status of the off-hook signals from each phone and
Fig.2: everything except the power supply. The two line interfaces are identical; the green labels are explained in
the text. Components/connections marked * are only required while programming the PICAXE-08.
www.siliconchip.com.au
June 2003 19
Parts List - PICAXE Telephone Intercom/Interface
Interface Unit
Semiconductors
1 PICAXE-08, programmed
4 BC548 NPN transistors
4 1N4001 1A power diodes
(IC1)
(Q1,Q2)
(D1, D2)
Resistors (0.5W, 1%)
2 47kΩ
4 33kΩ 1 22kΩ 3 10kΩ
2 470Ω 1W 4 330Ω 1W
Capacitors
2 2.2µF electrolytic (C1)
2 2µF non-polarised
Miscellaneous
2 12V relays, SPDT contacts (RLY1, RLY2)
* Components of second (identical) interface not
numbered on circuit diagram
then use logic to provide ring signals to the phones.
We are not going to re-invent wheels by telling you how
to program your PICAXE-08; that’s the purpose of Stan
Swan’s “Fun With PICAXE” series which has been running
in SILICON CHIP since February of this year.
Suffice to say that the 10kΩ and 22kΩ resistors are
only required while programming (in fact, they may well
be part of your programming setup) and can be removed
once programming is accomplished. We imagine that
anyone building this project will program the PICAXE
out of circuit.
Software for the PICAXE is pretty straightforward – it
is shown in a separate panel.
The power supply
The power supply circuit is shown separately in Fig.3. It
supplies ring current, around 30V DC, 12V DC and 5V DC.
Power Supply
Semiconductors
1 BD139 NPN power transistor
1 7812 12V positive regulator
1 7805 5V positive regulator
2 1N4001 1A diodes
(Q1)
(REG1)
(REG2)
(D1, D2)
Capacitors
1 470µF 35V electrolytic
1 1000µF 35V electrolytic
1 1000µF 50V electrolytic
1 100µF 50V electrolytic
4 100nF monolithic
(C1)
(C2)
(C3)
(C4)
(C5-8)
Resistors
1 1kΩ
Miscellaneous
1 240V to 30V, 20-30VA transformer
1 12V AC 1A plugpack
The output from a 12V AC plugpack is rectified by a voltage doubler circuit consisting of the two 1N4001 diodes,
C1, C2 and C3. This produces around 32V (give or take,
depending on the regulation of your plugpack) across C3,
the main reservoir capacitor. This capacitor also provides
a low impedance return path for the ring current.
Half of the power supply output feeds a 12V regulator
(REG1) then a 5V regulator (REG2) to give the +12V and
+5V rails required by the line interfaces and controller.
The 100nF capacitors around the regulators should be
monolithic type; they bypass the supply lines to help
prevent parasitic oscillations in the regulators.
Q1 and its associated components form an active filter
for the 30V supply. Any ripple across C3 would be heard
as a very annoying hum in the phone earpieces and the
filter reduces that hum to inaudible levels.
The ring current is supplied by a 240V to 30V mains
transformer connected backwards. This transformer needs
to be rated at between 20 and
30VA. With a 12V input on the
30V winding, the output will
be about 100V – enough to
give you a nasty bite. So keep
your fingers away from the ring
current circuitry! The voltage
will of course drop under load.
Construction
Fig.3: the power supply provides three DC outputs as well as the ring
current. It is designed to operate from a 12V AC plugpack (12V DC will not
work!). Transformer T1 is a small 240V:30V model used backwards.
20 Silicon Chip
No PC board is provided
for this project, the original
being lashed together. Some
readers may like to go the
trouble of designing a PC board
– it would make for a neater
project.
Regardless of which physical method is used, construcwww.siliconchip.com.au
tion proceeds as would any project – smallest components first, polarised components, semiconductors then
“hardware”. Don’t mount the PICAXE-08 yet – however,
an IC socket is a good idea.
Resistors R1 and R2 can get hot, so they should be
mounted a few millimetres above any board to allow air
circulation.
It is NOT a good idea to use standard phone sockets or
jacks for this project. Obviously it cannot be connected to
the public phone network (not only will it not work, it’s
illegal!) so to avoid the possibility of someone doing this
by mistake, we suggest some other form of 2-pin plug and
socket to connect this circuit to your phone lines.
You will of course need a standard (modular-type) plug
to connect to the majority of phones.
Testing
Ensure there are neither phones nor microcontroller
plugged in. Apply power from the 12V AC plugpack (note
that it must be AC, not DC) and measure the voltages out
from your power supply. The main DC supply should be
around 30-32V or so – the exact value is not critical and
will vary a little depending on the mains voltage and the
quality of your plugpack.
The 12V and 5V supplies should be pretty-well spot on,
as they are coming from regulators.
Using an AC range on your multimeter, measure the
ring voltage (the output from the transformer). It should
be about 100V (and remember, it can bite a bit!).
If all voltages are OK, disconnect power and wait until the capacitors have discharged. Plug in the PICAXE
(assuming you have programmed it already!) and both
phones. Reconnect power.
When you lift one phone the other phone should ring.
When it does, pick it up and verify that the ring stops. If
the ring continues, it will be heard as a very loud buzzing
noise in the earpiece (don’t put it against your ear as it
could be quite painful!).
If all is well and the ring has stopped, check that you
can talk into one phone and be heard in the other.
Duplicate the testing for the other phone. If all checks
out, well done!
Aw shucks! It doesn’t work!
If the power supply voltages are not as they should be,
check your wiring and component placement. There is
very little else that could be wrong with the power supply.
If a phone doesn’t ring, first check both line circuits.
Use a multimeter to check the voltage between the phone
terminals with the phone disconnected – it should be
nearly the same as the DC output of the power supply. If
that’s OK, measure the voltage across R2 with the phone
on-hook and off-hook. It should be zero on-hook and
around 6-12V off-hook.
Repeat the voltage checks, on-hook and off-hook, at the
collector of Q1. This time it should be about 5V and less
than 0.5V respectively.
To test the ring, disconnect power and wait for the capacitors to discharge. Remove the microcontroller, then
reconnect power with both phones connected. Using a
jumper lead, temporarily connect the ring terminal for
each line to +5V.
Verify that the relay operates and the phone rings.
www.siliconchip.com.au
Telephone Intercom - PICAX-08 Code
main:
let b0 = 0
loop:
if pin4 = 1 and pin3 = 1 then atrest
if pin4 = 1 and pin3 = 0 and b0 = 0 then
ring1
if pin4 = 0 and pin3 = 1 and b0 = 0 then
ring2
if pin4 = 0 and pin3 = 0 then clearing
goto loop
atrest:
low 1
low 2
let b0 = 0
goto loop
ring1:
high 1
goto loop
ring2:
high 2
goto loop
clearing:
low 1
low 2
let b0 = 1
goto loop
If all else fails, try substituting another phone or two
(use phones that are known to be working). Note that older
phones equipped with mechanical bells may not work
properly with this circuit.
Your phone lines
Note our comments before about NOT connecting this
system to the public phone system.
Because it is a fully private system, you can use virtually
any 2-wire cable between the phones.
Phone wire is an obvious choice but you could use
speaker wire, bell wire, even two strands of fence wire
if they are on insulated posts! (Well, at least when the
posts are dry!).
And if you’re in the bush its probably a good idea to
keep your phone wiring well away from any electric fence
wiring !
The circuit should work with lines up to several hundred metres in length (depending on the type of wire
used and most particularly the resistance). In fact, the
line resistance will be the main factor in determining
distance.
Standard 0.5mm phone wire should be OK up to say a
couple of hundred metres; longer runs may need thicker
wire.
And while there are regulations which don’t allow you
to connect this to the mate’s place next door (ie, over the
boundaries of your property), we could never condone
your breaking those rules . . .
SC
June 2003 21
|