Good-old rotary dial phones have been around since forever, and they used to be a part of everyday life, like dragons during medieval period. However, like dragons, suddenly all these marvelous ancient devices just disappeared one day. I was lucky to find one of these dinosaurs at the local flea market.
I was eager to try it out, but unfortunately I don't have a home phone line anymore. I hooked it up to my Voice Over IP (VoIP) adapter that I haven't used in years. It almost worked! Well, it rang like it is supposed to - waking up dogs and babies in a two block radius. I could even have a pleasant conversation over it, but I couldn't dial out. I heard a dial tone, but it ignored the number I was trying to dial.
The problem actually was not the phone - there is nothing could go wrong with it, ever. It's probably bullet-proof and could easily survive a minor nuclear apocalypse (haven't tried it, it is in my to-do list). The problem was in my Voice Over IP adapter. It's not compatible with "ancient" rotary-dial phones, and is designed to work only with (well, also vintage) push-button phones.
Ironically, rotary dial (or pulse-dial) is actually digital protocol, and is supposed to be closer relative to VoIP than "modern" push-buttons phones. The later ones use analog encoding to transmit digits. This process has a fancy name: Dual-Tone Multi-Frequency Signaling (DTMF).
The rotary dial is pure digital - transmitting numbers as a sequence of on/off pulses. One pulse corresponds to digit "1", two pulses - digit "2", etc; Ten pulses represent digit "0".
Of course I could get another VoIP adapter that supports pulse dialing, but this would be too easy. Instead, I decided to make my own pulse-to-DTMF converter.
I had a few microcontrollers lying around and decided using them to generate DTMF signals should be trivial. Obviously, it's been done before and I found an Atmel application note to do exactly that. There is nothing special there, just using a PWM (the same method I used to play audio on the TI Launchpad) to generate an analog signal. The only difference is that I am not using any external memory here. DTMF consists of just two sinusoidal waves, so we have to store one period of the sin wave and it is small enough to easily fit to the microcontroller's internal memory.
As I mentioned before, reading pulses from the phone is very simple. It's already digital, just count them up - and bam you get your digit. Here is a test setup with my adapter still on the breadboard
From left to right:
- Wi-Fi to Ethernet converter. Just because my VoIP adapter doesn't have a Wi-Fi and I don't like having Ethernet cables everywhere
- VoIP adapter. I had the old Cisco/Linksys PAP2
- Phone (kinda obvious)
- Breadboard. Schematic below:
The phone line voltage is in the "on-hook" state. Confusing term? It seems to have originated because you are supposed to keep the earpiece on the hook and "off-hook" it in order to answer the call.
Back to the voltage. So the "on-hook" voltage is quite high, around 48V DC and even higher (around 90V AC) during the ring. I decided to connect my board after the phone switch, so I am getting the power only when the phone is in the "off-hook" state (meaning the handset is not on the phone).
In the "off-hook" state, line voltage is supposed to drop down to around 5V DC, which is perfect for my AVR, but I still added a 5.1V zener diode D1 just in case.
The rotary dial module is disconnected from the phone circuit and connected to my adapter only. The purpose of the connection between pins F and RR is to make phone think that the dial is still connected.
I am generating DTMF/PWM signal on the AVR pin 5 and feeding it to the emitter follower Q1 via the low-pass filter (C1, R3).
If you are curious, you can grab an AVR source code here.
Here is the video testing the adapter
During the test I ran into the interesting issue. I noticed that AVR power consumption at the power-down mode is much higher than I anticipated (~500uA instead of ~10uA). After poking around I traced the issue to the debugWIRE interface. I was using debugWIRE to download and debug code on the AVR. Yet apparently debugWIRE draws a lot of current (~500uA). Disabling debugWIRE via fuses and using ISP instead solved the problem.
The last steps were to wire the adapter on the perforated board.
Then mount it inside the phone (thank you again, hot glue)
Done! Just put the cover on. Obviously it looks exactly the same as before modifications.
Next steps. I guess there is none. Well, maybe to record how this phone rings and use it as a ringtone.
Contact us to get started on your next Embedded Development & Programming project.