$10 ATA Part 3 – Hybrid

This project has been asleep since 2007 when I published Part 1 and Part 2 of the $10 ATA series. However for a couple of reasons I was inspired at lca.conf.au 2011 to go back to work. So for the past few weeks I have been working on this project for a few hours each day, and have been making steady progress. I now have a really low cost prototype “hybrid” (2 to 4 wire converter) circuit running, which uses an Arduino as the “sound blaster” for audio I/O.

hyrbid prototype

This project is useful the following reasons:

  • A way to lower the Bill of Materials (BOM) cost and hence sales price for the Mesh Potato. This means more poor people get telephones.
  • It makes the Mesh Potato design more portable to other Wifi System on a Chips (SoC), i.e. any router with a serial console port (pretty much all of them) can be converted into a Mesh Potato. This allows us to migrate the Mesh Potato design to lower cost or more modern (802.11n) SoCs, “future proofing” the design.
  • I am intrigued by the idea of recycling old OpenWRT-capable routers into useful mesh telephony devices. More on that below.
  • It’s a stepping stone to some other low cost Wifi router + micro-controller projects I would like to see happen, like the Louder Router, small automated AM/FM radio transmitters for villages, and HF Mesh Radio.
  • I want to know if it can be done. Geeky curiosity. Can we really build a FXS port with a few $ of analog components and a micro-controller?
  • I kicked off the idea 4 years ago so I feel committed to finishing it. One day.

The Mesh Potato project absorbed a lot of the ideas I originally had for the $10 ATA. For example using RS232 serial for SoCs that don’t have a TDM or USB port, and signal processing (echo cancellation, DTMF detection) on low end router CPUs. One nice outcome is that we now have many of the software components, e.g. a low latency serial port kernel mode device driver, an Asterisk channel driver, and user mode echo cancellation. On the Mesh Potato project I gained a lot of experience with the approach of using RS232 serial for PCM audio, so we know it can be done.

RS232 Serial or USB?

Although a bit “old school”, I like the idea of using RS232 between the micro-controller and the host router. The reasons were discussed in some detail in the Part 1 $10 ATA blog post. One big advantage is every OpenWRT capable router has a serial port. This makes it possible to turn any router into a Mesh Potato. In particular we know how to use a router’s serial port without SoC vendor support (e.g. detailed data sheets). Vendor support for the AR2317 SoC was a big problem with the Mesh Potato – the full data pack and support package for this chip costs $100,000 which we just couldn’t afford. So sticking to SoC peripherals like RS232 serial ports that are well understood can make life a lot easier.

However USB is also a great idea. Angelos Varvitsiotis was inspired by the $10 ATA idea to develop his very cool Open USB FXS dongle. This uses a Silicon labs chip set for the FXS port, and a PIC microcontroller with internal USB support for the interface to the host PC. Angelos has worked hard on this design for some time and it has recently been featured in Elektor magazine. A neat output of this project is a micro-controller based USB back end for FXS ports (USB drivers, Asterisk drivers etc).

To access the RS232 on OpenWRT routers you need to open them up. However modern routers have external USB, and USB can also be used to connect with any PC.

So it’s possible to take the low cost FXS circuits based I am developing here and fit them to either a RS232 serial or USB back end. I’ll be starting with RS232 as that’s what I am interested in, but I also look forward to seeing a USB version developed (maybe by some one else) one day.

Telephone Hybrid Requirements

As discussed in Part 1, telephones have a DC path (loop current), and an AC audio signal path for transmit and receive audio. All on the same pair of wires. The hybrid works with the AC audio signals. Some of the functions are:

  1. Take unbalanced (signal plus ground) transmit audio from a DAC and send it down the telephone line to the telephone. The transmit signal must be balanced, so when one side of the pair goes up to V volts, the other must go down to -V.
  2. Extract the balanced receive signal from the telephone line and convert to an unbalanced signal ready for ADC conversion.
  3. Two to four wire conversion. This needs a little explanation. In analog telephony the transmit and receive signals are both present on the same pair of wires. So the receive circuit must try to separate them and recover just the receive signal alone. This is done by subtracting the transmit signal and sending what’s left to the ADC. Separating the combined transmit plus receive signals into separate signals is known as two to four wire conversion. This separation is never perfect, so you always get a little transmit audio in your receive audio. That’s where echo cancellation comes in. As long as the hybrid can make a good attempt at separating the signals the echo canceller can take it from there, removing the remaining transmit signal. So 6-12dB suppression of the transmit signal in the receive audio is usually good enough.

