Dynamically switching gain on ADS1115

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
rbardsley
 
Posts: 62
Joined: Fri Jan 06, 2012 11:09 am

Dynamically switching gain on ADS1115

Post by rbardsley »

In my continued exploration of using the ADS1115 in my project, I now have a need to measure my differential signals at two different gain levels. Is this possible?

One signal goes from 0-4VDC.
The other signal goes from 0-2VDC.

Is it possible to do something like this:

Code: Select all

void loop() 
{
  ads.setGain(GAIN_TWO);        // 2x gain   +/- 2.048V  1 bit = 1mV      0.0625mV
  multiplier = 0.0625;       
  diff01 = ads.readADC_Differential_0_1();   

  ads.setGain(GAIN_FOUR);       // 4x gain   +/- 1.024V  1 bit = 0.5mV    0.03125mV
  multiplier = 0.03125;  
  diff23 = ads.readADC_Differential_2_3(); 
}
Or am I out of luck?

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Dynamically switching gain on ADS1115

Post by adafruit_support_mike »

Without digging through the library to confirm all the code, the general idea looks good. The ADS1115 has programmable gain, so you should be able to switch from one level to the next without trouble.

What do you get when you run the code?

User avatar
rbardsley
 
Posts: 62
Joined: Fri Jan 06, 2012 11:09 am

Re: Dynamically switching gain on ADS1115

Post by rbardsley »

It works!

Now I just have two functions that have different calls for

Code: Select all

ads.setGain(GAIN_FOUR);  
and

Code: Select all

ads.setGain(GAIN_TWO);  
to monitor two unique differential signals on the ADS1115.

Thanks for the help.

Ryan

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Dynamically switching gain on ADS1115

Post by adafruit_support_mike »

Glad to hear you have it working. Happy hacking! ;-)

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”