Analog phone pulse to tone converter with PT switch

 TL;DR

  • We're going to explore electronics of analog (POTS) phone and use some existing pulse to tone converter projects to make it work with contemporary landline
  • We're going to extend functionality of such converter to provide classic Pulse-Tone switch known from later models
  • Firmware, PCB (Gerber files), BOM and assembly instructions are available at the end of this document
 
 
There is this city in Poland, called Radom. It is believed to be one of the worst cities to live in.

As the famous saying goes:
- So, you're almost 40. Thinking abount getting married? Some children maybe?
- Yep, first thing after getting back from Radom.
- So you're going to Radom! When exactly?
- I'm not going to go there at all :)
Tens of years ago, when Poland was a proud member of eastern block, Radom was also famous of two things: small arms factory "Łucznik" and RWT (Radomska Wytwórnia Telekomunikacyjna) - a company producing phones. By the way - it's a nice way of marketing to name a company by the city it is located in and the items it produces (RWT translates directly to Radom's Factory of Phones). Well... I've just recalled Detroit Diesel and Texas Instruments... nevermind.

Anyway, one of the RWT's products is the subject of this article. Let me present RWT Elektrim (codename CB-664) - an ancient analog phone with rotary dial. Our job for today is to make it work with modern landline.
 
(RWT Elektrim CB-664)

Motivation

My motivation for this project is to get a handy tool to annoy my coworkers. I needs it to be fully functional in order to mitigate any excuses for throwing it out of the window. Also, besides some amount of nostalgia (I owned the same model some 30 years ago), the text "If it annoys you, just change the ringtone" is the one I'm especially proud of.

Analog telephony

I'm a computer networks engineer with minor experience in VoIP and enthusiast of electronics, so pardon my layman's approach to analog telephony. I'm gonna focus only on what happens inside the phone and between the phone and a wall socket when one is dialing a number, talking and when the phone is ringing.

So, as far as I'm concerned, a classic landline consists of two copper wires (a copper pair). The potential difference between them when the line is idle (i.e. phone not working in any way or not connected to the socket at all) is 48V DC nominal. Could we tap into these 48V to power our phone's "standby" circuitry? I don't think so. I don't believe there is any standarised "current yield" of the landline greater than "nothing", and any form of load between these two wires would quickly result in radical voltage drop. This will become important in a moment.

An analog phone has a hook, a mechanical switch that connects some audio circuitry to the line at the moment the receiver is picked up. This typically consists of microphone and speaker connected in series. It is connected to the line using a transformer. Let's leave out a problem of sidetone for now. Also, there needs to be a way to signal "receiver off-hook" state to the exchange. This is done by drawing some current off the line. Thats why a 100-ohm resistor in parallel to the audio circuitry
"shorts" the line when the hook is activated.
 
(Hook and its internals in Elektrim. Looks like 4PDT to me.)
 


 
(schematics of RWT Elektrim, can be found inside the case... good old times :) )

A hook has one more purpose. It is used to disable the phone's bell as soon as the receiver gets picked up. Which brings us to the ringing mechanics. The whole idea of making phone ringing is to add a bell between line wires. If the exchange sends some AC in addition to 48V, it can run a coil-based bell without any problem... except a coil being a simple short for DC. Placing just a coil between line wires would short them and signal the phone being constantly off-hook (busy) to the exchange. Yet, we have this clever device to pass through an AC and completely stop any DC in the same time... a capacitor. I hope I don't need to say all this needs to happen before the hook to make ringing possible in on-hook state.

To sum up, when the receiver is picked, bell-capacitor circuitry gets bypassed using 100-ohm resistor, current is drawn from the line to signal off-hook state to the exchange and audio circuitry gets connected to the line using a transformer.

One final piece of this puzzle i a mechanism for dialing a number. For vintage phones dialing is possible only in off-hook state. It means any dialing circuitry needs to be located after the hook. Here the legendary phone dial kicks in.