This figure illustrates the hybrid in action. It’s from an earlier series of posts I wrote on echo cancellation.

Open Hardware to the Rescue

I am a weak in analog design. However over the past few years a couple of very nice guys have sent me circuits for low cost SLIC (FXS port) designs. This was just what I needed, some people who know more about analog design that me to step in and give me a few tips. This is one of the great things about Open Hardware – you meet all sorts of really smart people who have the skills and motivation to help. One great side effect is learning about analog design from guys much cleverer than me. Just like I can learn about software by looking at open source code.

I have used a circuit sent to me by Ken Boak, which was developed by Ken and Radu Constantinescu. I have also received another design from Manoj Desai, thanks Manoj. Details of Manoj’s design are in the “Open FXS & SLIC Designs” section of my Open Hardware page. Either design would have been fine for this project, I just happened to try Ken’s design first. Thanks Ken for kindly answering my many questions via email.

How the $10 ATA Hybrid works

Here is a PDF of the current hybrid circuit.

Gyrator 1 and 2 are like electronic inductors. They block any AC signals (like phone audio). The operation of the Gyrators was described here. A useful side effect is biasing each side of the telephone a few volts away from AGND and VBATT. This means the balanced audio voltages to and from the phone stay a few volts away from the AGND and VBATT rails. In the previous $10 ATA design, I didn’t have Gyrator 2, this side of the phone was just grounded. So this version was unbalanced and susceptible to picking up hum, plus half the signal would be lost as one side wasn’t being driven.

During transmission onto the telephone line U1C and U1D drive the line differentially. C6 and C7 decouple us from the negative DC voltage developed across the telephone handset.

The 560 ohm resistor R13 sets the transmit and receive line impedance (nominally 600 ohms). During receive the telephone sends balanced audio to our hybrid via C6 and C7. The low impedance output of U1D means the voltage on pin 14 will not change in response to AC signals, it is like an AC ground. So due to the C6/C7 capacitive coupling the entire audio signal from the telephone will be developed across R13. So the AC equivalent circuit is like this:

receive equivalent circuit

Zl is the impedance of the phone (roughly 600 ohms, but in some countries there is a reactive component as well), and Vl is the AC voltage the phone is sending. There is a detailed explanation of the telephone model in the Part 1 blog post.

A difference amplifier (U1A) is used to perform 2 to 4 wire conversion. It subtracts the line voltage across R13 from the transmit signal to give us the single ended receive signal that is sent to the micro-controller ADC. R19 and R20 form a voltage divider that samples the balanced transmit output. Another voltage divider is formed by R13 and the telephone’s AC impedance, Zl.

D3 and D4 provide some protection for large input signals, for example 20Hz ringing at 100 volts peak-peak.

When I built this circuit I experienced AM radio break through. I could listen to the news about the February 2011 Egyptian demonstrations quite clearly on the telephone handset. This stumped me for a few days. Adding small capacitors to the input nodes of the circuit had no effect. I even rebuilt the circuit “dead bug” style on a piece of PCB to give better grounding. Eventually, more through luck than engineering, I found that adding C14 and C15 removed the AM radio pick up. I guess the phone lines were picking up strong local radio stations that were being demodulated (“detected”) by p-n junctions inside the op-amp. After describing this to Ken he also suggested series RF chokes in the wires leading to the phone connector .

Audio Record and Playback with an Arduino

