Sei sulla pagina 1di 48

Design and Implementing

a 1-to-4 PBX System


Using a Microcontroller
Behdad Hosseini
University of Isfahan, Iran
May 2003
Preface

This is the presentation of a project in partial fulfillment of the


requirement for the degree of Bachelor of Engineering in hardware
engineering presented to Department of Computer Engineering,
Engineering Faculty, University of Isfahan. The title of project is “Design
and Implementing a 1-to-4 PBX System Using a Microcontroller”.
The project started since September 2002 and lasted until May 2003.
I’ve done lots of its work in my home without any laboratory facility. So I
hope I’ve done something acceptable.
There are some useful technical documents about my project like
hardware schematics, a project report (but in Farsi) and its software in
assembly language. All of them can be found in the project’s web site.
I like to acknowledge everybody (especially my family) that helped my
in my project.

2 1-to-4 PBX Project May 2003


Abstract

Telephone centers or more precisely, branch exchange systems, are


electrical and electronical systems that are responsible for establishing
telephony communications. Their behavior can be explained by
making conversations between connected phones. Private Branch
eXchanges (PBXs) are some kind of such systems that are mainly
used in companies, organizations and other private complexes.
In this project, I’ve designed and implemented a PBX system that is
capable of switching 4 phones (lines) and an external connection
(trunk). A microcontroller from MCS-51TM family is used for handling
and controlling the whole system. The switching unit is realized via 3
analog conversation circuits (one for each conversation connection).
The hardware is implemented on 8 breadboards and the software is in
the MCS-51TM assembly language.

3 1-to-4 PBX Project May 2003


Introduction
Contents

Switching Theory
Telephone Switching System
About The Phonesets

5 1-to-4 PBX Project May 2003


Switching Theory (1)

Switched Network A network consists of some entities (stations)


that can communicate with each other and some controlling systems. If
we use some switching nodes instead of connecting every pair of
stations, we’ve made a switched network.
Switching means controlling some connections to making favorite
paths. These selections (and its actuators) are under our control. A
path can carry any signal from power to speech signals. About our
task, assume we have some phones or equally some speech signals.
We want to connect these phones to each other so we are concerned
about switching these signals.

6 1-to-4 PBX Project May 2003


Switching Theory (2)

Types of switching:
– Circuit the traditional form of the switching which makes the paths
physically by switches like relays and codecs. It is like an electrically close
circuit that connects our two desired points. So we can have any kind of
signaling if the frequency response of the path allows us and the current
value is supported by the elements. It means we can have analog or digital
data.
– Packet this kind of switching makes a virtual path not a physically one.
The data must be digital and encapsulated in packets. A packets is a
collection of data bits plus control bits that constructs its frames. The
switching can be performed by a simple PC or some specially designed
digital processing systems. So we can only transmit digital data or digitized
analog data.

7 1-to-4 PBX Project May 2003


Telephone Switching System:
Definition (1)

Definition An electrical and electronical circuit switching system is


called Telephone Switching System if the switched data is in the form
of analog speech signals (i.e signals with frequency between 0 and
4kHz) and can understand the request signals like dialing and can also
send meaningful informative signals like ringing. The electronic
technology of the system doesn’t matter. The important aspect is the
system behavior not the system structure. The switching section
usually is implemented in circuit switching model and can be analog or
can be digital as is done in new high performance systems.
Behavior From more practical point of view, Telephone Switching
Systems are capable of establishing conversation connections
between some connected phones or some external links (e.g from
another system).

8 1-to-4 PBX Project May 2003


Telephone Switching System:
Definition (2)

Types (Electronics) The Telephone Switching Systems can be


categorized by the electronic technology to:
– analog
– digital
Types (Domain) There’s also another kind of categorization that is
related to the domain of use (will be discussed in the next slides):
– Global eXchange (GX)
– Private Branch eXchange (PBX)

9 1-to-4 PBX Project May 2003


Telephone Switching System:
History

Point-to-point phones in 1876 (Bell)


Manual Telephone Switching Center
Crossbar (Matrix) Telephone Switching Center
Automated Central Telephone Switching
Analog Telephone Switching System
Digital Telephone Switching System
Exchange System

