Use the 45MHz Roofing Filter for an RF AGC?

 

John, VK2ETA, came across an idea in the search for a greater range for his MAX9814 AGC circuit.

Stations, above S9+10 would produce distortion in the audio circuit with the MAX9814 AGC in circuit.   He isolated this to the MAX circuit as the distortion would disappear when it was bypassed.

John was curious as to what the first 45Mhz filter (Roofing Filter) shape was like and if there was some plateau to be used somewhere for attenuating the strong signals.

He modified Ashhar Farhan’s original software to include an “Adjust First IF” menu item, in steps of [1000Hz].

By using a local station’s carrier aligned on 1,500Hz audio as a reference and an Android audio spectrum display he plotted the response of the single crystal roofing filter. This also gave an idea of the effect on the audio of shifting the filter up and down. The “noise” in the graph below near the peak is the effect of changing from a measure every [10,000Hz] to a measure every [1000Hz], plus the inaccuracy of John’s rudimentary instrumentation.

As you can see, there are rather slow slopes on each side of the peak (which is off-center by [7,000Hz] approximately when compared to 1,500Hz – the centre frequency of an SSB signal).

So John has proceeded with changing Ian’s software (based on v1.04) to incorporate an automatic AGC step-down when the signal reaches S9+10 and and automatic step-up when it reached S0. In the middle range, the MAX audio circuit does the AGC job.

John used the up side of the filter as he got some birdies on some of the shifts on the down side.

Now the uBitx can handle S9++++ stations with ease, that is until the first amplifier stage before the filter saturates which John suspects is unlikely in “normal” conditions.

The only concern would be for another, possibly even stronger, station which would be placed at the peak of the filter (possibly several KHz away). This could produce intermod distortion. But the chances of that happening are pretty remote.

So, this approach works quite well and is surprisingly effective for AGC control at an early stage in the receiver.

It also works in reverse, with the transmit SSB signal being attenuated by the same amount, thereby leading to a possible ALC software control for the units which measure the power out (or possibly just the current).   It could also be a simple solution to set attenuation (e.g. on digital modes).  Again, check the effect of the slope on the voice tone.

John has attached snippets of his code.  He has also uploaded the modified uBitx software for testing the filter both in RX and TX in the  “Software based IF attenuation” folder in the BITX20 IO Group files.

John will soon publish the complete set of Ian’s modified software including mods to control his ATU unit.   However, in seeing discussions on an IF AGC in the group, he thought this update would be of interest to constructors.

Code Snippets

#define OPTION_SMETER
#define OPTION_SOFTWAREAGC

void doSoftwareAGC() {
#ifdef OPTION_SMETER

int newSMeter;

//VK2ETA S-Meter from MAX9814 TC pin
newSMeter = analogRead(ANALOG_SMETER);
//Serial.print(“newSMeter:”); Serial.println(newSMeter);

//Faster attack, Slower release
currentSMeter = (newSMeter > currentSMeter ? ((currentSMeter * 3 + newSMeter * 7) + 5) / 10 : ((currentSMeter * 7 + newSMeter * 3) + 5) / 10);

//Serial.print(“currentSMeter:”); Serial.println(currentSMeter);
//Scale it
scaledSMeter = 0;
for (byte s = 8; s >= 1; s–) {
if (currentSMeter > sMeterLevels[s]) {
scaledSMeter = s;
break;
}
}
//Serial.print(“scaledSMeter, un-adjusted:”); Serial.println(scaledSMeter);
#ifdef OPTION_SOFTWAREAGC
//Apply auto-shift of first IF to increase the dynamic range of the Audio AGC circuit
long previousShift = firstIfShift;
if (scaledSMeter >= 7) {
//Reduce gain by shifting the first and second If by the same value, thereby
// leaving the RX frequency the same but using the slope of the roofing
// filter to deliver progressive attenuation.
// 10kHz or 5kHz per step.
firstIfShift += (scaledSMeter > 7 ? 10000 : 5000);
} else if (firstIfShift > 0 && scaledSMeter < 1) {
//Re-increase the gain if we reduced it earlier
firstIfShift -= 5000;
firstIfShift = firstIfShift < 0 ? 0 : firstIfShift;
}
if (firstIfShift != previousShift) {
setFrequency(frequency);
//Serial.print(“firstIfShift:”); Serial.println(firstIfShift);
//Adjust meter by IF attenuation except for the first 10Khz. Approx 6dB per 5KHz.
scaledSMeter += (firstIfShift > 10000 ? (firstIfShift – 10000) / 5000 : 0);
//Serial.print(“scaledSMeter, adjusted:”); Serial.println(scaledSMeter);
}
#endif //OPTION_SOFTWAREAGC
#endif //OPTION_SMETER

}

//And the setfrequency function becomes:

void setFrequency(unsigned long f) {
f = (f / arTuneStep[tuneStepIndex – 1]) * arTuneStep[tuneStepIndex – 1];

setTXFilters(f);

if (cwMode == 0)
{
if (isUSB) {
//si5351bx_setfreq(2, SECOND_OSC_USB – usbCarrier + f + (isIFShift ? ifShiftValue : 0));
si5351bx_setfreq(2, SECOND_OSC_USB + firstIfShift – usbCarrier + f – ((isIFShift && !inTx) ? ifShiftValue : 0));
si5351bx_setfreq(1, SECOND_OSC_USB + firstIfShift);
}
else {
//si5351bx_setfreq(2, SECOND_OSC_LSB + usbCarrier + f + (isIFShift ? ifShiftValue : 0));
si5351bx_setfreq(2, SECOND_OSC_LSB + firstIfShift + usbCarrier + f + ((isIFShift && !inTx) ? ifShiftValue : 0));
si5351bx_setfreq(1, SECOND_OSC_LSB + firstIfShift);
}
//VK2ETA Bring back the BFO to default if using IF Shift and we are TXing
si5351bx_setfreq(0, usbCarrier + ((isIFShift && !inTx) ? ifShiftValue : 0));
}

else
{
if (cwMode == 1) { //CWL
//si5351bx_setfreq(2, SECOND_OSC_LSB + cwmCarrier + f + (isIFShift ? ifShiftValue : 0));
si5351bx_setfreq(2, SECOND_OSC_LSB + firstIfShift + cwmCarrier + f + ((isIFShift && !inTx) ? ifShiftValue : 0));
si5351bx_setfreq(1, SECOND_OSC_LSB + firstIfShift);
}
else { //CWU
//si5351bx_setfreq(2, SECOND_OSC_USB – cwmCarrier + f + (isIFShift ? ifShiftValue : 0));
si5351bx_setfreq(2, SECOND_OSC_USB + firstIfShift – cwmCarrier + f – ((isIFShift && !inTx) ? ifShiftValue : 0));
si5351bx_setfreq(1, SECOND_OSC_USB + firstIfShift);

}
//VK2ETA Bring back the BFO to default if using IF Shift and we are TXing
si5351bx_setfreq(0, cwmCarrier + ((isIFShift && !inTx) ? ifShiftValue : 0));

}

Reference