Now that we have four wire transmit and receive audio I needed a way to sample the signals. So over a few days I wrote this uart2analog Arduino program. Actually it’s standard C code, not an Arduino project. I wanted to use Arduino hardware (they are ubiquitous now), but not the Arduino GUI. This project pushes the capability of the Atmel microcontroller so we need to get close to the bare metal. There is a Makefile to take care of compiling and download instructions are in the project README.

I am used an Arduino Duemilanova which sports an ATMEGA368P. Trivia – Duemilanova means 2009 in Italian, thanks Rosemary for the translation!

The uart2analog program takes RS232 samples from a Host PC and “plays” them out the PWM port. It simultaneously samples using the ADC and sends the samples to the Host PC via RS232 serial. There is some crude averaging to handle sample rate conversion. Combined with the hybrid circuit it actually works quite well, here is some recorded audio. This is another sample recorded while simultaneously playing the previous sample, to demonstrate full duplex audio. You can hear the effect of the hybrid suppressing the “played” (transmit) signal, only a little bit of it comes back as echo. I can also hear some effects of the coarse (8 bit) quantisation.

Eight bit linear sampling is unlikely to sound as good as a custom FXS chip set (like the Silicon Labs chip set we use for the Mesh Potato). The current hardware layout is rough, with long unshielded analog lines and poor power supply filtering on the ADC. A proper PCB should help that. But it’s a good start, and should improve with some hardware and software tweaks. In Part 2 I recorded this sample, using different software and hardware. This sample sounds cleaner to my ears, with a better high frequency response. I’ll need to track down the differences in these two samples some day. But it’s actually it’s quite amazing how good 8 bit linear audio can sound. Good enough for my purposes, anyway (developing world telephony).

I used a x86 laptop as the host, and a user mode host program to record and play samples to/from disk files. User mode PC programs suffer from big delays (10’s of ms) between Serial I/O system calls as the PC swaps between tasks. This means the RS232 output from the PC will be bursty. It sends nothing, then a big burst every several 10’s of ms. So I found that a large FIFO buffer was required on the Arduino program (1800 bytes) to get good quality audio with no gaps through RS232 serial. This is almost all of the micro-controllers 2k RAM.

For real world VOIP use we need to hack the kernel mode serial driver to have low latency response to serial port activity. This is also necessary to get a constant, known delay between the transmit and receive sample stream, a requirement for echo cancellation. Anyway, I did all that for the Mesh Potato so it will be straight forward for the $10 ATA. In the mean time the user mode host sampling code is OK for basic testing, and lets me focus on the hardware rather than recompiling kernels and developing on embedded boxes.

The ATMEGA368P chip I am using can do 10 bit PWM and ADC, we could use this if we implement mu-law companding on the micro-controller with look-up tables or some C code.

Open Hardware and Local Manufacture

One key feature of the $10 ATA is the use of easy to find, “garden variety” analog components. With the exception of the micro-controller they could even be recycled from e-waste. No special chip sets, no surface mount.

A cool project for your hacker-space might be recycling old routers into Mesh Potatoes, then using them for local free telephone networks or shipping boxes of them to developing countries to build mesh telephony networks. Some more details on this idea at the bottom of the lca.conf.au 2011 post.

servicing on the street in Dili

I would also like to try building $10 ATAs in developing countries. This is a meme of Open Hardware that I have dreamed about for years but never tried until now. In the Dili Village Telco project there was some local assembly of the Mesh Potatoes (drilling boxes, soldering cables), and the Timorese guys absolutely loved it. So I think their is a big appetite for local assembly in the developing world. Recycling e-waste, low end user cost, and local manufacture could be very empowering compared to importing expensive 1st world goods. I have this vision of people in developing countries recovering analog components from old TV sets, CFL Light bulbs and PCs, then hacking old routers into Mesh Potatoes, or maybe other useful devices.

