mmmries / ads1115

Elixir Circuit Library for Interacting with an ADS1115 or ADS1015 Analog-to-Digital Chip
10 stars 8 forks source link

PGA (Programmable Gain Amplifier) is confusing to many #6

Open tomjoro opened 2 years ago

tomjoro commented 2 years ago

The PGA is confusing a lot of folks. Maybe we could update the readme to explain it a little more clearly.

Firstly, the range of the number never changes for the chip, i.e 12bits in 2's complement. The gain number changes the actual voltage range that is "zoomed" in.

For example if the gain is at 2048, then +-2.048 is the maximum voltage that can be measured. Anything beyond that will be clipped according to the specification. The actual 12 bit range covers that voltage range so that the maximum positive 12bit number is 2.048 volts.

So, if you want to measure 5V then you have to set the PGA to 6144.

If you are converting the FSR reading that is returned to voltage, then you need to know what gain was used when the value was read.