CTR2 was designed from the start to manage audio to and from your radios. The inspiration to do this came in part from the PJRC.com web site. Paul Stoffregen and Robin Coon at PJRC.com, and the online ecosystem supporting Teensy products, have provided us mere mortals with an extraordinary set of hardware development boards and software tools that provide exceptionally easy methods to manage audio with a micro-controller.
This project originally started in April 2020 with the PJRC.com Teensy 4.0 micro-controller and Rev D Audio Adapter board. The processor board features a 600 MHz ARM Cortex-M7 processor with tons of memory and other options. After I built the first CTR2 prototype PJRC.com came out with the Teensy 4.1 board. This board is a little longer than the 4.0 board. The extra length brings more serial ports out to the I/O pins and provides a build-in SD card. Needless to say, it didn’t take long before the HMI board was updated to host the 4.1 board.
Teensy audio processing is managed by an online Audio Design Tool. This tool runs on Node-Red and allows you to build your audio processing chain using a simple drag and drop interface. You literally do no coding to configure the audio routing and DSP treatment. The design tool allows you to import an existing configuration (such as from CTR.ino) or export a new configuration once you’ve changed your design.
To import the audio configuration from CTR2, open the CTR2.ino file in your development environment (Arduino IDE, Microsoft Code, or my favorite, Microsoft Visual Studio). Scroll down the source code listing to around line 70(ish) and you’ll find the start of the audio configuration code:
// GUItool: begin automatically generated code //============================================
//Paste autogenerated code from https://www.pjrc.com/teensy/gui/
Copy everything between the //===================== lines into the clipboard. In the current release (8/3/21) this code starts at line 79 and ends on line 143. Open the design tool, click the Import button, and paste the clipboard into the import window (Ctrl+V) and click [OK]. The design tool will render the configuration.
Once you’ve edited your configuration, reverse the process. In the design tool, click the Export button, press Ctrl+A to select all text, then Ctrl+C to copy it to the clipboard. Open CTR2.ino, delete all the code between the //===================== markers and paste (Ctrl+V) the new configuration code into CTR2.ino.
NOTE: Configuring the audio properties is only the start. If you change any of the object names or add/remove objects you must modify the source code to accommodate these changes.
The audio design tool helps you visualize how signals are brought into, routed, mixed, filtered, detected, and brought out of the audio board.
The audio board is based on the SGTL5000 codec from NXP. The design tool does a great job hiding all the complexities of this chip from us.
The HMI‘s Amp Levels page shows the basic functions of the audio processor. Line In, Mic In, and USB In bring audio into the routing matrix represented by HMI on this page. Each input has an amp associated with it. USB Out and Line Out are the outputs and have amps associate with them. The FFT amp allows us additional control over the level sent to the tone decoders and FFT decoder in the SGTL5000.
Visit the UI: Configuration and Levels post for a discussion on how the Amp Levels page works.
In the following discussion, objects in the design tool are displayed in highlighted bold text.
Line In and Mic In feed into the Line_In object in the audio design tool. This object takes these analog input signals and converts them to a left and right channel digital stream.
Line In comes from the Line In signal from the Radio I/O module and is fed into the left channel of Line_In. This audio can be supplied by the radio’s Line Out or Speaker output depending on how you wired the Radio I/O module.
The Mic In signal comes from the HMI‘s Mic connector and is fed into the right channel of Line_In.
USB In comes from the left channel of the Teensy 4.1’s micro-USB port and is shown as USB_In in the audio designer. This signal is already a digital stream and is usually provided by a 3rd party app such as WSJT-X.
There are a few other inputs in the audio design that aren’t shown on the Amp Levels page.
Sidetone is a tone generator that generates the CW sidetone heard in the headphones. Its level is adjusted using the Sidetone Level control on the CW Settings page.
RTTY is a 2-tone generator that generates the RTTY tones. Its frequency is controlled by the RTTY_KEY input. Its level is adjusted with the Tx Level control on the RTTY Settings page.
PlaySdRaw is a player that decodes and plays a .WAV file stored on the SD card. This object is used to play voice announcements, voice transmit buffers, and off-air receive recordings.
The audio matrix has several outputs. The program decides which output to use based on the user’s input and the operating mode.
USB Out (USB_Out in the audio designer) sends a digital audio stream back to your PC using the micro-USB connector on the Teensy 4.1. 3rd party apps use this audio. Your app should provide a method to select the input and output audio source for their use. Select the Teensy input and output audio ports.
Line Out shown in the Amp Levels page comes from the Output object in the audio adapter. This object can send analog audio to the Line Out port of the Radio I/O module (and on to the Line In or Mic inputs on your radio), and/or this audio can be routed to the internal Headphone jack. This jack was originally mounted on the audio adapter board and was removed during construction of the HMI. The headphone output of the audio adapter board was wired to the Headphone jack on the front of the HMI.
NOTE: The headphone output on the HMI is floating and neither lead must ever be connected to ground! Doing so will probably destroy the audio adapter board.
Record_Out is an object that records audio to the SD card. This object is used to record voice buffers and receive audio. There is a level control on the HMI record page that allows you to set the level of Amp_Rec.
MIXERS AND FILTERS
Mixers combine one to four inputs into a common output signal. Each input has an adjustable level control that when set to 0 gain disables that input. This is used to enable and disable audio paths depending on the operating mode.
Filters provide DSP functions like bandwidth control and notch filtering. These are under control of the HMI and each operating mode has its own filter settings.
Various detectors are incorporated in the HMI.
Sq_Det listens to the receive audio path. When the audio is above the threshold set on the Home page Squelch control the receive audio is allowed to pass to the headphones. Normally this control is set to minimum to disable squelch control. It can come in handy when monitoring for a band opening. Just adjust Squelch to mute the receive audio under idle noise levels. Any additional audio received will open the receive audio path.
Vox_Det listens to the transmit audio path. It activates when audio is above the VOX Trigger level set on the Digital Settings page. If the on Tx Audio Activity control is set to Pass Audio > Radio the transmit audio will be routed to Line Out and sent to the transmitter where its Vox control can be used to key the radio. It the VOX > Radio PTT is selected the transmit audio will be sent to Line Out and the HMI will issue a PTT output to the Radio I/O module to key the transmitter. This option is usually used when operating in Digital mode with 3rd party apps but may be used (with limited success) in Voice mode also.
Tone1 and Tone2 detectors detect single tone frequencies. Tone1 is used for CW and RTTY signal decoding. In CW mode, Tone1‘s frequency is adjusted by the FFTFreq option selected on the encoder. Tone2 is used to detect the second tone in an RTTY signal. The tone detect threshold is set by the FFT gain control on the Home page along with the FFT amp gain on the Amp Levels page. To set the detector level, adjust these controls so the receive noise floor on the FFT graph on the Home page is just under the first graticule on the bottom. The tone to detect should deflect towards the top two graticules on the graph.
The fft1024_1 object is the FFT decoder. It samples a bandwidth of 24 kHz but since we only have a limited audio signal to work with, CTR2 only displays the first 3.2 kHz of the signal.
The sgtl5000_1 object is used to control the general operation of the SGTL5000 codec. The 5-band equalizers and transmit compression amp are configured and enabled in this object.
This completes the Teensy Audio walk through. If you have additional questions, post them below and I’ll try to answer them. I am not, by any means, an expert on this board. What I know I’ve learned by trial and error and many visits to the Teensy forums. That’s where the real experts hang out.