Skip to content

hharte/1dcoinctrl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

1dcoinctrl - Issue 4

Western Electric 1D/2D Payphone Controller Interface for Asterisk

WARNING - This project involves potentially lethal High-Voltage!

The coin relay in most payphones operates using +/- 130VDC. This project uses a DC-DC converter to boost 12VDC to 130VDC. Construction and operation of this circuit should only be performed by people familiar with best practices when operating with high voltage, and using extreme caution.

I WILL NOT BE HELD LIABLE FOR INJURY OR DEATH RESULTING FROM BUILDING OR USING THIS CIRCUIT. BUILD AND USE THIS CIRCUIT AT YOUR OWN RISK.

THIS HARDWARE AND SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL HOWARD M. HARTE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE HARDWARE AND SOFTWARE OR THE USE OR OTHER DEALINGS IN THE HARDWARE AND SOFTWARE.

Overview

This project aims to emulate a coin line as required by the older "dumb" (ie, non-COCOT) payphones such as the Western Electric 1D "Fortress" series. This coin line interface connects in between an Asterisk PBX and the payphone. It provides the coin control functionality as well as the ability to determine whether an initial rate has been deposited, and can also perform the "stuck coin" test.

This project is based on another open-source project (see References below) and has the following goals:

  1. Real coin-line signaling, while preserving the payphone earth ground. This requires both +130VDC (coin collect) and -130VDC (coin refund) as well as +25VDC for the "stuck coin" test and -25VDC for the "initial rate" test.
  2. The ability to provide up to four coin lines in a single unit.
  3. The ability to count dial pulses from Rotary payphones and provide the digits out-of-band to Asterisk.
  4. The ability to be red-boxed.

alt_text

Pay phone

The payphone is a standard Western Electric 1D phone with a 32B "dumb" chassis. I also verified that Western Electric 32A and TeleService 4032C chassis work well with this design.

Coin Line Signaling

All coin line signaling happens with respect to TIP and Ground with the RING open. For the tests, current flowing when voltage is applied indicates that either a coin is present in the hopper, or the initial rate has been deposited.

Voltage Operation
+130VDC Collect coins.
-130VDC Refund coins.
+25VDC Stuck Coin Test
-25VDC Initial Rate Test

Controlling the Coin Line Signaling

Control of the coin lines is handled by a PIC18F47Q84 microcontroller. This microcontroller can sense the line polarity and ON/OFF hook status, the test status, and can control the relays on the controller.

There are three relays that provide common control, and two additional relays per line.

Common Control Relays

  1. REFUND Relay: When operated will prepare negative voltage to be applied to the TIP when the selected line's COIN_CONTROL relay is operated. When this relay is operated, either Coin Refund or Initial Rate Test will be performed based on the state of the DISPOSITION relay.

  2. DISPOSITION Relay: When operated will prepare high voltage (either +130VDC or -130VDC, depending on the state of the REFUND relay) to be applied to the TIP when the selected line's COIN_CONTROL relay is operated. When the DISPOSITION relay is not operated, low voltage (+25VDC or -25VDC) will be applied in order to perform either the initial rate test or the stuck coin test.

  3. POLE-CHANGER Relay: This relay is used to swap the Vout+ and Vout- on the output of the 130VDC DC-DC converter so that both +130VDC and -130VDC are available depending on whether the coin should be collected or refunded.

Per-Line Relays, one each per coin line:

  1. HOLD Relay: When operated will shunt the TIP and RING towards the CO (Asterisk PBX in our case) with a 120-ohm resistor. This will keep the line on hold while coin disposition or rate tests are performed.

  2. COIN_CONTROL Relay: When operated, will apply the coin control voltage to the TIP towards the payphone. When not operated, the TIP and RING from the CO (Asterisk PBX) will be passed through to the payphone.

Sensors

There are several opto-isolated sensors in the design to provide status to the microcontroller.

  1. TEST_STATUS sensor will go low when current is flowing during a test. It will be high when current is not flowing.

  2. Per-line OFF_HOOK_F and OFF_HOOK_R sensors (one per line) will go low when current is flowing through the loop to the CO (Asterisk PBX) and can detect forward and reverse polarity. This current will be flowing either when the payphone is off-hook or when the line is on hold. Polarity reversal answer supervision, if provided by your telephone line, can be used to determine whether coins should be collected or refunded. These LEDs will blink rapidly while a rotary payphone is being dialed.

Microcontroller Firmware