An old signalling standard for dialing a single digit is simply to disconnect from landline (to stop drawing current) as many times as the digit indicates. Except of 0, obviously, for which 10 such "pulses" should be produced. Pulsing should occur at precise frequency of 10 Hz +/-0.5 (although https://en.wikipedia.org/wiki/Rotary_dial suggests even more liberal constraints). I found no information about duty cycle requirement. Also it's worth noting that some scandinavian countries and New Zealand used to use reverse system: 1 = 9 pulses, 2 = 8 pulses, etc.

Fixing frequency of pulse-generation is typically implemented using purely mechanical means. For instance, in CB-664, a 10 Hz pulsing frequency is achieved via mechanical centrifugal brake regulator.

(Mechanics at the back of RWT's dial. Regulator is in bottom right.)



(Mechanics of another dial I own. Also, large black wheel at the top is the regulator.)

Studying internals of a dial leads to another conclusion. To produce clear pulses, it is important to mute audio circuitry while pulsing. This is done by dial shorting the audio circuitry for the whole period of pulsing a single digit.
 
I believe the time limit between digits is something about 5 secs.

It is finally worth mentioning, that there is no techncal difference between pulsing using a dial and putting receiver back on hook. So if you'd be able to activate hook by hand at fixed frequency of 10 times a second, you'd be able to dial a number, even if the dial itself would be deactivated for some reason. This is indeed an idea behind mechanism of phreaking (https://en.wikipedia.org/wiki/Phreaking).

DTMF

Dialing by pulsing is an obsolete mechanism. Only some of public phone operators still support it. Also I've been able to test it on some VoIP adapters with varying results: Grandstream GXW-4024 (ca. 2012) still supports it, but has extremely strict requirements for pulsing frequency. Cisco SPA8000 and PAP2T do not seem to support it at all.

Pulse dialing got replaced by DTMF. Popularisation of integrated circuits eased the development and production of phones able to produce in-audio short bursts of certain fixed frequency (a tone). Moreover, as audio channel in analog telephony has relatively narrow band (just enough to transmit human voice), it may be desirable to combine two orthogonal frequencies during burst. This is exactly how DTMF works. It stands for Dual-tone Multi-Frequency signalling. Any digit being dialed has unique combination of two frequencies assigned to it. Dialing it produces short burst of in-audio tone transmitted further to the exchange. Obviously this method is much more simple to implement when the phone has a keypad instead of a dial. Nevertherless DTMF has became a de-facto standard for dialing in analog telephony.
 
 
(RWT Cyklamen 02, a keypad prototype based on RWT Elektrim, http://telesfor.org/telefony-modele/pozostale/)

You can find frequency assignments for each key of keypad on Wikipedia: https://en.wikipedia.org/wiki/DTMF.

Rotatone and rotarydial projects

My Elektrim was produced in 1971. Despite DTMF being dated back to 1963, I'm pretty sure in 1971 noone in Poland even heard of it.

With fading support for pulse dialing at the operator level, there are certain projects to incorporate DTMF into dial-based phones. First one worth mentioning is the Rotatone (https://oldphoneworks.com/products/rotatone-pulse-to-tone-converter): cheap, small, yet commercial device used to convert pulses produced by dial to DTMF tones. In addition to standard 10-digit functionality, it supports dialing hash (#) and asterisk(*), and allows to use phonebook of some (5 - as far as I remember) frequently dialed numbers. Available both in form of in-phone device and an external "filter" mounted on phone cable, this feature-rich solution would be ideal except for one additional requirement I have.
 
 
 
 
 

 
An open-source alternative to Rotatone has been refined from some projects generally available on the internet by Matthew Millman (https://www.mattmillman.com/projects/building-your-own-pulse-to-tone-converter/). While a bit less feature-rich, it is extremely simple, and due to its openness, can be made part of a more complicated device. This is want we want!

Details of Matthew Millman's rotarydial project

Matthew's pulse-to-tone converter (let's call it "rotarydial" for short) is based on jellybean Atmel's ATtiny85V microcontroller. Guess what! Even Atmel predicted its use for generating DTMF tones. There's an Application Note describing how to generate DTMFs using 85V's PWM module. And while in-dial contacts can be used to short some microcontroller inputs to ground (no need to use pull-up resistors; 85V has its own in it!), all we need is a way to tap into the line. Here is where rotarydial gets clever. In order to impose DTMF on the line, it kind-of shorts it via itself. Using one of its outputs and a 680-ohm resistor (in order not to exceed limit of ca. 15 mA above which output gets fried) it passes some current from the positive wire to the negative. If the output changes its state at certain frequency, it makes a great way to produce a frequency on line.
 

There are two things to consider when using microcontroller powered from the phone line.

First of all, power supply of 85V cannot exceed 5V. This is ensured by L78L05 linear voltage regulator. Yet, even L78L05 has its upper limit for input voltage. At this moment, we need to return to the "current yield" of phone line. While idle line offers 48V DC, we need our microcontroller to work only in off-hook state, when the line is shorted by 100-ohm resistor. This reduces 48V to something more like 6-8V which L78L05 can accept directly. And in case of an overwoltage (hook malfunctioning, etc), a Zener diode with breakdown at 27V protects the whole circuit (L78L05 in particular, as it can accept at most 30V). Since off-hook line voltage is far below the Zener breakdown, a Zener diode should not affect audio in any way. Since it is connected to the line only in off-hook state, it also does not influence on-hook ringing.
 
 

My extension to rotarydial

So... what is rotarydial missing?

First of all, as far as I know, rotarydial has been developed to be used in UK. British Telecom uses a special, "polarized" phone socket and plug system, that does not require you to care about which wire of the line is positive and which is negative. On the other hand, an analog phone, as shown above, does not care about polarity. Yet, the microcontroller does!

So first thing we would need in order to adapt rotarydial to polish RWT Elektrim, that uses symmetric plug by default is to ensure rotarydial always get positive supply voltage. Easiest way to do this is to "rectify" a line using literally any Graetz bridge. And since we're dealing with rather low voltages (every diode has a forward voltage drop!), it is even better to build one yourself. All you need is 4 silicon diodes with forward drop of your choice (the lower, the better).
 
 

 
(Ancient polish telephone plug (bakelite). As found in Elektrim.)


The other requirement is derived from an intention of modified phone being practical "to the extend permitted by applicable law". In most contemporary analog phones you can still find a P-T switch, used to choose between pulse and tone dialing. How about adding this thing to Elektrim?

P-T switch and WC relay coil triggering model

Obviously, for a phone dial that has 3 leads, the first choice to route them either to phone directly or to rotarydial would be to install a manual switch.

This very basic approach has 2 signifficant drawbacks:
  1. A switch that can route 3 signals to one of 2 different destinations (3PDT) would generally be massive. And, indeed, I wasn't able to find anything small enough to conveniently install it on Elektrim's case. RWT Elektrim has been designed as if DTMF never existed. Obviously it has no P-T switch and even no suilatble place on the case to install one.
  2. If you look closely at the schematics of a phone dial, you can see that it has two contacts: one between common lead and "mute", and one between common lead and "pulse". The thing is that when phone is not dialing, the first contact is NO, and the second is NC. State of contacts only changes while dialing a single digit ("mute" closed for the whole time, "pulse" producing "open" pulses). In order for rotarydial to work, "pulse"-"common" should be closed permanently on the phone side, when the the rotarydial is selected via P-T switch. We are dangerously close to requiring 4PDT.
(Example of 3PDT switch and its dimensions)

So if a single mechanical switch is not the case, lets look at a group of switches that we can somehow synchronize.

Just by coincidence, I have some of NEC/KEMET EC2 telecommunications bistable relays with coil rated for 3.3V. A bistable relay of this type has two coils: one requires short pulse of current to "set" the relay, i.e. to connect common lead to one output, and another, when activated by the same type of pulse, "resets" the relay, that is, connects common lead to another output. Each EC2 has two channels.
 
 (EC2-3TNU relay case)
 

(EC2-3TNU relay schematics)

Now, imagine combining 2 EC2s by connecting their "set" coils in serial and connection their "reset" coils in the same manner. Looks like we've just invented electrically driven 4PDT switch. Yeah, electrically...
 
(Coils of 2 EC2s connected in series to construct 4PDT switch)

Using realys (even bistable ones) in current-constrained environment poses quite a challenge. First one is to minimize current that holds relay's moving contact in place. Obviously bistable relays have their holding current of 0 mA in both "set" and "reset" state (hence "bistable"). You only need to produce a pulse long enough for relay to switch to the opposite state. In order to produce a pulse, that is to cut off the coil current as soon as the relay finishes switching, it would be nice to use some kind of feedback loop. How about one of four available switches cutting off a current to the coil as soon as the relay changes state?
 
(Feedback loop. First switch is part of relay 1, now in "set" position, just about to switch. Second switch is external, manually driven.)

While this setup reduces our switching abilities from 4PDT to 3PDT, it has a nice feature of consuming current only when it is absolutely needed.

Sadly, relay does not switch instntaneously. In our setup, current to the coil is cut as soon as the switching (moving) part inside the relay starts moving. For coil voltage of 3.3V, this part often is unable to gain enough momentum to reach the other end. The relay may, in this case begin to oscillate or, even worse, have its moving part stuck somewhere in the middle between contacts.

So... have you ever flushed your WC? I bet you have! What if we'd have some kind of reservoir, a buffer of an energy to sustain the movement of the relay's moving part after the supply of current has been cut by feedback loop (i.e. after the moving part started to move)? We can achieve that by charging some large capacitor in advance, and making it discharge through the coils when switching is initiated. This is the whole idea of my solution.

Finally, to ensure capacitors are charged enough before initiating relay switching, lets discharge them through the thyristor, activated when the voltage on the capacitor pins is above breakdown voltage of 4v3 Zener diode.

Additional 2 diodes to prevent effects of EMF backfire at the relay coils, and we're done.
 
(Pulse Tone Rotary Dial full schematics)

Wiring it all together

One more thing. With nice, electrically driven 3PDT built on top of 2 EC2 relays, we need one more channel to short "pulse" and "common" phone terminals when rotarydial ("T" mode) is selected. This we could achieve at the level of physical switch that drives the state change of relays. We could use DPDT instead of SPDT with one channel driving the relays and another shoritng "pulse" and "common" when required. And small-size DPDTs is one thing we can find!
 
(PCB project and production simulation)
 
 
(Breakout board version of Pulse Tone Rotary Dial)


Rotarydial author suggests to install the device "after" the hook, so it does get activated only when required - when the receiver is picked up. Fortunately in case of Elektrim, we have a separate connector inside the phone that allows you to tap into the line just after the hook.
 
 
 (Tapping rotarydial into the phone line inside RWT Elektrim)

 
(Internal cable and receiver connectors of Elektrim.)

Further installation steps consist of connecting rotarydial to... rotary dial, connecting rotarydial to the connectors for the rotary dial on the phone side (to allow rotary dial to pass through pulses from dial to phone when in "pulse" mode) and connecting our infamous DPDT P-T switch.

And I think I've found the right place for it on the phone case.
 

Final steps

ATtiny85V needs to be programmed. HEX file with firmware, as well as the source code can be downloaded directly from the rotarydial's website. As for the programmer, I'm a proud owner of AVR Dragon, but I'm pretty sure any SPI programmer will do (PonyProg?).

When designing PCB, my intention was to make it look as similar to the other PCB in the phone as possible. It turned out rather difficult to achieve due to size constraints and complication level of the circuitry. Yet, the final product is still a single-side board. Due to minimum trace spacing of 6 mil (!) I would not recommend etching your own PCB at home. Mine was produced by PCBWay.
 
 
 

(Real PCBs turned out pretty nice)
 
(Assembling the device)
 


(Some pictures of Rotarydial mounted onto Elektrim
 

Taking a step back. Revision B.

"Never design for production" , my colegue says.

 Does the device work? Of course not :/ And if you looked closely at the scehmatics, you are already screaming at me.

Further investigation using multimeter revealed that:

1. I'm literally unable to design simple Graetz bridge! I am a genius... I know!

2. I've used wrong packages for thyristors. While symbol seems OK, MCR-100s in the board have anode and cathode swapped!

3. Polarity of "set" coils of K2 and K3 is reversed. It seems that when this happens, relay cannot be set at all!

4. In order to design the board, I've used a footprtint for similar relay, Panasonic TX2-L2. While dimensions are 100% compatible with EC2, the pin layout differs. Coils in TX2-L2 are placed along longer edge! Fortunately, there is a TX2-LT, which matches EC2 in both footprint and pin setup. And it requires very minor changes to TX2-L2 already available in EAGLE6.

(Pin setup of Panasonic TX2-L2 and TX2-LT. The latter one is compatible with NEC EC2-3TNU)

Problems 1. and 2. can be solved by simply resoldering components. Sadly this means inconsistency between silkscreen and real components placement. I think we can live with that.

Problems 3. and 4. can be solved by trace cutting and some KYNAR. Again, this would have been an easy fix if only I hadn't glued those large capacitors to the PCB earlier using glue gun :(. Yet, I've succeeded, and after applying all the fixes, the device works like a charm.

(Finally: the proper DEMO. Sadly DTMF tones are nearly inaudible.)
 
I'm not going to assemble another one using corrected PCB, because I've already got what I wanted - a working Elektrim able to produce DTMF tones. All I can do is to publish the fixes. So here you have revision B schematics and board of Pulse Tone rotarydial.


(Pulse Tone rotarydial rev. B's full schematics, PCB design, and PCB production simulation)

Downloads


Komentarze

Popularne posty