Skip to content

Commit

Permalink
limit gain increases to +34 dB
Browse files Browse the repository at this point in the history
  • Loading branch information
ka9q committed Sep 12, 2024
1 parent 43296f9 commit 2d405f7
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions rx888.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,13 +424,15 @@ static void *agc_rx888(void *arg){
if(frontend->rf_agc && (new_dBFS > AGC_upper_limit || new_dBFS < AGC_lower_limit)){
float const target_level = (AGC_upper_limit + AGC_lower_limit)/2;
float const new_gain = frontend->rf_gain - (new_dBFS - target_level);
if(Verbose)
fprintf(stdout,"Front end gain change from %.1f dB to %.1f dB\n",frontend->rf_gain,new_gain);
rx888_set_gain(sdr,new_gain,false);
// Change averaged value to speed convergence
frontend->if_power *= dB2power(target_level - new_dBFS);
// Unlatch high water mark
frontend->if_power_max = 0;
if(new_gain > 34){ // Don't try to go above max gain
if(Verbose)
fprintf(stdout,"Front end gain change from %.1f dB to %.1f dB\n",frontend->rf_gain,new_gain);
rx888_set_gain(sdr,new_gain,false);
// Change averaged value to speed convergence
frontend->if_power *= dB2power(target_level - new_dBFS);
// Unlatch high water mark
frontend->if_power_max = 0;
}
}
}
return NULL;
Expand Down

0 comments on commit 2d405f7

Please sign in to comment.