The microcontroller firmware uses the Arduino development environment with the DxCore library for ease of development. The firmware provides a command-line interface via the serial port that uses a command set modeled after the familiar Hayes AT command set.

The command syntax is AT followed by a single character command, and an optional number [1-4] for the coin line to operate on. If the coin line is omitted, the previously used coin line is assumed.

Commands are as follows:

Command Description Response
AT Attention OK
ATZ Reset OK
ATC Collect coin OK
ATR Refund coin OK
ATI Initial rate test 0 = Initial rate not deposited

1 = Initial rate deposited

ATS Stuck coin test 0 = No coin in escrow.

1 = Coin in escrow.

ATQ Query hook state 0 = On hook

1 = Off hook (normal polarity)

2 = Off hook (reversed polarity)

ATL Query selected coin line 1-4
ATH Hold CO line OK
ATU Un-hold CO line OK
ATD Dump current controller state OK
ATE Stress test 100 refunds (1s apart) OK
ATT Coin line simulation Need hard reset to exit.
ATV Display firmware version OK
AT? Help Display command help

Building the Hardware

Components

The components for this board can be ordered from Digi-Key using this parts list. The list includes all components and accessories to build the full board supporting all four coin lines. The user will need to provide their own 12VDC power supply.

There is an interactive Bill of Materials here.

Stuffing Options

Relay Coil Voltage and DC-DC Converters

The schematic/BOM supports either 5V or 12V coil relays. Alternatively, the board may be built to support a 24VDC input voltage and the user may use 24V coil relays. In this case, PS1 and PS2 need to change:

Power Supply Voltage Relay Coil Voltage J8 Setting PS1 Part PS2 Part
+12VDC* 12V* 1-2 R12-100B IA1224S
+12VDC 5V 2-3 R12-100B IA1224S
+24VDC 5V 2-3 R24-100B IA2424S
+24VDC 24V 1-2 R24-100B IA2424S

Serial Port - RS-232 or 5V TTL-level UART

Communication with the host computer is either via RS-232 or 5V TTL-level UART.

Reference Designator RS-232 TTL UART Notes
U2 MAX202 or equivalent.
C3,C4,C5,C6,C8 0.1uF Capacitor
R2
C7 4700pF Capacitor
JP1 Programming Enable (to program Microcontroller)

Remove jumper from JP1 when using a standard FTDI 5V TTL UART cable.

JP2, JP3 1-2 2-3 Jumper 1-2 for RS-232 or 2-3 for TTL UART.
J5 6-pin right angle 0.1” male header.

Note: To switch between RS-232 and TTL UART, U2 can be removed from the socket, and the 5V TTL UART cable attached to J5. When switching back to the RS-232 port, detach the 5V TTL UART cable from J5 and reinstall U2. In addition to the TTL UART, J5 is also used to program the microcontroller.

External +/-130VDC Coin Collect / Refund Supply

The board can accommodate an external +/-130VDC supply with the following assembly changes:

Reference Designator Populate Do Not Populate Notes
PS1
C18
D2
D1 V_COIN_RELAY (130VDC) Indicator LED.
K1 Pole Changer Relay
R15
R5 5K Potentiometer
R9 V_COIN_RELAY (130VDC) Indicator LED current limit.
F2, F3 125mA Fuse
R10, R11 +/- 130VDC LED current limiting.
D3, D13 +/- 130VDC Indicator LEDs

Note: To switch between external +/-130 VDC supply and the on-board DC-DC converter:

  • At minimum, PS1 and K1 should be removed when using the external supply. If desired, a socket can be made for PS1 by removing several pins from a 24-pin 0.6” wide, machined-pin DIP socket. A socket can be made for K1 in a similar fashion, using a 16-pin machined-pin DIP socket.
  • At minimum, F2, F3 should be removed when using the on-board DC-DC converter. This is essential for two reasons:
  1. Safety: Prevent V_COIN_RELAY (130VDC) from being present on the +/-130VDC terminals of J1.
  2. Protection: to ensure that V_COIN_RELAY is not shorted to the +/-130VDC supply during operation.

Warning

D1, when illuminated, indicates that 130VDC is present on the board. While this LED is lit, be very careful not to touch the high-voltage section of the board.

D3, D13, when illuminated, indicates that external +/-130VDC is present on the board. While either of these LEDs are lit, be very careful not to touch the high-voltage section of the board.

Less Than Four Coin Lines

The controller can be assembled to support fewer than four pay phones. If only one pay phone is desired, U3 (7406) can be omitted, as well as components associated with lines 2 through 4.

