1dcoinctrl
Western Electric 1D/2D Payphone Controller for Asterisk
Install / Use
/learn @hharte/1dcoinctrlREADME
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:
- 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.
- The ability to provide up to four coin lines in a single unit.
- The ability to count dial pulses from Rotary payphones and provide the digits out-of-band to Asterisk.
- The ability to be red-boxed.

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.
<table> <tr> <td>Voltage </td> <td>Operation </td> </tr> <tr> <td>+130VDC </td> <td>Collect coins. </td> </tr> <tr> <td>-130VDC </td> <td>Refund coins. </td> </tr> <tr> <td>+25VDC </td> <td>Stuck Coin Test </td> </tr> <tr> <td>-25VDC </td> <td>Initial Rate Test </td> </tr> </table>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
-
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.
-
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.
-
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:
-
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.
-
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.
-
TEST_STATUS sensor will go low when current is flowing during a test. It will be high when current is not flowing.
-
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:
<table> <tr> <td><strong><em>Command</em></strong> </td> <td><strong><em>Description</em></strong> </td> <td><strong><em>Response</em></strong> </td> </tr> <tr> <td>AT </td> <td>Attention </td> <td>OK </td> </tr> <tr> <td>ATZ </td> <td>Reset </td> <td>OK </td> </tr> <tr> <td>ATC </td> <td>Collect coin </td> <td>OK </td> </tr> <tr> <td>ATR </td> <td>Refund coin </td> <td>OK </td> </tr> <tr> <td>ATI </td> <td>Initial rate test </td> <td>0 = Initial rate not deposited <p> 1 = Initial rate deposited </td> </tr> <tr> <td>ATS </td> <td>Stuck coin test </td> <td>0 = No coin in escrow. <p> 1 = Coin in escrow. </td> </tr> <tr> <td>ATQ </td> <td>Query hook state </td> <td>0 = On hook <p> 1 = Off hook (normal polarity) <p> 2 = Off hook (reversed polarity) </td> </tr> <tr> <td>ATL </td> <td>Query selected coin line </td> <td>1-4 </td> </tr> <tr> <td>ATH </td> <td>Hold CO line </td> <td>OK </td> </tr> <tr> <td>ATU </td> <td>Un-hold CO line </td> <td>OK </td> </tr> <tr> <td>ATD </td> <td>Dump current controller state </td> <td>OK </td> </tr> <tr> <td>ATE </td> <td>Stress test 100 refunds (1s apart) </td> <td>OK </td> </tr> <tr> <td>ATT </td> <td>Coin line simulation </td> <td>Need hard reset to exit. </td> </tr> <tr> <td>ATV </td> <td>Display firmware version </td> <td>OK </td> </tr> <tr> <td>AT? </td> <td>Help </td> <td>Display command help </td> </tr> </table>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:
<table> <tr> <td>Power Supply Voltage </td> <td>Relay Coil Voltage </td> <td>J8 Setting </td> <td>PS1 Part </td> <td>PS2 Part </td> </tr> <tr> <td>+12VDC* </td> <td>12V* </td> <td>1-2 </td> <td>R12-100B </td> <td>IA1224S </td> </tr> <tr> <td>+12VDC </td> <td>5V </td> <td>2-3 </td> <td>R12-100B </td> <td>IA1224S </td> </tr> <tr> <td>+24VDC </td> <td>5V </td> <td>2-3 </td> <td>R24-100B </td> <td>IA2424S </td> </tr> <tr> <td>+24VDC </td> <td>24V </td> <td>1-2 </td> <td>R24-100B </td> <td>IA2424S </td> </tr> </table>Serial Port - RS-232 or 5V TTL-level UART
Communication with the host computer is either via RS-232 or 5V TTL-level UART.
<table> <tr> <td><strong><em>Reference Designator</em></strong> </td> <td><strong><em>RS-232</em></strong> </td> <td><strong><em>TTL UART </em></strong> </td> <td><strong><em>Notes</em></strong> </td> </tr> <tr> <td>U2 </td> <td>✔ </td> <td> </td> <td>MAX202 or equivalent. </td> </tr> <tr> <td>C3,C4,C5,C6,C8 </td> <td>✔ </td> <td> </td> <td>0.1uF Capacitor </td> </tr> <tr> <td>R2 </td> <td>✔ </td> <td> </td> <td> </td> </tr> <tr> <td>C7