Dumb Pay Stations and Asterisk
The information on this page is not intended to be construed as a casual electronics project that just anyone can build. The control voltages used to operate the coin relay in the pay station are potentially lethal and anyone messing around with these voltages needs to observe extreme caution. If you decide to duplicate my control electronics, I will not be held responsible for any injuries or fatalities. I offer no warranties of fitness or function. Implement at your own risk.
The coin control capabilities I built consist of 3 separate design components. First there is some hardware to physically implement the the application of test and control voltages (the coin line simulator). Second, there is microcontroller firmware used by an on-board microcontroller to sequence the application of test and control voltages, and take commands from a serial communications channel. Finally, there is some software in the form of Asterisk AGI's which the extension logic uses to send commands to the microcontroller.
Coin Disposal - Action which comes from the coin line simulator to collect or refund the coins in the paystation hopper.
Coin Line - A special type of phone line which supplies the additional coin control voltages needed to test for, and dispose of coins.
Initial Rate Test - Action which is initiated to check for the presence of enough coins to make a paid local call.
A Review of Dialtone First Dumb Pay Station Control
Pay stations are connected to the central office with a 3-wire circuit consisting of Tip,Ring and Ground.
A dial tone first payphone works just like a normal phone as far as tip and ring are concerned. The interesting stuff occurs when ring is opened and various voltages are placed between tip and ground.The table below shows the various control voltages applied to the tip conductor referenced to ground:
Voltage from tip to ground
Initial Rate Test
Stuck Coin Test
When a user picks up the receiver on a dial tone first pay station, dial tone is sent by the CO. This allows the user to make calls to emergency services, and other services without having to use a coin to get a dial tone.The CO routing tables (In our case Asterisk's extension logic) determines which calls require the deposit of an Initial Rate and those which require no deposit. If the number dialed requires a deposit, the CO performs the initial rate test by applying the voltage as mentioned in the above table.
If a call requiring a deposit, is answered by the calling party, then the CO remembers this and will send the coin collect voltage at the end of the call. If the caller hangs up before the called party answers, then the coin return voltage will be sent at the end of the call.
A number of design compromises were made to simplify the design of the coin line simulation hardware:
A Prototype Controller
Here is a picture of the prototype coin line simulator I built installed on my wiring board in the garage:
The prototype was built on a Radio Shack 276-147 perfboard and enclosed in a 2 pc. aluminum box. The aluminum box is bonded to earth ground (Important!) with the large green wire shown in the top left of the picture. The earth ground terminal is also the the terminus of the pay station ground and the coin line simulator ground. The pay station connects to the 3 pole barrier strip at the top. The 16.5VAC input connects to the 2 pole barrier strip at the bottom right.The 4 pole barrier strip located at the mid to bottom left hand side of the board connects the serial control link to the RS-485 network infrastructure. The 2 pole barrier strip at the top left connects to the Asterisk PBX FXS port. The dip switch allows the relays to be manually controlled during testing and debug; all the switches are left in the open position when under control of the firmware. The rather large capacitor in the upper right is what stores the energy for the coin relay.
This is a somewhat complex implementation, and it has a lot of pieces which probably make it way more complicated than it needs to be.
In order to truly simulate a coin line, Asterisk must be able to control the coin line simulator by asking for its status and sending it commands. This is accomplished by implementing a communications channel. A block diagram of my communications channel is shown below:
Using the Perl Asterisk AGI and the Hanclient.pm module, the Asterisk server communicates over the wired Ethernet network in my home to an embedded linux Single Board Computer (SBC) in the garage. The SBC runs the Home Automation Network (han) server program and sends all the commands to a serial port which has an RS-485 level converter. This approach was great for me as all of this infrastructure was already in place, but for someone who is implementing this without any of that infrastructure, some redesign may be necessary in order to simplify things.
If there is no communications channel to the coin line simulator from Asterisk, then the coin line simulator will always return the coins when the pay station is hung up, and no initial rate test will be performed.
Code and Documentation
The schematics for the coin line simulator shown above are downloadable in the 3 links below:
Page 1 - Power Supply
Page 2 - Coin Control Relays
Page 3 - Microcontroller and Serial Data Link Isolation
The firmware is written in straight PIC assembler, and is compilable with MPASM or GPASM:
Firmware Source Code
Asterisk AGI program, Extension Logic, and Perl module for RS-485 Communications
AGI written in Perl
Hanclient.pm Perl module for RS-485 communications
han.conf for the Hanclient.pm perl module
han-0.0.5.tar.gz - Han server used to translate from TCP/IP to RS-485
Another fun project by Steve Rodgers, WA6ZFT