10 1-to-4 PBX Project May 2003


Telephone Switching System:
Some Technical Words (1)

Line A voice link is called a line if it is supposed to connect a phone


(or some systems alternatively) to the telephone network. Each lines
contains just one conversation link.
Trunk A voice link is called a trunk if it connects two switching
systems. So a trunk may contain more than one conversation links
(multiplexing).
Tip & Ring These are two wires that carries electrical voice signals
(in analog form). The positive one is called Ring and the negative is
Tip.
Inbound Signaling If the request and respond signals (like dialing
and ringing) is carried over tip and ring, it is inbound signaling. It is
more used in lines where one side is a phoneset.

11 1-to-4 PBX Project May 2003


Telephone Switching System:
Some Technical Words (2)

Outbound Signaling If we add some wires to the tip and ring just
for transmitting the control signals, it is called outbound signaling. In
this form, conversation is isolated from other signals. The trunks
usually uses outbound signaling because of its higher quality and ease
of use.
Conversation Circuit In analog telephone switching system there
are some buses (separated from each other) that may hold
conversations and is called conversation circuits (one conversation in
one circuit). It means each line / trunk can be connected /
disconnected from each bus (like a matrix).

12 1-to-4 PBX Project May 2003


Telephone Switching System:
GX

Global eXchange (GX) is a switching system that is implemented in


high scales to support a lot of lines and trunks. The formal telephone
network is implemented by GXs. The local telephone wires that is
came to our house is from a GX. These systems are connected
hierarchically to build the whole telephone network in a country or in
the world. The systems in leaf of that tree is connected to phonesets or
alternatively to a PBX.
Connections As is obvious from next slide, a GX is connected to
phonesets (or PBXs) through lines and another GXs through trunks. A
digital processing system can observe and control the policies of the
system but can be removed later. Monitor panel is a panel to show
some signals like current connections.

13 1-to-4 PBX Project May 2003


Telephone Switching System:
GX Connections

Monitor Panel

Line 1
Phone 1

Line 2 &Trunks
Phone 2 Another GX
GX Switching System
Signals

Line I
Phone I

Power
Data Processing
System

14 1-to-4 PBX Project May 2003


Telephone Switching System:
PBX

Private Branch eXchange (PBX) is a switching system but


usually in much lower scales to support the lines and trunks just for an
organization, company or another private complex. It designed for
private use i.e to switch some phonesets internally and also for
external connections through a few incoming lines (from the local GX).
So a hospital, hotel and … can connect all of its phones to the public
telephone network just through some few links.
Connections As is obvious from next slide, a PBX is connected to
phonesets (or PBXs) through lines and GXs through trunks. A digital
processing system can observe and control the policies of the system
but can be removed later. Monitor panel is a panel to show some
signals like current connections. Operator is a phoneset-like system
that has the ability to control connections specially from trunks to lines
and some other permissions.
15 1-to-4 PBX Project May 2003
Telephone Switching System:
PBX Connections

Operator Monitor
Panel

Line 1 Trunk 1
Phone 1 GX 1

Line 2 Trunk 2
Phone 2 GX 2
PBX Switching System


Line I Trunk J
Phone I GX J

Power
Data Processing
System

16 1-to-4 PBX Project May 2003


About The Phonesets (1)

On-hook / Off-hook These are two traditional words to express the


physical mode of the phone. When the handset of a phoneset is in its
place and can be ringed, it is in on-hook mode. When the handset is in
hand (a conversation or dialing is in progress) the mode is off-hook.
Voice The most important aspect of a phoneset is its ability to send
and receive speech signals through two wires: tip and ring. In a
handset there is a speaker and a microphone and the tip and ring pass
through these components (serially). The switching system is
responsible to put a dc power on these wires so the voice signals can
be carried over this voltage. It is obvious that in the conversation mode
the phoneset shows a dc resistance and lets dc current pass (a dc-
loop).

17 1-to-4 PBX Project May 2003


About The Phonesets (2)

Dialing When a phone wishes to connect to another, there must be a


