Audio to TTL Adapters – ElectroSchematics.com

I saw a request about how to interface an audio signal with a microcontroller for logic level switching. I started thinking a lot about it and found some quick fixes. This post has my ramblings about those fixes. I hope it will be helpful for beginners!

Electronic Audible Alarm

From home appliances and security devices to automotive electronics and healthcare devices, communicating information from a device to its end user through audio signals is a common necessity. The most common device used to generate sound from an incoming electrical signal is the buzzer which usually comes in two forms – electromagnetic buzzer (magnetic buzzer) and piezoelectric buzzer (piezo buzzer).

An electronic audible alarm produces an warning sound using electronic means. Piezoelectric type alarms utilize a piezoelectric transducer which consists of a metal disc that has a ceramic material bonded to it. When voltage is applied to the ceramic material, it causes the metal disc to physically flex. If the piezoelectric transducer is physically flexed at an appropriate frequency, the air pressure waves are produced that are heard as an audible sound.

At this point, it is worth noting that an “active” piezo buzzer has its own internal circuitry. So, the user only needs to apply an input voltage, and the alarm will instantly sound.

But a “passive” piezo buzzer does not contain any internal circuitry, so the user must supply the complex AC drive signal that will make the sounder diaphragm (transducer) flex at the appropriate rate and amplitude.

On the other hand, electro-magnetic type alarms utilize an electro-magnet and a nearby bare metal disc that is mounted to the housing. When the electro-magnet is energized, the resulting magnetic field physically deflects the bare metal disc. If the bare metal disc is flexed at an appropriate frequency, an audible sound is produced.

If you want to know more about how each type works, here you can find a pragmatic explanation https://www.cuidevices.com/product-spotlight/piezo-and-magnetic-buzzers

Audible Alarm Extension

As in the case of our reader, there may be situations where the alarm signal from an electronic device (a washing machine, for example) needs to be extended to build another external alert system. The easiest way to do this is to tap the audio signal from the device’s sounder terminals. This simple trick allows you to go forth without disturbing the delicate microcontroller located at the core of the device. If so, you do not need to gather the schematic and/or service manual of that device for your hack.

However, it requires a “translator” to make things smooth and secure. So, let me try to share one idea for building an “Audio to TTL” adapter to convert the audio signal input into a logic high/low signal output.

The circuit setup for this idea will be very simple. The only key component we will need is an AC Optocoupler H11AA1 (https://www.vishay.com/docs/83608/h11aa1.pdf), which we will hook directly to the sounder of the device. The only catch is that the sounder is driven by a tone (AC) signal which usually has a frequency in kHz range, and often the bidirectional signal has a peak-to-peak voltage (VPP) value much higher than the actual operating voltage of the microcontroller used in the device (For example 5V). We will examine this in detail later (something that is often unnoticed)!

Resistor R1 in this circuit is the current-limiter resistor for the optocoupler OC1 whereas resistor R2 is the optional pull-up resistor for the next microcontroller’s I/O pin (10K is a commonly used value). The typical forward voltage (VF) of H11AA1 is 1.2V at a forward current (IF) of 10mA. So, take this into account while calculating the value of R1 for your proposed application (Here, 1KΩ seems to be the highest value to start with – anyway dust down your calculator).

To test the above concept, I used the audio signal from a quartz alarm clock. It is a very old dysfunctional table clock engine, but its electronics are still active.

The optocoupler is used deliberately to isolate signals for protection and safety between a safe and an electrically noisy/dangerous environment. The bidirectional optocoupler incorporates an input circuit with two emitters connected in reverse parallel. This means that the regular optocoupler permits DC input only, while the bidirectional input type also permits AC input.

To make it more useful

I modified the basic circuit and hooked an extra bit of electronics to the output of the optocoupler since a little addition enables the setup to handle a repetitive tone input similar to the quartz alarm clock signal.

The below image shows the modified schematic. There is one interesting thing here: you will get two output lines – a logic high/low level voltage output (IC1’s Pin 3) and a logic high/low state open-collector output (IC1’s Pin 7). Furthermore, the add-on circuitry is simple and highly adaptable. Enjoy!

Note that, in a standard 5V TTL system, basically any voltage that is at least 2V will be read in as a logic high (1), and any input voltage that is below 0.8 V will be considered logic low (0) when read into the device (https://learn.sparkfun.com/tutorials/logic-levels/ttl-logic-levels).

You will notice that the above given setup can easily provide a logic high level voltage greater than the recommended minimum (2.7V), and a logic low level voltage well under the recommended maximum (0.4v). So far so good!

The Mighty Chirps!

Sometimes things in the real world can be very different than our quick notes on paper. Let me get to that story.

Since the alarm sound of my quartz clock engine, which I used to test my builds, sounded louder than usual, I hooked my oscilloscope probes to the sounder device (buzzer or transducer – name it as you like) in both directions. These are lazily captured oscillograms.

See, the peak-to-peak voltage (VPP) of the 1.5V operated 2kHz alarm circuit is around 6V!

The alarm sounder in my test device is a magnetic buzzer which is a current driven device (but the power source is typically a voltage). The current through the coil is determined by the applied voltage and the impedance of the coil. The magnetic transducer requires an excitation waveform to drive the buzzer. In principle, arbitrary wave shapes and a wide range of frequencies can be used for the excitation waveform.

At this point, note that you can increase the sound level of a magnetic buzzer by raising the peak-to-peak voltage applied across it. If you use an appropriate driver circuitry, the applied voltage is twice as large as the available supply voltage, which gives you about 6dB higher output audio power.

I will not go deeply into this now as my purpose is only to draw your attention to the mighty VPP value that often goes unnoticed.

Further reading https://www.cuidevices.com/blog/buzzer-basics-technologies-tones-and-driving-circuits

The Temporal End

In this project we simply translated an alarm signal into an isolated logic-level switching signal using a handful of easy to use and inexpensive electronic components. Sweet! Now that you have established a structure and a build scheme for your project, you can begin to piece it together. The convenient way to make your own compact Audio to TTL Adapter module will be to use a small piece of prototyping circuit board. Ultimately, now it is your turn to explore how to cycle a digital pin from HIGH to LOW or LOW to HIGH with different/strange audio signals. Get ready to get noticed. Good luck!

Leave a Comment