I2Cdevlib Forums

# WanaGo

Members

1

2

## Reputation Activity

1. WanaGo got a reaction from weleoka in ADS1115 Single Ended mode - Strange results
Hello,

Basically what I am doing is I have the ADS1115 in single channel mode, measuring the voltage across a resistor, which indicates the current flowing through the resistor. The current comes from an AC Current Clamp which sits on my mains power board.

Basically what I am trying to do is measure the current flowing, using information I have found on the openenergymonitor.org site.
They have a library which basically offsets the AC wave into the positive space, then filters out the wave in code and samples the wave to get an average, which then gives you the current flowing in the AC line.

They have used the standard 10 bit ADC on the Arduino, but I wanted to use the 16bit ADS1115 instead.

I have set the Gain to be 4.096, and have tried 860samples/second in continuous mode, but I am seeing very weird results sometimes.
Its like Channel 0 is merging into Channel, and 2 into 3, or some other random combination, and I cannot fully understand what is going on.

This is however using their own library, but one guy mentions yours and said it has a similar problem. He describes a fix, but I cannot find where to apply that.

I am also using a Chipkit board, so its running at 80Mhz compared to the 16Mhz of the Arduino.

I was wanting to know if you could tell me if there is any reason why doing

quite fast, would cause problems. I was under the impression that you could call this as often as you liked, and it would just report the current figure that the ADS1115 had measured at the time, since its in continuous mode. Is that right?