way of addressing the destination. In nowadays telephone networks,
each phone (line) has a unique decimal number (with respect to its
local). The process of repeatedly sending the digits of destination no is
called dialing. There are two dialing modes:
– Pulse the phoneset opens and closes the dc-loop in a predefined timing to
send the the dialed digit to switching system.
– Tone the phoneset sends some special wave with predefined timings and
frequencies to show the dialed no. It this mode the dc-loop always exists.
Ringing When a phone wishes to connect to another one, the
switching system sends an ac power to the destination. If the
destination phone is in on-hook mode, it rings. In the on-hook mode
there isn’t a dc-loop but an ac-loop establishes.

18 1-to-4 PBX Project May 2003


About The Phonesets (3)

Notifying Tones There are some tones that switching systems send
to phones to inform the user of the result of its request.
– Dial tone a continuous wave after the handset pickup. It means it is ready
to accept the dialing.
– Ring back tone a discrete wave synchronous with ring wave to inform
the requester that the requested phone is ringing.
– Busy tone a discrete wave which means the requested phone is busy.
– Invalid tone a discrete one which means the dialed number is invalid.
Usually, its frequency is higher than the other tones.

19 1-to-4 PBX Project May 2003


The Project
Contents

Title
Behavior
Design Considerations
Hardware
Software
Sample Processes

21 1-to-4 PBX Project May 2003


Title

“Design and Implementing a 1-to-4 PBX System Using a


Microcontroller”.
PBX The project is a telephone switching system and is a Private
Branch eXchange.
1-to-4 It supports 4 lines (connection to phones) and 1 trunk
(connection to local GX).
Microcontroller The controller section is a microcontroller (a digital
processor + internal RAM + internal ROM + internal timers …).

22 1-to-4 PBX Project May 2003


Behavior (1)

Connections The system is connected to 4 normal phones and 1


external line (from local GX). The monitor panel is the monitoring leds
on the project’s boards. The input power is 220V, 50Hz ac voltage.
The optional data processing system is not implemented in this version
of project (see next slide for details).
Dialing mode The system supports only pulse dialing. It has no
reaction when encountering tone dialing.
Number assignments The system has 5 valid numbers: “0” for the
trunk, “1” for the 1st line, “2” for 2nd, “3” for 3rd and “4” for 4th line. Other
numbers are invalid.

23 1-to-4 PBX Project May 2003


Behavior (2)

Tones The system has 4 tones:


– Dial tone system is ready for dialing.
– Ring back tone requested phone is ringing.
– Busy tone requested phone is busy.
– Invalid tone dialed no is invalid.
Services No special services (like diverting, auto answering, …) exist
in this version of implementation. Note that the design method
guaranties adding new services and capabilities.

24 1-to-4 PBX Project May 2003


Behavior:
Connections

Monitor Panel

Line 1
Phone 1
Line 2
Phone 2 Trunk 1
Project’s PBX Switching GX 1
Line 3 System
Phone 3
Line 4
Phone 4

Power
Data Processing
System

25 1-to-4 PBX Project May 2003


Design Considerations (1)

Modular design Everything in this project is designed with modular


method. In this method special & predefined tasks are assigned to
each subsystem. These subsystems communicate with sending
requests and getting answers to each other in order to perform a
complex task. This method guaranties the following characteristics:
– Readability, writablity, debugging A reader can understand the
mechanisms better. The modifications are easy and the bugs can be
discovered quickly.
– Upgrade & development Hardware and software additions (like adding
lines or trunks, adding special services, …) are easy tasks. The project
development is bright and straight.
Analog switching The system utilizes the circuit switching with
analog technology. So there are some conversation circuits (i.e 3) to
switch connections.
26 1-to-4 PBX Project May 2003
Design Considerations (2)

Nonblocking system Every phone can be connected to another


one at any desired time. It means a connection won’t be blocked
because of lack of resources. There are 2 conversation circuits for
internal switching (i.e 4 phones) and 1 for connecting the phones to
trunk.
Digital controller A microcontroller from MCS-51TM family is selected
for controlling the whole system. It is observed that even though the
switching is analog, the controller is digital making all internal signals
(except voice signals) digital.
Trunk ring policy If a ring is sent to the trunk (by the local GX) the
system checks line 1 then 2 … to find first free phone and sends the
ring to the found phone in order to connect it to the trunk. Therefore in
this project, operator can be neglected.

