1
\$\begingroup\$

I am looking for guidance on audio functionality test over USB audio codec. This audio output serves as Alarm to indicate certain events.

The signal flow is ARM processor USB port --> USB Codec --> Class D amplifier --> 4 ohms speaker

For diagnosis purpose, I want to detect the presence of analog output from the amplifier and convert this into digital signal (high or low transition), so that the processor would know whether the analog audio section is OK or not.

The signal flow is Class D amplifier --> Audio sense circuit --> Processor GPIO.

Please help me with ideas on how to implement such a feedback circuit.

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

Using a Class-D amplifier makes this a little bit more complicated - but not much.

The problem with simply detecting an AC signal is that the Class-D amplifier is generating its carrier signal even if there isn't any audio present. So: you need to filter out the carrier signal.

A simple RC low-pass filter will get rid of the carrier. Now you are left with the desired audio signal.

You can simply half-wave rectify that audio signal, use appropriate current-limit resistor and voltage divider (if needed), then feed that into your GPIO input pin.

Most PIC microcontroller TTL-level input pins have a threshold voltage of near 1.3 Vdc. If the audio peaks are above that level, the microcontroller will register a logic 1 each time the signal rises above that threshold.

If you set the pin for Interrupt-On-Change, you don't need any form of peak-hold circuit. On the other hand, if you are simply polling the pin on a periodic basis, you need to ensure that any audio peaks detected are held long enough to be captured by the next poll. That's simply a capacitor after the rectifier diode. Be sure to add a discharge resistor across the capacitor - choose the RC time constant to be longer than your poll period.

You can add much more to this if you need to. Bandpass filtering may be necessary. But we don't know what you need because you don't provide enough detail in your question.

\$\endgroup\$
1
  • \$\begingroup\$ Thanks for your guidance. Please let me know the additional details that's required, I will share them without fail. Meantime, let me put together the circuit as you mentioned and feedback. Thanks much. \$\endgroup\$
    – V V Rao
    Oct 31, 2019 at 7:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.