fwd_average=fwd_average-fwd_cal_offset;
rev_average=rev_average-fwd_cal_offset;
if (rev_average < 0) rev_average=0;
+ if (fwd_average < 0) fwd_average=0;
break;
case NEW_PROTOCOL:
fwd_average=fwd_average-fwd_cal_offset;
rev_average=rev_average-fwd_cal_offset;
if (rev_average < 0) rev_average=0;
+ if (fwd_average < 0) fwd_average=0;
break;
// tx->swr can be used in other parts of the program to
// implement SWR protection etc.
// The SWR is calculated from the (time-averaged) forward and reverse voltages.
+ // Take care that no division by zero can happen, since otherwise the moving
+ // exponential average cannot survive from a "nan".
//
- if (tx->fwd > 0.1) {
+ if (tx->fwd > 0.1 && fwd_average > 0.01) {
//
// SWR means VSWR (voltage based) but we have the forward and
// reflected power, so correct for that