27 1-to-4 PBX Project May 2003


Hardware:
Structure
Line 1

Line 2

Line 3

Line 4
Project’s
Line Unit Monitoring
Signals PBX
System

Switch Unit Control Unit

Data Power
Trunk Unit Signals Supply
Unit
Trunk 1

28 1-to-4 PBX Project May 2003


Hardware:
Units

Power Supply Unit This unit is responsible for supplying the necessary
voltages that other units need. This unit must supply the voice carrier
voltage applied to the phoneset, so must be designed with care.
Line Unit This unit interfaces the system with phonesets. It detects the
dialing & phone mode and also send ring signal. In this unit, tip and ring of
each phone (for use in switch unit) is constructed.
Trunk Unit It interfaces with trunk and has responsibilities similar to line
unit. The tip and ring of trunk (for use in switch unit) is constructed.
Switch Unit It has some conversation circuits and switches the phones
and trunk (under control of control unit) i.e their tip and ring wires.
Control Unit This unit controls the whole system. It gets detect signals
from line and trunk units and sends control signals to switch unit and (if
necessary) to line and trunk units.
29 1-to-4 PBX Project May 2003
Hardware:
Some Components
Relays The main switch components that is used in this project are
relays. A relay is an electrical-mechanical component capable of
attract a contact with an electrical command in order to connect /
disconnect some connections. It is like a key with electrical control.
Despite of its mechanical problems, it’s an idle component for passing
a wide range of signals with different powers.
Open collector not gates Just like normal logical not gates, open
collector not gates, negates the input signals but with one major
difference. The output layer transistors are open collectors, which
means are not connected to power voltage.
Opto-couplers A semiconductor device which consists of a normal
led and a BJT transistor with optically sensitive base. If a current is
passes through the led, it stimulated base just like a normal current.
It’s main usage in this project, is detecting dc-loop in order to find
phoneset mode.

30 1-to-4 PBX Project May 2003


Hardware:
Boards (1)

Power Supply board It produces the following voltages:


– +5Vdc: for the digital (gates and microcontroller) components.
– +18Vdc: for carrying the voice signal and also for driving the relays.
– 110Vac: This board also generates an ac voltage (around 50Hz) as the
ring voltage for applying to phonesets.
Line boards Each line board contains 2 line interface circuits that
interfaces a phoneset to the system and do the following tasks:
– Detecting the phone mode (Off-hook or On-hook), also useful for detecting
pulse dialing signals.
– Applying the ring to phone, if necessary.
– Carry tip and ring wires to switch unit for switching.
– Showing the phone mode and phone ring signal by two leds.

31 1-to-4 PBX Project May 2003


Hardware:
Boards (2)

Trunk board The trunk board contains 1 trunk interface circuits that
interfaces a trunk to the system and do the following tasks:
– Detecting the trunk ring signal.
– Carry tip and ring wires to switch unit for switching.
– Showing the ring signal and connect mode by two leds.
Conversation Circuit boards Each conversation circuit board
contains 1 conversation circuit that is able to create one conversation
between some lines or trunk. Control unit controls which relays are active
and therefore switching of each circuit.
Control board This board has one microcontroller from MCS-51TM
(AT89C52) that controls the system by scanning the detect signals and
retrieving the request information then sending controlling or monitoring
signals and if necessary, switching the lines / trunk (via switch unit).

32 1-to-4 PBX Project May 2003


Control Unit Line Unit

Control board L0_RNG Line 0&1 board


L0_TIP
L0_INTR pbx.dsn L0_RING
L0_DTCT (Line 0” sheet)“
L1_TIP
L1_RNG
pbx.dsn L1_RING
L1_INTR (Line 1” sheet)“
L1_DTCT

L2_RNG Line 2&3 board


L2_TIP
L2_INTR pbx.dsn
VCC L2_RING
+18V L2_DTCT (Line 2” sheet)“
Ring
L3_TIP
Hardware: Boards Diagram

