Friday, September 9, 2022

Integrating the T41-EP with GNU Radio

Before working with the Teensy while it is in the main board, remember to sever the USB power bridge on Teensy, Otherwise you will put 5 volts on the T41-EP 5 volt bus from both your computer and the T41-EP power supply.  Bad things will happen if you don't do that.

Everything is performing well right now with my T41-EP and the V015 software.  However, it would be nice to integrate with GNU Radio to be able to validate the hardware and also open the door to do some experimentation with DSP.  Reading up on Teensy, it has a rich development environment that I found here:

https://www.pjrc.com/teensy/gui/

I developed this flowchart.


I imported the code into Arduino and this is what that looks like:

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioInputI2SQuad        i2s_quad2;      //xy=293,148
AudioInputUSB            usb1;           //xy=329,306
AudioMixer4              mixer1;         //xy=491,148
AudioOutputI2SQuad       i2s_quad1;      //xy=660,303
AudioOutputUSB           usb2;           //xy=742,157
AudioConnection          patchCord1(i2s_quad2, 0, mixer1, 0);
AudioConnection          patchCord2(i2s_quad2, 1, mixer1, 1);
AudioConnection          patchCord3(i2s_quad2, 2, mixer1, 2);
AudioConnection          patchCord4(i2s_quad2, 3, mixer1, 3);
AudioConnection          patchCord5(usb1, 0, i2s_quad1, 0);
AudioConnection          patchCord6(usb1, 0, i2s_quad1, 2);
AudioConnection          patchCord7(usb1, 1, i2s_quad1, 1);
AudioConnection          patchCord8(usb1, 1, i2s_quad1, 3);
AudioConnection          patchCord9(mixer1, 0, usb2, 0);
AudioConnection          patchCord10(mixer1, 0, usb2, 1);
AudioControlSGTL5000     sgtl5000_1;     //xy=385,423
AudioControlSGTL5000     sgtl5000_2;     //xy=402,475
// GUItool: end automatically generated code


void setup() {    
  Serial.begin(9600);            
  AudioMemory(48);
  mixer1.gain(0,1);
  mixer1.gain(1,1);
  sgtl5000_1.enable();
  sgtl5000_2.enable();
  sgtl5000_1.volume(0.6);
  sgtl5000_2.volume(0.6);
}
void loop() {
  // read the PC's volume setting
  float vol = usb1.volume();

  // scale to a nice range (not too loud)
  // and adjust the audio shield output volume
  if (vol > 0) {
    // scale 0 = 1.0 range to:
    //  0.3 = almost silent
    //  0.8 = really loud
    vol = 0.3 + vol * 0.5;
  }
  Serial.println(vol);
  
  // use the scaled volume setting.  Delete this for fixed volume.
  sgtl5000_1.volume(vol);  
  sgtl5000_2.volume(vol);
  delay(1000);
}


It programmed the Teensy fine.  Then my PC detected and loaded an audio device named: "Teensy Audio".  One head scratcher is that the PC's audio output volume doesn't change on the Teensy.  I worked with the 10K pot on the main board and that is how I'm changing volume. That is fine for now.

Remember to sever the USB power bridge on Teensy, Otherwise you will put 5 volts on the T41-EP 5 volt bus from both your computer and the T41-EP power supply.  Bad things will happen if you don't do that.

I did some quick tests, by running audio into both the microphone and receive channels on the main board.  Those appeared on my PCs speakers.  I then played audio from my PC to the  T41-EP.  That audio was on both the speaker output and the Exciter port.  Yay!

With that I now have high confidence that my audio ports are working on the main board.  

This did force me to study the schematic and the main PCB.  I had neglected to jumper the Teensy Audio shield to the L, G, R, MIC GND, and MIC on the PCB.  Doh!  


Now off to GNU Radio.

I loaded it on my desktop.  It threw an error that revealed that my ancient desktop doesn't support AVX.  However, my Laptop did, so now both my desktop and laptop have GNU Radio loaded.

Regardless, my laptop works fine and in GNU Radio Companion, I developed this flow graph:


It loops back the audio source (both of the Audio input ports on the T41-EP) to the Audio Sink (The speaker and the Exciter port on the T41-EP). And it displays an FFT spectrum and waterfall.  I fed it audio from a handy source (audio from the my workbench FireTV) and this is what it shows:



Whoop!  With this, it opens the door to work with any signals and experiment with GNU Radio and to learn and proof DSP techniques which can be ported (I think?) to the T41-EP.

Very satisfying.

Building the T41-EP


 This is my first success.  The CPU is running V015.  The encoders work.  The switch matrix does "something".  Man, that 3.3 Volt regulator does get hot!


It runs!.  I ran a 7.030 MHz CD signal from my signal generator into the QSD.  I'm waiting for some 2n3904 transistors, so that is bypassed by a wire at this time.  The CW tone came through the speaker.  The waterfall shows the signal.