Noise Floor Calibration
Overview
The noise floor calibration is done periodically to determine what the current thermal noise floor is. Since the hardware doesn't have a fixed reference, it estimates the thermal noise floor at the receiver and uses this internally for a variety of methods.
How does it work?
The best thing to do is read the patent document. It goes into a lot of useful details.
What's it used for?
The estimated thermal noise floor is used as both a reference for measuring incoming signal strength against, as well as the offset for various PHY signal level parameters.
How's it implemented in hardware?
The PHY has a few bits in the AGC control register (AR_PHY_AGC_CONTROL) which controls how the noise floor is programmed, calibrated and used.
For the AR5212 (802.11abg) and later 802.11n chips, the NF calibration hardware is the same. In particular:
- The hardware can be told do a single noise floor calibration (see ar5416StartNFCal() for an example);
- When the hardware has completed a NF calibration, it can either program that value into the chip, or it can simply return the value and leave it to software to manually program in santized values. (see ar5416LoadNF() as an example.)
- Checking NF calibration completion is done by polling the AGC register.
How is it done in software?
The software tracks the last handful of noise floor calibration values and programs in the median value. This is to avoid a few things:
- In case the hardware returns an invalid value (see below for reasons);
- In case the environment changes.
See the following functions:
- ar5416LoadNF() - load the median values into the PHY
- ar5416StartNfCal() - start a new NF calibration
- ar5416UpdateNFHistBuff() - update the history buffer with the most recent samples.
- ar5416SanitizeNF() - sanitize the NF values based on what the expected values are from each chip family
- ar5416GetNF() - read the noise floor from the hardware, sanitize the values, update the history buffer
The noise floor calibration is called periodically from the driver (defaulting to 30 seconds) - this is one of the responsibilities of ath_hal_calibrate().
What goes wrong?
A few things can go wrong:
- When a NF calibration is kicked off, the chip waits for a quiet period before doing a NF calibration. If the environment doesn't have quiet periods, the chip may take a long time (or never?) to actually do a NF calibration.
- If the environment is noisy, the chip may actually calibrate against the combination of thermal noise and the noise introduced in the background, and be unable to compensate for the latter. In this instance, the returned NF values are quite a bit higher than the thermal noise floor.
How could it be improved?
- If the environment is noisy or frequently changing, a 30 second sample interval is not fast enough for the NF values to converge. It may be worthwhile changing that to a smaller value (say a second) if the environment is noisy.
Source files
- ath_hal/ar5212/ar5212_cal.c
- ath_hal/ar5416/ar5416_cal.c
Further reading