Remaining Tasks

  1. Design a micro-controller based DC-DC converter that can supply -24 to -48V VBATT and ringing voltages. I made some progress on that in Part 2, but there is still a lot of work to do. I am intimidated by control system design so need to think about this some more. Last time I worked on this I blew up my micro-controller by putting -100V into an ADC input! So I might pay a little more attention to protecting inputs this time around….
  2. On and off hook detection hardware and micro-controller logic. Detecting off hook during ringing can be tricky.
  3. Develop a way to send hook detection and ringing commands thru RS232 serial, multiplexed with voice data. This will save some GPIOs, and the bandwidth is trivial, a few bits/s.
  4. Develop OpenWRT patches for common routers that include the low latency serial driver, chan_mp channel driver and Asterisk, Batman, and config files.
  5. Design a full schematic and PCB for the $10 ATA, including the micro-controller. For the PCB design we need to pay attention to good analog layout, like single point grounding, and isolation of hybrid and DC-DC converter sections.
  6. Organise some trial workshops in developed or developing countries to try building some $10 ATAs and fitting them to routers. To support this maybe publish a Wiki with debugging and step by step testing information.


  1. $10 ATA Part 1
  2. $10 ATA Part 2
  3. $10 ATA SVN, circuits, source code, Makefiles, simulations, notes on downloading to Arduinos.

  4. Project Google Group Mailing List which has been dead for years. I’ll answer questions on it or via comments on this blog post.
  5. Gyrator DC Characteristic
  6. How echo cancellers work