Here are the 2 main functions I have in my code, which is mainly copied out of the example from the openenergymonitor.org website
double calcIrms(int NUMBER_OF_SAMPLES, int Channel) {                 double ADC_COUNTS = 24512; //portion of 15bit count used for range                 double SUPPLYVOLTAGE = 3064; //3.064V is the full scale I can output into sensor from clamp                 double ICAL = 100; //current constant = (100 / 0.050) / 20 = 100                 for (int n = 0; n < NUMBER_OF_SAMPLES; n++)                 {                                 lastSampleI = sampleI;                                 if(Channel == 1)                                 {                                                 sampleI = adc.getConversionP1GND();                                 }                                 else if(Channel == 3)                                 {                                                 sampleI = adc.getConversionP3GND();;                                 }                                 else                                 {                                                 return 0;                                 }                                 lastFilteredI = filteredI;                                 filteredI = 0.996 * (lastFilteredI + sampleI - lastSampleI);                                 // Root-mean-square method current                                 // 1) square current values                                 sqI = filteredI * filteredI;                                 // 2) sum                                 sumI += sqI;                 }                 double I_RATIO = ICAL * ((SUPPLYVOLTAGE / 1000.0) / (ADC_COUNTS));                 double Irms = I_RATIO * sqrt(sumI / NUMBER_OF_SAMPLES);                 //Reset accumulators                 sumI = 0;                 return Irms; } void loop() {                 Irms1 = calcIrms(100, 1);  // Calculate Irms only                 Irms3 = calcIrms(100, 3);  // Calculate Irms only                 apparentPower1 = supplyVoltage * Irms1;     //extract Apparent Power into variable                 apparentPower3 = supplyVoltage * Irms3;     //extract Apparent Power into variable } I am displaying this to a TFT LCD and sometimes the figures just drop to 0 and stay there, and now and then the numbers blink to show something, and then go away again.

Any help you could provide would be appreciative, esp if you see that I am doing something stupid.
Regards
WanaGo
2. WanaGo got a reaction from Samellanak in ADS1115 Single Ended mode - Strange results
Hello,

Basically what I am doing is I have the ADS1115 in single channel mode, measuring the voltage across a resistor, which indicates the current flowing through the resistor. The current comes from an AC Current Clamp which sits on my mains power board.

Basically what I am trying to do is measure the current flowing, using information I have found on the openenergymonitor.org site.
They have a library which basically offsets the AC wave into the positive space, then filters out the wave in code and samples the wave to get an average, which then gives you the current flowing in the AC line.

They have used the standard 10 bit ADC on the Arduino, but I wanted to use the 16bit ADS1115 instead.

I have set the Gain to be 4.096, and have tried 860samples/second in continuous mode, but I am seeing very weird results sometimes.
Its like Channel 0 is merging into Channel, and 2 into 3, or some other random combination, and I cannot fully understand what is going on.

This is however using their own library, but one guy mentions yours and said it has a similar problem. He describes a fix, but I cannot find where to apply that.

I am also using a Chipkit board, so its running at 80Mhz compared to the 16Mhz of the Arduino.

I was wanting to know if you could tell me if there is any reason why doing

quite fast, would cause problems. I was under the impression that you could call this as often as you liked, and it would just report the current figure that the ADS1115 had measured at the time, since its in continuous mode. Is that right?

Here are the 2 main functions I have in my code, which is mainly copied out of the example from the openenergymonitor.org website
double calcIrms(int NUMBER_OF_SAMPLES, int Channel) {                 double ADC_COUNTS = 24512; //portion of 15bit count used for range                 double SUPPLYVOLTAGE = 3064; //3.064V is the full scale I can output into sensor from clamp                 double ICAL = 100; //current constant = (100 / 0.050) / 20 = 100                 for (int n = 0; n < NUMBER_OF_SAMPLES; n++)                 {                                 lastSampleI = sampleI;                                 if(Channel == 1)                                 {                                                 sampleI = adc.getConversionP1GND();                                 }                                 else if(Channel == 3)                                 {                                                 sampleI = adc.getConversionP3GND();;                                 }                                 else                                 {                                                 return 0;                                 }                                 lastFilteredI = filteredI;                                 filteredI = 0.996 * (lastFilteredI + sampleI - lastSampleI);                                 // Root-mean-square method current                                 // 1) square current values                                 sqI = filteredI * filteredI;                                 // 2) sum                                 sumI += sqI;                 }                 double I_RATIO = ICAL * ((SUPPLYVOLTAGE / 1000.0) / (ADC_COUNTS));                 double Irms = I_RATIO * sqrt(sumI / NUMBER_OF_SAMPLES);                 //Reset accumulators                 sumI = 0;                 return Irms; } void loop() {                 Irms1 = calcIrms(100, 1);  // Calculate Irms only                 Irms3 = calcIrms(100, 3);  // Calculate Irms only                 apparentPower1 = supplyVoltage * Irms1;     //extract Apparent Power into variable                 apparentPower3 = supplyVoltage * Irms3;     //extract Apparent Power into variable } I am displaying this to a TFT LCD and sometimes the figures just drop to 0 and stay there, and now and then the numbers blink to show something, and then go away again.

Any help you could provide would be appreciative, esp if you see that I am doing something stupid.
Regards
WanaGo
3. WanaGo got a reaction from TimothyPi in ADS1115 Single Ended mode - Strange results
Hello,

Basically what I am doing is I have the ADS1115 in single channel mode, measuring the voltage across a resistor, which indicates the current flowing through the resistor. The current comes from an AC Current Clamp which sits on my mains power board.

Basically what I am trying to do is measure the current flowing, using information I have found on the openenergymonitor.org site.
They have a library which basically offsets the AC wave into the positive space, then filters out the wave in code and samples the wave to get an average, which then gives you the current flowing in the AC line.

They have used the standard 10 bit ADC on the Arduino, but I wanted to use the 16bit ADS1115 instead.

I have set the Gain to be 4.096, and have tried 860samples/second in continuous mode, but I am seeing very weird results sometimes.
Its like Channel 0 is merging into Channel, and 2 into 3, or some other random combination, and I cannot fully understand what is going on.

This is however using their own library, but one guy mentions yours and said it has a similar problem. He describes a fix, but I cannot find where to apply that.

I am also using a Chipkit board, so its running at 80Mhz compared to the 16Mhz of the Arduino.

I was wanting to know if you could tell me if there is any reason why doing

quite fast, would cause problems. I was under the impression that you could call this as often as you liked, and it would just report the current figure that the ADS1115 had measured at the time, since its in continuous mode. Is that right?

Here are the 2 main functions I have in my code, which is mainly copied out of the example from the openenergymonitor.org website
double calcIrms(int NUMBER_OF_SAMPLES, int Channel) {                 double ADC_COUNTS = 24512; //portion of 15bit count used for range                 double SUPPLYVOLTAGE = 3064; //3.064V is the full scale I can output into sensor from clamp                 double ICAL = 100; //current constant = (100 / 0.050) / 20 = 100                 for (int n = 0; n < NUMBER_OF_SAMPLES; n++)                 {                                 lastSampleI = sampleI;                                 if(Channel == 1)                                 {                                                 sampleI = adc.getConversionP1GND();                                 }                                 else if(Channel == 3)                                 {                                                 sampleI = adc.getConversionP3GND();;                                 }                                 else                                 {                                                 return 0;                                 }                                 lastFilteredI = filteredI;                                 filteredI = 0.996 * (lastFilteredI + sampleI - lastSampleI);                                 // Root-mean-square method current                                 // 1) square current values                                 sqI = filteredI * filteredI;                                 // 2) sum                                 sumI += sqI;                 }                 double I_RATIO = ICAL * ((SUPPLYVOLTAGE / 1000.0) / (ADC_COUNTS));                 double Irms = I_RATIO * sqrt(sumI / NUMBER_OF_SAMPLES);                 //Reset accumulators                 sumI = 0;                 return Irms; } void loop() {                 Irms1 = calcIrms(100, 1);  // Calculate Irms only                 Irms3 = calcIrms(100, 3);  // Calculate Irms only                 apparentPower1 = supplyVoltage * Irms1;     //extract Apparent Power into variable                 apparentPower3 = supplyVoltage * Irms3;     //extract Apparent Power into variable } I am displaying this to a TFT LCD and sometimes the figures just drop to 0 and stay there, and now and then the numbers blink to show something, and then go away again.

Any help you could provide would be appreciative, esp if you see that I am doing something stupid.
Regards
WanaGo
4. WanaGo got a reaction from CharlesnurE in ADS1115 Single Ended mode - Strange results
Hello,

Basically what I am doing is I have the ADS1115 in single channel mode, measuring the voltage across a resistor, which indicates the current flowing through the resistor. The current comes from an AC Current Clamp which sits on my mains power board.

Basically what I am trying to do is measure the current flowing, using information I have found on the openenergymonitor.org site.
They have a library which basically offsets the AC wave into the positive space, then filters out the wave in code and samples the wave to get an average, which then gives you the current flowing in the AC line.

They have used the standard 10 bit ADC on the Arduino, but I wanted to use the 16bit ADS1115 instead.

I have set the Gain to be 4.096, and have tried 860samples/second in continuous mode, but I am seeing very weird results sometimes.
Its like Channel 0 is merging into Channel, and 2 into 3, or some other random combination, and I cannot fully understand what is going on.

This is however using their own library, but one guy mentions yours and said it has a similar problem. He describes a fix, but I cannot find where to apply that.

I am also using a Chipkit board, so its running at 80Mhz compared to the 16Mhz of the Arduino.

I was wanting to know if you could tell me if there is any reason why doing

quite fast, would cause problems. I was under the impression that you could call this as often as you liked, and it would just report the current figure that the ADS1115 had measured at the time, since its in continuous mode. Is that right?

Here are the 2 main functions I have in my code, which is mainly copied out of the example from the openenergymonitor.org website
double calcIrms(int NUMBER_OF_SAMPLES, int Channel) {                 double ADC_COUNTS = 24512; //portion of 15bit count used for range                 double SUPPLYVOLTAGE = 3064; //3.064V is the full scale I can output into sensor from clamp                 double ICAL = 100; //current constant = (100 / 0.050) / 20 = 100                 for (int n = 0; n < NUMBER_OF_SAMPLES; n++)                 {                                 lastSampleI = sampleI;                                 if(Channel == 1)                                 {                                                 sampleI = adc.getConversionP1GND();                                 }                                 else if(Channel == 3)                                 {                                                 sampleI = adc.getConversionP3GND();;                                 }                                 else                                 {                                                 return 0;                                 }                                 lastFilteredI = filteredI;                                 filteredI = 0.996 * (lastFilteredI + sampleI - lastSampleI);                                 // Root-mean-square method current                                 // 1) square current values                                 sqI = filteredI * filteredI;                                 // 2) sum                                 sumI += sqI;                 }                 double I_RATIO = ICAL * ((SUPPLYVOLTAGE / 1000.0) / (ADC_COUNTS));                 double Irms = I_RATIO * sqrt(sumI / NUMBER_OF_SAMPLES);                 //Reset accumulators                 sumI = 0;                 return Irms; } void loop() {                 Irms1 = calcIrms(100, 1);  // Calculate Irms only                 Irms3 = calcIrms(100, 3);  // Calculate Irms only                 apparentPower1 = supplyVoltage * Irms1;     //extract Apparent Power into variable                 apparentPower3 = supplyVoltage * Irms3;     //extract Apparent Power into variable } I am displaying this to a TFT LCD and sometimes the figures just drop to 0 and stay there, and now and then the numbers blink to show something, and then go away again.

Any help you could provide would be appreciative, esp if you see that I am doing something stupid.
Regards
WanaGo
×