Click Here to see the project from the beginning
As is often the case in firmware-defined hardware systems (“Embedded Systems”), there is a constant interplay between firmware and hardware as the design progresses. This system is no exception and the time has arrived to implement some firmware infrastructure before the next major hardware addition. I’m speaking of a fast A-D acquisition process that can capture audio samples for the coming AGC system. These samples will be used for the S-Meter and the firmware controlled AGC processes.
In order to get accurate and regular samples of real-time audio, we need to sample it at least twice the rate of the highest frequency we want to capture. Trying to do this in the main code loop or by using the Arduino analogRead() function would be way too slow and too irregular. We need some way to capture samples much faster and without interference from other code. My solution involves setting up the A-D hardware sub-system to ‘free run’ in the background at a fast rate defined by an on-board timer. Then another hardware timer, running at a slower rate, can pick up a sample at regular intervals. This technique doesn’t tie up any processor throughput except to respond to the interrupts created by the data collection timer.
If done properly, this process can get samples from multiple A-D ports at varying user-defined rates with little to no interaction between measurements or significantly slowing down the main loop. This allows one very fast rate for audio signal sampling, another slower rate for handling events from the rotary encoders, and an even lower rate for measurements that aren’t very timing critical. I actually had this code from a project I did with the uBitx board. Today I snagged that code and got it working in this project.
Now I can move on to the voltage-controlled audio amplifier, the software defined AGC system that controls it and the S meter functionality that is a byproduct.
Leave a Reply