Build Plans

PICAXE Telephone Exchange Simulator




This PICAXE Telephone Exchange Simulator is presented "as is" with no warranty or guarantee of operational correctness. The electronic design has not been exhaustively tested but appears to work with the configuration used by the author, but that is no guarantee that the design is sound or that damage will not occur when used with your own equipment. Anyone using the designs or information related to it herein does so entirely at their own risk. No liability whatsoever is accepted by the author.

This project is a work in progress and should be considered as an educational resource rather than as a completed project.


Important Note - Limitations on Use - Prohibitions

  Under no circumstances must the Telephone Exchange Simulator described here be connected to a public telecommunications system in any way. Doing so will render you liable to prosecution and other penalties. Connection to a public telecommunications system or any private telephone exchange will probably destroy the electronics of this device and may damage the telephone exchange.


Full Project Details

Full details of the project can be found on the following page ...


Prototype

  Note that the prototype shown here may differ from the veroboard layout shown later, and may use a different circuit to that finalised.


Main Circuit Diagram

        BT431A       -.- +12V                                               BT431A
         Line        .|.                                                     Line
        Socket       | | 330R                                               Socket
       .------.      |_|                                                   .------.
   1   | =====|       |                                                    |===== |   1
   2   | =====|-------^-----------.----------------------------------------|===== |   2
   3   | =====|                   |    ___             ___                 |===== |   3
   4   | =====|                   `---|___|---.-------|___|--------.       |===== |   4
   5   | =====|-------. +5V -.-        18K    |        10K         |   .---|===== |   5
   6   | =====|       |      |                |                    |   |   |===== |   6
       `------'       |      |   .---..---.   |                    |   |   `------'
       Dial-Out       |      `---| +V  0V |---|--------------------{   |     Modem
        Device        |      .---| SI  O0 |---|---.                |   |
                      |     .|.  | D4  A1 |---'   |  |\ |     22K  |   |
           .-.        | 22K |_|  | I3  D2 |---.   `--| >|--.---.   |   |
 Download  |O|--------|------{   `--------'   |      |/ |  |  .|.  |   |
         .-|O|-----.  |     .|.  PICAXE-08M   |     1N4001 |  | |  |   |
   Run   `-|O|--.  |  | 10K |_|               |            |  |_|  |   |
           `-'  |  |  |      |                |            |   |   |   |
         Molex  |  |  }------^----------------|------------|---^---^---'
          link  |  |  |      | /|     ___     |      |\ |  |
                |  |  }------|< |----|___|----'   .--| >|--{
       .---.    |  |  |      | \|     1K8         |  |/ |  |     .---.
       |    \   |  |  |       LED                 | 1N4001 |     |    \
1      | O---\--|--|--|---------------------------|--------|-----|-O   \   1      DCD to PC
   6   |   O-|--|--|--|---------------------------|--------|-----|---O |      6   DSR to PC
2      | O---|--|--|--|---------------------------'        `-----|-O   |   2      TX  to PC
   7   |   O-|--|--|--|------------------------------------------|---O |      7   RTS from PC
3      | O---|--'  `--|------------------------------------------|-O   |   3      RX  from PC
   8   |   O-|--------|------------------------------------------|---O |      8   CTS to PC
4      | O---|--------|------------------------------------------|-O   |   4      DTR from PC
   9   |   O-|--------|------------------------------------------|---O |      9   RI  to PC
5      | O---/--------^---.--------------------------------------|-O   /   5      GND
       |    /             |                                      |    /
       `---'             -^- 0V                                  `---'
    9-Way Male D                                             9-Way Female D
     From Modem                                                  From PC


Diagnostics port

                                         .---.
                                         |    \
                                 .-------|-O   \   1      DCD to PC
                    PICAXE       }-------|---O |      6   DSR to PC
                     'D4'  >-----|-------|-O   |   2      TX  to PC
                                 |   .---|---O |      7   RTS from PC
                                 |   |   | O   |   3      RX  from PC
                                 |   `---|---O |      8   CTS to PC
                                 `-------|-O   |   4      DTR from PC
                                         |   O |      9   RI  to PC
                           .-------------|-O   /   5      GND
                           |             |    /
                       0V -^-            `---'
                                     9 Way Female D
                                          To PC


Power Supply

                                              .--------------------------> +12V
                              7812            |        7805
            |\ |           .---------.        |     .---------.
    VUR >---| >|---.-------| I     O |----.---^-----| I     O |----.-----> +5V
            |/ |   |       |   GND   |    |         |   GND   |    |
                 __|__     `----.----'  __|__       `----.----'  __|__
                 ===== 4700uF   |       --.-- 100nF      |       --.-- 100nF
                   |    25V     |         |              |         |
     0V >----------^------------^---------^--------------^---------^-----> 0V


