Support Forum

Share your projects and post your questions

Register   or   Sign In
The Forum

Setting "pga"

2334 Views - Created 30/11/2016

30/11/2016

Posted by:
paul42

paul42 Avatar

Am using the Diff ADC pcb on a Pi2. No problem reading etc. I am trying to use the "pga" feature for the first time & finding some difficulty.I have setup a channel on the adc to read in single ended mode, - to ov & feeding the + in with 0.46v via a resistor divider. This reads fine with "adc.set_pga(1)" i get the expected 0.46v.If i change the pga setting to "2" i expected the read figure to double, but it stays the same. In fact it stays the same for the other options of 4 & 8 as well. I must be doing something wrong here, any ideas thanks?Paul

30/11/2016

Posted by:
andrew

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

Hi Paul

The ADC Diff library takes into account the PGA setting when it calculates the voltage so the output will stay the same when you change the PGA value.

When you change the PGA to 2 the ADC will have a maximum input of 1.024V instead of 2.048V. If you put 0.5V into the input the library will still show 0.5V even though the raw values coming from the ADC have doubled.

30/11/2016

Posted by:
paul42

paul42 Avatar

Quote from andrewHi PaulThe ADC Diff library takes into account the PGA setting when it calculates the voltage so the output will stay the same when you change the PGA value.When you change the PGA to 2 the ADC will have a maximum input of 1.024V instead of 2.048V. If you put 0.5V into the input the library will still show 0.5V even though the raw values coming from the ADC has doubled.OK thanks that makes sense.Out of interest i just tried in diff mode with an isolated supply to + & -This produced a different result as follows (rounded v's):1.2v In shows 1.2v with pga 1, 1.0v with pga 2, 0.5v with pga 4 & 0.3v with pga 8Thanks,

30/11/2016

Posted by:
andrew

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

It looks like there is a bug with the library. I will try and figure out what is going wrong and post on here as soon as I have fixed it.

30/11/2016

Posted by:
paul42

paul42 Avatar

Quote from andrewIt looks like there is a bug with the library. I will try and figure out what is going wrong and post on here as soon as I have fixed it.Thanks Andrew...

30/11/2016

Posted by:
andrew

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

After looking through the library and a bit of confusion I have just realised that it is working correctly.

When the PGA is used the maximum input voltage will be reduced:

1x PGA = 2.048V
2x PGA = 1.024V
4x PGA = 0.512V
8x PGA = 0.256V

If you put a 1.6V input on the pin and set the PGA to 2 the voltage will be higher than the ADC can read so it will clip the top 0.6V and just show the maximum value it can store which is 1.024V. That is why it is showing 0.5 and 0.25V for 4 and 8 PGA values as well.

When using the PGA settings it may be worth keeping the voltages below the maximum value for the selected gain. It shouldn't damage the ADC as long as the voltage stays below 2.1V but just to be sure it is probably best not to overdrive the inputs.

30/11/2016

Posted by:
paul42

paul42 Avatar

Quote from andrewAfter looking through the library and a bit of confusion I have just realised that it is working correctly. When the PGA is used the maximum input voltage will be reduced:1x PGA = 2.048V2x PGA = 1.024V4x PGA = 0.512V8x PGA = 0.256VIf you put a 1.6V input on the pin and set the PGA to be 2 the voltage will be higher than the ADC can read so it will clip the top 0.6V and just show the maximum value it can store which is 1.024V. That is why it is showing 0.5 and 0.25V for 4 and 8 PGA values as well.When using the PGA settings it may be worth keeping the voltages below the maximum value for the selected gain. It shouldn't damage the ADC as long as the voltage stays below 2.1V but just to be sure it is probably best not to overdrive the inputs. Thanks, i can get my head round that ok. First time i have tried to use this feature so thanks for the help understanding what is happening.Paul

Sign in to post your reply

Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view, download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.