19 thoughts on “$10 ATA Part 3 – Hybrid”

  1. David,

    Some other things to throw into the mix.

    There’s a design for USB in firmware on the ATmega/AVR microcontrollers which might be useful:


    I recently added a SPI serial SRAM to the ATmega328 (Arduino) to give it a 32Kx8 buffer. I bit banged the port lines (so that the C code was generic and not reliant on on-chip SPI bus). This should be fast enough to cope with 8 bit audio. The idea could be extended to use larger SPI dataflash roms to allow voice prompts to be played out through the SLIC.

    Secondly, I did a poorman’s “etherduino” by grafting a Microchip ENC28J60 onto an ATmega328. This might be one way to get low cost ethernet from router to FXS interface.

    Perhaps you could release the micro/SLIC as a shield to fit onto an Arduino, so that more people can use it as a platform for development – this would spread the technology a little wider. “Arduino Phone-Shield” That would keep the hacker’s happy. Use the Arduino to do DTMF detection.

    My first 50V/100V inverter was reverse engineered from a battery powered fluorescent lamp. It took 6V input and with a single transistor and step up transformer made a self oscillating inverter that would strike and run a CFL tube. We used a 51V zener to detect when the output voltage was greater than 50V and killed the drive to the inverter. In this way we got burst-mode regulation with no need for microcontroller intervention. We found that when we loaded the inverter with an off-hook phone, that the voltage drooped to about 23 to 26V when it supplied around 25mA of line current.

    I’ve subsequently been experimenting with the Arduino to generate pwm for 50Hz sine wave synthesis for another inverter project. I achieved a 60Vpp sine wave from a 5V supply using a couple of 100V mosfets in a half bridge configuration with a 220uH inductor. This could be useful for generating real sinusoidal ringing signals when on-hook and 48v battery voltages with minimal arduino intervention when off-hook, because when off-hook the Arduino is pre-occupied with the audio processing. Tricky bit, I found was reliable off-hook detection both when in the midde of a ring, and in the quiet period between rings. I have some ideas how to simplify this.

    Good luck with the project


  2. Hi David,

    I really like the idea of integrating an ATA into existing router’s / AP’s – Have you looked at the devices from TP-Link – A Wireless N AP costing $40AU – Add in your $10 ATA and you have an amazing match. Would the guys at TP-Link be up for some R&D perhaps?

    Cheers, Joe

    1. Hi Joe,

      Does the TP-Link unit run OpenWRT? Some of the cheaper APs have smaller RTOSes and 2M flash.

  3. Most phones have an RJ11-4P4C jack for a handset, and it’s pretty much 4-wire interface there. Having microcontroller directly connected to both headset (for audio path) and line jack (for power/ringing/DTMF/on-off-hook signalling) could simplify design, while also improving audio quality.

  4. please forgive a not too technical type for butting in here, just have been trying desperately to get my hands on a device that could solve the second biggest obstacle to the perenial problem of communication in the developing world which after cost happens to be “power”, the mesh potato would have been the perfect answer but for the fact that it requires power 100% of the time. Could this ata be coupled with say a 900 MHZ (2.4 wifi would be a good 2nd choice) wifi radio in a mobile form factor? something akin to the DLINK DPH-540?, It may be a little early for this but I would be more than happy to facilitate and coordinate assembly in a developing country.
    You guys did a marvelous job with the Mesh Potato, many thanks, still have 2 beta units, on active duty.

    1. Osa – what sort of power do you have available? In Timor we have identified intermittent power as a big problem. What would be very useful is an integrated UPS, so the Mesh network can keep running when power is out for an hour or two. This just requires a simple charger and small lead acid or lithium battery, much cheaper than solar power.

  5. Locations with available grid infrastructure, usable power is present only 50 percent of the time, and can be unavailable for up to a week. We have tried overcoming this with various tactics one of the more extreme being to size battery power to support devices like the nanostations and bullets for up to 2 weeks of run time, but this in turn demands a charging system that can replenish used power within the short window that usable power is available, which in turn drives cost through the roof.

    Seventy five percent of our target locations simply have no grid power available, but there is usually a generator/inverter system available comercially to charge GSM handsets at locally affordable rates. Most households also have some form of generator available as well, run intermittently.

    I do have a few units of the Micro UPS board purchased for some other projects, I think I will try your sugesstion and see what battery configuration provides real-world usability. Perhaps one could even try fitting all the pieces into an old style telephone casing to produce something like the CDMA fixed-mobile sets. Do you have any idea this would affect the range of the MP?

    1. With 1 week power drop outs solar might be a better approach.

      I am interested in developing small scale solar chargers & MPP trackers. These could be included in the Mesh Potato, or be small add on products. A few $ for the electronics plus the battery and panel costs. The charger could also work as a battery backup when mains power is available but intermittent. The design would be open hardware and easy to assemble in developing countries.

      The Mesh Potato range is affected by line of site. Unless the range to the next node is trivial, you need to get it outside on a roof.

        1. Thanks Hadley that is interesting. The extra efficiency from the MPP wasn’t as high as I had thought. If the DC-DC converter is only 75% efficient it might wipe out the gains from MPP tracking. My target is a low power MPP regulator/charger for Wifi and Mesh Potato applications, some thing that could be made for a few $.

          1. True but 25% is still pretty important when you’re talking about small panels. The gains would also depend on the panel and cells you’re charging. Using MPPT would allow you to have more flexibility in the specs of the panel in relation to the target charging voltage.

          2. Yes, just not sure if that 75% will be lost in the DC-DC converter, e.g. the current design is only 76% efficient, which is fairly typical. It is possible to improve that by 10% by replacing the diode with another transistor. However I think it’s possible to implement MPP with identical hardware to a regular step-down DC-DC converter (0 extra hardware cost) so it’s worth trying. I will have a go at a small (20W) MPP/charger some time.

  6. As a Ham in a poor location for HF Im looking at setting up a Solar Powered HF remote site (friends bush block), your ATA project could be used in a 4 wire mode to allow audio linking of receive and transmit paths, with a 64K shaped 3G link. pair of ATAs in a peer to peer mode.
    Sounds like a interesting project the $10 ATA hope to see more development.
    Frank VK3ZFS

  7. Hello David,

    Every ADSL router have one RJ-11 so how about using it for FXO :) Most of them have 2MB flash chip so openwrt can not work, but – who dares wins!

  8. This is actually pretty nice! So it looks like you’re almost finishing your ATA?
    I’m very excited to see this project concluded; it would be awesome to be able to build my own for measly $10.

Comments are closed.