1 L3_RNG
Ring pbx.dsn L3_RING
2 L3_INTR (Line 3” sheet)“
Power L3_DTCT
Supply
Unit
Switch Unit
Power C0_S0
Supply
board C0_S1 Conversation Circuit 0 board
C0_S2 pbx.dsn
C0_S3 (Conversation Ckt 0” sheet)“
pbx.dsn

C0_TONE
)“Control” sheet(

C1_S0
C1_S1 Conversation Circuit 1 board
C1_S2 pbx.dsn
C1_S3 (Conversation Ckt 1” sheet)“
C1_TONE
C2_S0
C2_S1 Conversation Circuit 2 board
pbx.dsn )“Power Supply” sheet(

C2_S2 pbx.dsn
C2_S3 (Conversation Ckt 2” sheet)“
C2_TONE

Trunk Unit

Trunk 0 board
T0_CNCT T0_TIP
pbx.dsn
T0_RDTCT T0_RING
(Trunk 0” sheet)“
Hardware: Photo
Software:
Structure
Line Ports Trunk Ports

Line Hardware Interface Unit Trunk Hardware Interface Unit

Line Control Unit Trunk Control Unit

Project’s
Central Control Unit Software
Architecture

Switch Control Unit

Ring & Tone Generator


Unit Switch Hardware Interface Unit

Switch Ports

35 1-to-4 PBX Project May 2003


Software:
Units (1)

Line Hardware Interface Unit This unit is responsible for


interfacing the line ports (hardware signals) to the software. Every
access to line ports are through this unit. This unit also translate detect
signals to some meaningful messages.
Trunk Hardware Interface Unit This unit is similar to Line one but
interfaces the trunk ports.
Switch Hardware Interface Unit This unit interfaces the switch
ports to software or in the other words, any access to switch ports
must be through this unit.
Line Control Unit This unit controls each line by getting messages
from line interfaces and central control. In this unit the applied signals
to the phone is constructed and it watches over any change
concerning with the line (phone).

36 1-to-4 PBX Project May 2003


Software:
Units (2)

Trunk Control Unit Like the line one, this unit controls the trunk. It
receives messages from trunk interface and central control in order to
build trunk control signals.
Switch Control Unit This unit has a collection of useful routines for
handling and monitoring the switching.
Central Control Unit This unit is responsible for making inter-
routine communication and higher policies are held in this unit. This
unit applies number assignments and connects the three above control
units to each other.
Ring & Tone Generator Unit This unit generates all of the tones
and waves that is needed in the software including: ring wave, dial
tone, busy tone, ring back tone and invalid tone.

37 1-to-4 PBX Project May 2003


Software:
Considerations (1)

Concurrency Because of executing some routines (like control units)


in real time mode, we are encountering with a concurrency problem.
This can be solved by use of hardware interrupts but this solution is
not applicable in all situations where we have some software routines.
The used method is time sharing and use of timer interrupt. For
simplifying the context switching, all of the concurrent routines are
state-based. Whenever a change has been detected in the system, an
event is created and will be propagated in the related control units. So
the switching between concurrent routines is done by themselves not
by forcing and cutting their execution.

38 1-to-4 PBX Project May 2003


Software:
Considerations (2)

State-based routines State-based routines are routines that have


some finite states and are in one of those states in every specific
time.When a messages or events is received by these routines, the
state will be updated and if necessary some action will be done.
Event-driven routines Whenever a change has been occurred in
the system, an event is created usually by interface routines and will
be reported to the other parts of the software. This mechanism
guaranties that if and only if something is changed, processor will
process it not always. Therefore the processor will have enough time
to complete concurrent tasks.

39 1-to-4 PBX Project May 2003


Software:
Phone States
StIdle Normal state of the phone i.e on-hook.
StDialTone The handset is picked up and the dial tone must be
applied (ready to dial).
StDialing The user is dialing. No tone must be applied.
StInvalidTone The requested no is invalid. Invalid tone must be
applied.
StBusyTone The requested no is busy. Busy tone must be applied.
StTrunk The requested no is the trunk and the connection is
established.
StRingbackTone The requested phone is ringing. Ring back tone
must be applied.
StTalk A talk (conversation) is established and is in progress.
StRing The phone is ringing (requested by another phone).
40 1-to-4 PBX Project May 2003
EvPutdown StRingback EvEOD+EvNoLineRB
Tone

EvAllRel
(EvToneReq(TnRingback
EvTalkCancel

Accept
EvTalk
(EvToneReq(TnNo

EvPutdown
StTalk

EvAllRel EvTalkAccept

EvPickup
EvEOR
Software: Phone State Diagram

StRing
EvSOR
EvConvReq
(EvToneReq(TnDial

EvPickup
StIdle StDialTone EvSOD StDialing
EvPutdown

EvAllRel (EvToneReq(TnNo

EvPutdown
EvDigitDialed

EvPutdown StInvalid EvEOD+EvNoInvalid


Tone

EvAllRel (EvToneReq(TnInvalid

EvPutdown StBusy EvEOD+EvNoLineBusy


Tone EvEOD+EvNoTrunkBusy

EvAllRel
(EvToneReq(TnBusy
EvTrunkRel

EvPutdown EvEOD+EvNoTrunkOK
StTrunk
Software:
Routines (1)

Initialize routines These routines are executed once (usually after a


reset) and will initialize variables and set up the timer settings.
Timer ISR routine When an interrupt is received by the processor, it
will execute this routine that is responsible for invoking the timing
routines repeatedly.
Timing routines These routines make the necessary timings like
1ms, 20ms, 1s … and will call the time sensitive routines (like interface
routines) with special periods.
Memory Access routines Access to memory is through these
routines. Each routine that needs to restore / retrieve some value (like
its state) will call the related memory access routine.

42 1-to-4 PBX Project May 2003


Software:
Routines (2)

Hardware Access routines These routines interface the software


and ports. Any routine that needs to change or read a port will do that
via these routines.
Interface routines These routines translate the hardware signals to
events (if required) and will propagate it through the software.
Control routines These routines control the parts of the hardware
(lines, trunk and switches) by attending to events and messages from
interface and other control routines.
Debugging routines There are some routines just for debugging
and development of the software. These routines can be removed in
the final implementation of the software.

43 1-to-4 PBX Project May 2003


Sample Processes (1)

Internal connection In this process a line connects to another line.


First, a user pickups the handset (off-hook). The hardware signal is
detected by the interface routines and the appropriate event is
generated. The state of its line control will be updated and the dial tone
will be applied. Now, requester starts to dial, the software finds out the
dialed no by watching over the hardware, then sends the no to central
control and gets the meaning of the dialed no. Assume it is no of a free
line. The destination starts to ring. When the handset is picked up, the
connection is established (switched) and voice signals can be
transmitted. When two sides put down the handsets (on-hook) the
connection is ended and the resources are returned to the system.

44 1-to-4 PBX Project May 2003


Sample Processes (2)

External connection In this process the trunk is ringed by the local


GX. First the ring is detected by hardware and the interface software
makes an event to inform the central control of what has been
happened. In this case, according to the trunk ring policy of the
system, the first free phone with higher priority will be ringed. When the
handset is picked up the connection starts and a dedicated
conversation circuit will hold the conversation. When the destination
put downs the handset (off-hook), the resources return to the system
and the communication ends.

45 1-to-4 PBX Project May 2003


Summary
Summary (1)

Development Suggestions:
– The switch unit can be implemented using digital technology. It needs
major changes in hardware and software.
– Tone dialing can be supported by adding some hardware component to
line boards. Of course some software modification is needed.
– Operator is another possible addition that can be implemented using a new
hardware unit and its software drivers.
– Lots of services like diverting, auto answering, conferencing … and
monitoring and also logging can be supported by system just by adding
required software routines.

47 1-to-4 PBX Project May 2003


Summary (2)

Conclusion:
– This project is an electrical and electronical circuit switching system, a PBX
i.e a Private Branch eXchange that is implemented in analog technology.
– Mixture of electronics, communication, software and hardware theories and
technologies are used to construct the project.
More Information:
– All of project documents are in electronic form and are stored as PC files,
please refer to them for more technical information.
– For information of the used microcontroller, please refer to the Intel®
official site: www.intel.com.

48 1-to-4 PBX Project May 2003

Potrebbero piacerti anche