Coin Line Reference Designator Do Not Populate Notes
2 D19 Bi-Color LED
D5, D7 1N4148 Switching Diodes
R4, R16, R24
K3, K6 Hold / Coin Control Relays
U5 Optoisolator
3 D20 Bi-Color LED
D8, D10 1N4148 Switching Diodes
R3, R18, R26
K5, K7 Hold / Coin Control Relays
U4 Optoisolator
4 D21 Bi-Color LED
D9, D11 1N4148 Switching Diodes
R1, R19, R25
K8, K9 Hold / Coin Control Relays
U1 Optoisolator

Enclosure

Included in the parts list is a Hammond 160mm extruded aluminum enclosure. This enclosure includes end caps that can be cut/drilled for the LEDs in the front of the board, as well as the connectors in the rear. Alternatively, a design for 3D-printed end caps is included in this project.

Issue 4 PCB

Microcontroller Replacement

The PIC microcontroller in previous revisions was replaced with an AVR128DA28 in the DIP-28 package. The firmware uses the Arduino development environment with the DxCore library for ease of development and programming.

Other changes between Issue 3 and Issue 4:

  • Additional LED connected to microcontroller pin PA7 under firmware control.

Still need to validate:

  1. Coin Lines 2, 3, 4.
  2. FTDI 5V TTL UART Connection.

Connections

J3, J4 - Lines

The controller supports four CO lines and four coin collectors via two RJ45 connectors. Each of these connectors is wired according to T568A.

Pin T568A Pair J4

CO Lines

J3

Coin Phones

Color
1 3 L3 Tip L3 Tip White/Green
2 3 L3 Ring L3 Ring Green/White
3 2 L2 Tip L2 Tip White/Orange
4 1 L1 Ring L1 Ring Blue/White
5 1 L1 Tip L1 Tip White/Blue
6 2 L2 Ring L2 Ring Orange/White
7 4 L4 Tip L4 Tip White/Brown
8 4 L4 Ring L4 Ring Brown/White

J1 - Power

Pin Description
+12VDC Positive 12V Input. This must be positive with respect to GROUND.
GROUND Power Supply Ground (Must be the same as earth ground.)
+130VDC_IN Coin voltage + (Optional, board assembly option.)
-130VDC_IN Coin voltage - (Optional, board assembly option.)

Earth Ground Lug

Coin control and tests are with respect to earth ground. All payphones must be grounded and bonded for safety as well as to provide a return path for coin collect/refund as well as the initial rate and stuck coin tests. If the payphone and coin line controller are not grounded, they will not work properly.

Serial Port

Communication with the host computer running Asterisk is via an RS-232 serial port at J6. If the user does not wish to use RS-232 levels to communicate with the computer, then the MAX202 IC at U2 should be removed from the socket. With the MAX202 removed, a USB to 5V TTL Serial cable connected to J5 (Ground pin on the left when looking at the rear of the controller) can be used to connect the coin controller to a PC via USB.

Indicators

The controller includes several indicator LEDs. Most are on the front panel; however, high-voltage warning LEDs are present inside the enclosure.

Reference Designator Indicates Notes
D15 Power Illuminates when +5VDC is present, indicating that the coin controller board is powered.
D16 MCU Status Illuminated under firmware (PA7) control by the on-board microcontroller.
D17 Test Status Illuminates during the stuck coin test or the initial rate test if the test result is positive: coin is stuck, initial rate is deposited. This status is input to the microcontroller on PA6.
D18 L1 Status Line 1 Hook State:
  • Not illuminated: On-hook
  • Green: Normal Polarity
  • Red: Reverse Polarity (Answer supervision.)
D19 L2 Status Line 2 Hook State
D20 L3 Status Line 1 Hook State
D21 L4 Status Line 1 Hook State
D1 V_COIN_RELAY (Internal) 130VDC produced by the on-board DC-DC converter.
D3 +130VDC (Internal) Indicates +130VDC from the external supply is present.
D13 -130VDC (Internal) Indicates -130VDC from the external supply is present.

Asterisk PBX Modifications

Modifications to Asterisk in order to recognize the 1700/2200Hz coin tones is based on Joshua Stein's project although I modified them to treat the 1700/2200Hz tones as a 5th row/column in the standard DTMF decoding routine in Asterisk's main/dsp.c.

The Asterisk AGI script is not complete, but at present it will prompt for money and can recognize the coin tones. It will complete the call after 25 cents has been deposited.

References

About

Western Electric 1D/2D Payphone Controller for Asterisk

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages