Re: uBITX AGC - Adafruit TPA2016, A Success! #ubitx

Nick VK4PP

  VK4PLN's AGC Code. Adafruit TPA2016
Add call to setupTPA2016(); to main code setup() in ubitx_20 after initOscillators();
#include <Wire.h>
#include "Adafruit_TPA2016.h"
Adafruit_TPA2016 audioamp = Adafruit_TPA2016();
void setupTPA2016() {
  // See Datasheet page 22 for value -> dBV conversion table
//  Serial.println("Right off, Left On,");
  audioamp.enableChannel(false, true);
  // Noise Gate Threshold: Below this value, the AGC holds the gain to prevent breathing effects.
  //Select the threshold of the noise gate (1,4,10,20mV) (0-3)
//  Serial.println("Noise Gate Threshold,");
  //Disable NoiseGate, we want to hear everything, even weak signals....
  // Fixed Gain: The normal gain of the device when the AGC is inactive.
  // The fixed gain is also the initial gain when the device comes out of shutdown mode or when the AGC is disabled.
  // value 6 seems to work ok... based on datasheet. Where gain is from -28 (dB) to 30 (dB)
// Serial.println("Setting Fixed Gain");
  audioamp.setGain(-12); //-27 is ok? -12 is too high local stations arnt clipped...
    // Compression Ratio: The relation between input and output voltage.
  // AGC can be TPA2016_AGC_OFF (no AGC) or
  //  TPA2016_AGC_2 (1:2 compression)
  //  TPA2016_AGC_4 (1:4 compression) * Datasheet - Voice
  //  TPA2016_AGC_8 (1:8 compression)
//  Serial.println("Setting AGC Compression");
  // Limiter Level: The value that sets the maximum allowed output amplitude.
//  Serial.println("Setting Limit Level");
  // or turn off with 
  audioamp.setLimitLevel(30);  // range from 0 (-6.5dBv) to 31 (9dBV) (8.5dBv(30) as per datasheet)
  //Maximum Gain: The gain at the lower end of the compression region
//  Serial.println("Setting AGC Max Gain (18-30db - (0-12)");
   *   For voice systems the attack time should be in the 2-ms region, with a hang time of about 0.3 sec,
   *   followed by a gradual recovery time of up to 1 sec. 
  // See Datasheet page 23 for value -> ms conversion table
//  Serial.println("Setting AGC Attack (0.1-6.7ms - (0-63))");
  // See Datasheet page 24 for value -> ms conversion table
//  Serial.println("Setting AGC Hold (0.0137-0.8631ms - (1-63))");
  // See Datasheet page 24 for value -> ms conversion table
//  Serial.println("Setting AGC Release (0.0137-0.8631ms - (0-63))");

Join to automatically receive all group messages.