skagmo.com – Analog phone trade
Motivation
A number of years in the past, an analog cellphone trade would most likely be one of many final issues I assumed I’d construct.
Nonetheless, final yr I made a decision to dig into the previous POTS (Plain Outdated Phone Service) customary, search Finn (the norwegian equal to Craigslist) for previous telephones and begin designing a cellphone trade.
Why on earth would I do that?
- I like working with previous communication protocols and requirements. Think about studying a nicely outlined customary from a yellow stained paper written within the 1970’s, when you are writing firmware for a contemporary MCU.
- My daughter is admittedly into toy telephones, so what would not be cooler than mounting a correct cellphone in her room and enabling her to name us and her grand mother and father?
- We have now an unused CAT6 cable between our home and my mother and father home, in addition to a number of CAT6 wiring in our (fairly new) home, so all of the cables are already in place.
Here is a demo of the completed cellphone trade:
{Hardware} structure
The primary questions that got here to my thoughts was how old-fashioned this was going to be:
- Would I exploit relays or semiconductors for the switching matrix? I do love the sound of clicking relays, however I ended up with strong state analog MUXes which saves a number of PCB space.
- Would I exploit devoted analog circuits just like the previous MT8870 DTMF decoder? No, I made a decision this was an excellent alternative to do some DSP in firmware and in addition save PCB space through the use of the ADC within the MCU and write the DTMF decoder in firmware.
In different phrases, I’ve made some trendy twists to an in any other case previous design.
One other vital design choice was to have line interfaces as separate PCBs, each to have the ability to use completely different sorts of bodily interfaces (resembling wired POTS, wi-fi and so forth.), and since the mainboard in any other case could be very giant and full of comparable circuitry. If I have been to make one other revision of the principle board, I may merely plug the interface boards into the brand new principal board.
I additionally use 100 mil pitch edge card connectors as a result of they offer me a heat fuzzy retro feeling 😉 (And naturally it saves me the trouble of not having to solder a connector.)
That is how the structure ended up:
Predominant board
The guts of the principle board is a PIC32MX575F512H microcontroller.
This does actually all of the heavy lifting.
- 4 ADCs are related to the 4 audio buses to have the ability to decode DTMF in firmware and report audio (voice mail and so forth.)
- 2 PWM modules are filtered with a 3rd order lively low cross filter to work as DACs, feeding audio bus 1 and a couple of to supply ring tone, play again audio and so forth.
- It controls an H-bridge with a look-up desk to create an ideal 25 Hz sine ringer voltage
- UART and CAN bus is uncovered on connectors. UART is used to log occasions and debug, CAN bus is used to attach the cellphone trade to my CAN primarily based house automation system. It could have the ability to set off occasions when dialing sure numbers, make telephones ring from House Assistant and so forth.
Producing ringing voltage is finished in steps proven within the footage:
- Generate the PWM and path sign from the MCU, utilizing a sine LUT and a PWM peripheral
- Output from H-bridge
- LC-filtered sign (low voltage 25 Hz sine)
- Output from transformer (excessive voltage sine)
POTS line interface board
The road interface board holds all of the circuitry required to interface a single POTS cellphone to the principle board:
- RJ11 connector
- DPDT relay to toggle between 24 VDC bias + audio sign OR the 90 VAC ringer voltage
- Optocoupler circuit to detect the off-hook present
- Analog MUX to attach the road to one of many 4 audio buses
- Safety circuitry
Strictly talking, telephones ought to have bias voltage on a regular basis, even when ringing. Nonetheless, it simplifies the design quite a bit to make use of a DPDT relay to both join the ringer voltage (and no bias), or the bias voltage/MUX. This eliminates the necessity for a giant inductor or gyrator to dam the AC ringer voltage.
I really applied each strategies, however ended up utilizing the strategy with no bias throughout ringing for it is simplicity.
Nonetheless, there’s one caveat. To detect when a cellphone goes off-hook, you detect a rise in bias present. If the cellphone rings and there’s no bias voltage, you could not detect that the cellphone is off hook.
The best way I solved this was to watch the H-bridge present for the ringer circuit utilizing an ADC on the MCU. If the ringer present rises above a threshold, the cellphone could be thought of off hook and the ringer stops instantly.
Autopatch board
The autopatch board permits dialing into the cellphone trade from a handheld radio, or answering incoming calls on the hand held radio.
I made a decision to make use of a easy FM “walkie talkie” transceiver module for this function.
I first tried SA818, however turned out to be utterly unsuitable because of a big TX delay. It took nearly a full second from enabling the PTT line till the TX audio turned undistorted. Appears like a coupling capacitor within the AF path charging as much as a sure bias stage very slowly.
Second attempt was the RDA1846S module (link here). It is a lot higher and has solely milliseconds of delay earlier than TX is at full energy and undistorted.
Firmware architeture
The firmware was written in naked steel C, though in an “object oriented method” with a context/deal with for every of the cellphone strains.
DTMF decoding is finished with the Goertzel algorithm, matched for every of the 8 completely different frequencies used for DTMF. 4 situations runs in parallell to have the ability to decode DTMF continously on all 4 audio buses.
There’s a huge state machine dealing with all cellphone states, callbacks for occasions like off-hook, new DTMF knowledge and so forth.
Assembling all of it togheter
Right here is the entire meeting with a CNC routed aluminium entrance plate for subrack mounting, toroidal transformer, principal board and all interface boards.
Everlasting mounting
I mounted the cellphone trade in my “house lab” rack along with my networking and residential automation tools.
It’s powered from a 2.5 kWh 37 V (10S) battery pack constituted of Nissan Leaf battery modules. This powers my principal UPS, however relatively than utilizing the UPS to go from 37 VDC -> 230 VAC -> 24 VDC I exploit a DC/DC converter to go on to 24 VDC. Which means in an influence outage I will use the cellphone trade for months after the UPS has turned off. Not that I’d ever want it 😉
Organising a personal cellphone community
I mounted a Diamond X-30 antenna on the roof for the autopatch, which can give me loads of vary once I’m cross nation snowboarding or mountaineering in a close-by mountain and have to dial house for some purpose. My daughters room was upgraded with a cellphone mounted subsequent to the mattress, and the final picture reveals the underground cable from our home to my mother and father home.
It has been giving us and our daughter a number of enjoyable, and has additionally proved to be actually helpful.