Parts List

    1 x PICAXE-08M
    1 x 8-Pin DIL Socket
    1 x 7812 or 78L12 +12V Regulator
    1 x 7805 or 78L05 +5V Regulator
    4 x 1N4148 Signal Diodes
    1 x Red LED ( Power On )
    1 x Green LED ( Status )
    1 x 4700uF/25V Electrolytic Capacitor
    2 x 100nF Polyester Capacitor
    1 x 330R Resistor
    1 x 1K8 Resistor
    1 x 4K7 Resistor
    2 x 10K Resistor
    1 x 18K Resistor
    2 x 22K Resistor
    1 x 3-Pin 0.1" Molex Terminal
    1 x 2-Pin 0.1" Molex Link
    1 x 9-Way Female D Socket
    1 x 9-Way Female D Socket ( Optional : Diagnostic Port )
    1 x 9-Way Male D Socket
    2 x UK Single Telephone Line Sockets


Veroboard Layout and Track Cutting Diagram


Software

    '   ***************************************************************
    '   *                                                             *
    '   *   PICAXE-08M Telephone Exchange Simulator    PICAXELS.BAS   *
    '   *                                                             *
    '   ***************************************************************

        SYMBOL A2D                     = 1
        SYMBOL LED                     = 2
        SYMBOL TX                      = 4

        SYMBOL LED_PIN                 = pin2

        SYMBOL ledStatus               = w0 ' b0/b1

        SYMBOL lineLevel               = b2
        SYMBOL minLineLevel            = b3
        SYMBOL maxLineLevel            = b4

        SYMBOL onHookCount             = b5
        SYMBOL offHookCount            = b6

        SYMBOL powerOnDelay            = b7
        SYMBOL ringDelay               = b8

        SYMBOL MIN_ON_HOOK_LINE_LEVEL  = 224
        SYMBOL MAX_OFF_HOOK_LINE_LEVEL = 152

        SYMBOL LINE_LEVEL_GAP          = MIN_ON_HOOK_LINE_LEVEL -
                                         MAX_OFF_HOOK_LINE_LEVEL

        SYMBOL LINE_LEVEL_OFFSET       = LINE_LEVEL_GAP / 3

        SYMBOL ON_HOOK_LINE_LEVEL      = MIN_ON_HOOK_LINE_LEVEL -
                                         LINE_LEVEL_OFFSET
        SYMBOL OFF_HOOK_LINE_LEVEL     = MAX_OFF_HOOK_LINE_LEVEL +
                                         LINE_LEVEL_OFFSET

        SYMBOL ON_HOOK_THRESHOLD       = 5
        SYMBOL OFF_HOOK_THRESHOLD      = 5

        SYMBOL LED_STATUS_POWERUP      = %0100000000000000
        SYMBOL LED_STATUS_UNKNOWN      = %0000000011111111
        SYMBOL LED_STATUS_ERROR        = %0011001100110011
        SYMBOL LED_STATUS_RING_DELAY   = %0011111111111111
        SYMBOL LED_STATUS_ON_HOOK      = %0000000000000000
        SYMBOL LED_STATUS_OFF_HOOK     = %1111111111111111

        SYMBOL TX_BAUD                 = N2400 ' 4800 @ 8MHz

    PowerOnReset:

        SETFREQ M8

        LOW LED
        ledStatus = LED_STATUS_POWERUP

        FOR powerOnDelay = 0 TO 100 ' 5s
          GOSUB UpdateLedAndCheckLineLevel
        NEXT

        SEROUT TX,TX_BAUD,("= ",#OFF_HOOK_LINE_LEVEL,
                           "/",#ON_HOOK_LINE_LEVEL,CR,LF)

        onHookCount  = 0
        offHookCount = 0

        minLineLevel = 255
        maxLineLevel = 0

        ledStatus = LED_STATUS_UNKNOWN

    UnknownState:

        GOSUB UpdateLedAndCheckLineLevel
        IF onHookCount  >= ON_HOOK_THRESHOLD  THEN GoneOnHook
        IF offHookCount <  OFF_HOOK_THRESHOLD THEN UnknownState

        ledStatus = LED_STATUS_ERROR

        SEROUT TX,TX_BAUD,("Stuck ")

        GOTO IsOffHook

    GoneOnHook:

        ledStatus = LED_STATUS_ON_HOOK

    IsOnHook:

        SEROUT TX,TX_BAUD,("On",CR,LF)

    OnHook:

        GOSUB UpdateLedAndCheckLineLevel
        IF offHookCount < OFF_HOOK_THRESHOLD THEN OnHook

    GoneOffHook:

        ledStatus = LED_STATUS_RING_DELAY

    IsOffHook:

        SEROUT TX,TX_BAUD,("Off",CR,LF)

        IF ledStatus <> LED_STATUS_RING_DELAY THEN OffHook

        FOR ringDelay = 0 TO 100 ' 5s
          GOSUB UpdateLedAndCheckLineLevel
          IF onHookCount >= ON_HOOK_THRESHOLD THEN GoneOnHook
        NEXT

        ledStatus = LED_STATUS_OFF_HOOK

        SEROUT TX,TX_BAUD,("Ring",CR,LF)

        SERTXD("RING",CR,LF)

    OffHook:

        GOSUB UpdateLedAndCheckLineLevel
        IF onHookCount < ON_HOOK_THRESHOLD THEN OffHook

        GOTO GoneOnHook

    UpdateLedAndCheckLineLevel:

        PAUSE 100 ' 50mS @ 8MHz

        LED_PIN = bit15
        ledStatus = ledStatus * 2 | bit15

        IF powerOnDelay <= 100 THEN InPowerUpDelay

        READADC A2D,lineLevel

        GOSUB UpdateOnAndOffHookCounts
        GOSUB CheckMinAndMaxLineLevelChanges

    InPowerUpDelay:

        RETURN

    UpdateOnAndOffHookCounts:

        IF lineLevel >= ON_HOOK_LINE_LEVEL  THEN GotOnHookLineLevel
        IF lineLevel <= OFF_HOOK_LINE_LEVEL THEN GotOffHookLineLevel
        RETURN

    GotOnHookLineLevel:

        onHookCount  = onHookCount+1
        offHookCount = 0
        RETURN

    GotOffHookLineLevel:

        offHookCount = offHookCount+1
        onHookCount  = 0
        RETURN

    CheckMinAndMaxLineLevelChanges:

        IF lineLevel >= minLineLevel AND
           lineLevel <= maxLineLevel THEN NoMinOrMaxLineLevelChange

    CheckMinLineLevel:

        IF lineLevel >= minLineLevel THEN CheckMaxLineLevel
        minLineLevel = lineLevel

    CheckMaxLineLevel:

        IF lineLevel <= maxLineLevel THEN ReportMinAndMaxLineLevels
        maxLineLevel = lineLevel

    ReportMinAndMaxLineLevels:

        SEROUT TX,TX_BAUD,(#minLineLevel,"..",#maxLineLevel,CR,LF)

    NoMinOrMaxLineLevelChange:

        RETURN


PICAXE is a trademark of Revolution Education Ltd.





Associated Articles

  The PICAXE Processors
  PICAXE News
  PICAXE Questions & Answers
  PICAXE Comparisons
  PICAXE Pinouts
  PICAXE Serial Interfacing
  PICAXE Infra-Red Interfacing
  PICAXE Wireless Interfacing
  PICAXE LCD Interfacing
  PICAXE LCD Interfacing
  A Real-Time Clock for the PICAXE
  PICAXE Optimisations
  The PICAXE Birthday Box Project
  PICAXE Telephone Exchange Simulator
  The Brainf**ked PICAXE
  The PICAXE Extended Programming Interpreter
  Build Your Own Basic Stamp
  Tech Toys



Sites to Visit

  PICAXE Home Page
  Revolution Education Ltd



Site Navigation

  Home Page
  What's New
  Search
  Add Bookmark
  Have Your Say
  Guestbook



PICAXE Telephone Exchange Simulator © 2004, The Happy Hippy


First published on Saturday the 17th of July, 2004 at 14:52:00
Last upload was on Thursday the 19th of August, 2004 at 02:27:25