Eliminating noise from ADS1115

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

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

Eliminating noise from ADS1115

Post by rbardsley »

Hello,

While I have made steady improvements to my circuit (thank you Adafruit_Support_Bill) and my calibration test is running now (takes 2 days) I have found one more mystery for my non-EE brain. I seem to have some sort of oscillating signal on my analog lines.
noise.jpg
noise.jpg (248.69 KiB) Viewed 2270 times
As far as I can tell, you can use something like an RC filter to remove something like this, but it involves calculations that don't make sense to me yet. It sounds like I need a low-pass filter to try to remove this noise (which may be coming from the EMC from the Arduino itself) but I don't want to lose my signal to such a filter. Does an RC filter remove the oscillation, but keeps the actual signal?

I count ~10 waves per minute in my signal, and this is consistent across ADC0..ADC3, so it seems like it is something that is affecting the whole ADS1115.

Can someone help me understand how to diagnose this, and maybe treat it with an RC filter? Other suggestions HIGHLY welcomed!

I'll update my earlier post once my calibration test is done.

Thanks everyone.

Ryan

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

Re: Eliminating noise from ADS1115

Post by adafruit_support_mike »

It's really hard to filter slow-moving signals, and that's pretty slow.. about 0.67Hz.

Let's do some tests to see where the problem lives. Get a 3v battery pack (or a CR2032 coin cell) and take an ADC reading of that every time you get a reading from the ADS1115. The battery voltage should remain stable, so if you see the same ripple in that series of readings, it means the problem is in your Arduino's power or voltage reference. If the battery readings remain stable, it means there's some kind of oscillation at the sensor.

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Eliminating noise from ADS1115

Post by adafruit_support_bill »

Also - another data point that might be useful in diagnosing the source of the noise: What is the sample rate you used to collect that data?

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

Re: Eliminating noise from ADS1115

Post by rbardsley »

Excellent ideas. I'll buy a battery today and see what I can figure out.

Thanks!

Ryan

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

Re: Eliminating noise from ADS1115

Post by rbardsley »

Sorry, I am sampling the signal on the ADS1115 every 1000ms. Not sure if I would need to speed things up or slow them down to remedy this.

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Eliminating noise from ADS1115

Post by adafruit_support_bill »

Try sampling at a different frequencies and see if the apparent frequency of the noise changes. The 0.167 Hz wave you are seeing may just be aliasing caused by a sample rate that is less than 1/2 of the noise frequency. http://en.wikipedia.org/wiki/Aliasing

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

Re: Eliminating noise from ADS1115

Post by rbardsley »

I still haven't had a moment to wire up the battery test properly, but I was thinking... I am using a TLE2426 "rail splitter" to take the 5VDC precision reference voltage and cut it in half for my differential reference voltage. I started to look through all of the data sheets I had for each component and found that the TLE2426 has an oscillating pattern in its output.
Screen Shot 2014-01-07 at 3.01.50 PM.png
Screen Shot 2014-01-07 at 3.01.50 PM.png (79.4 KiB) Viewed 2207 times
Would this happen to be causing my very stable oscillating noise? It goes right into one end of the differential port, so it seems like that would make sense.

Hmm...

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

Re: Eliminating noise from ADS1115

Post by rbardsley »

I dug out my oscilloscope (we just moved) and definitely see a flickering on all of the +VDC lines in my circuit. I must have something wired-up wrong. The flickering seems to correspond with the TX LEDs on the Arduino and the status LED on the micro-SD breakout board. So, I must have something miswired there. Getting closer...
scope_1.png
scope_1.png (49.94 KiB) Viewed 2201 times

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

Re: Eliminating noise from ADS1115

Post by rbardsley »

Okay... I think I found it.

I have an Adafruit micro-SD breakout board connected to my circuit as well. All of my components share a common ground (which I read can be a problem) but otherwise the micro-SD board is hooked up just like the tutorial suggests. When I have the SD card out, my main program will not run (by design) and I measured the 5VDC source to the Arduino on my oscilloscope:
scope_10.png
scope_10.png (31.21 KiB) Viewed 2197 times
This looks normal. However, if I reset the Arduino and have an SD card in the breakout board, I get a blip on the 5VDC source that corresponds directly with writing to the SD card. I changed my sample rate from every 1000ms to every 500ms and the blip changes accordingly. So, there is either something in the micro-SD board that is causing this, or there is something common connected to my entire circuit that is tripped when writing to the SD card.
scope_12.png
scope_12.png (35.01 KiB) Viewed 2197 times
I have an external wall wart that I tried as well. Even when measuring the Vin from the Arduino on the wall wart power, I see the same blip but on my 9VDC line. Does this sound like a grounding issue?

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Eliminating noise from ADS1115

Post by adafruit_support_bill »

All of my components share a common ground (which I read can be a problem)
It is important to have a common ground. But there can be problems caused by how you wire it. Writing to the SD card does take a bit of current and could induce noise into your circuit. Post a photo of how you have everything hooked up and we'll see if we can spot any potential problem areas.

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

Re: Eliminating noise from ADS1115

Post by rbardsley »

Well, when I hooked up my breadboard this time, the *blip* was gone. I think my breadboard must have had a wire that was angled in a weird way or something else that is non-repeatable, will-haunt-me, and is-annoying. Alas, it's gone.

However, this brings me back to the underlying oscillation in my signal. After looking at things for a while, I have found that it has something to do with the way I am controlling the LED using PWM from the TLC59711. Right now, I check the brightness of the LED as often as I can before having to write to the Serial port for CSV output every 1000ms. Here is my current loop:

Code: Select all

void loop()
{
    unsigned long currentMillis = millis();
    compensate_for_LED_brightness();
    if(currentMillis - previousMillis > interval) 
    {
      previousMillis = currentMillis;  
      Serial.print(intensity);       Serial.print(", ");
      Serial.print(diff01);           Serial.print(", ");
      Serial.print(diff23);           Serial.print(", ");
      Serial.print(quadratic, 0);  
      Serial.println(" ");
      seconds++;
   }
}
And the function I wrote to change the brightness of the LED (as determined by my light sensor hooked up to diff23 on the ADS1115) is here:

Code: Select all

      void compensate_for_LED_brightness()
      {
          diff23 = ads.readADC_Differential_2_3();  
          normalized_ref   = constrain(diff23 + 32767, 0, 65535);
          smoothed_ref    = digitalSmooth(normalized_ref, smoothArray_ref);  
          if(smoothed_ref < target_irradiance)
          {
            intensity++;
            constrain(intensity, 0, 65535);
            setIntensity(intensity);
          }
          else if(smoothed_ref > target_irradiance)
          {
            intensity--;
            constrain(intensity, 0, 65535);
            setIntensity(intensity); 
          }
      }
Now, when I subtract the last reading of intensity from the current reading (to find the slope) I see the oscillation happening in +/- 15 increments. So, that seems to be where my wave pattern is coming from. It has something to do with the way I am adjusting the LED brightness and reading the resulting irradiance value. Here is the output from my slope CSV (apologies for the formatting)

Code: Select all

slope
14
14
14
14
12
-15
-15
-15
-14
-14
6
14
15
15
15
6
-15
-15
-14
-15
-11
14
14
14
14
14
It seems like I am overshooting and undershooting the target irradiance by 15 or so with each loop iteration of the CSV output. The result is a perfectly flat average light reading, but I don't like how I am doing it. I feel like I need something closer to how a PID controller does it. Should I only update the LED brightness every second? It seems like I should be able to do it faster. I actually don't see what is wrong with my current function.

Maybe the smallest detectable increment in brightness is greater than 1 increment on the PWM scale? So, every time I adjust one value on the PWM scale, I am going far beyond the target_irradiance value and it puts it into an unstable oscillation?

Thank you for your continued help.

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Eliminating noise from ADS1115

Post by adafruit_support_bill »

If you are using the TLC59711, the PWM resolution is 16 bits, so that shouldn't be the problem.

How fast are you updating the led output? You may be exceeding the response time of your light sensors.

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

Re: Eliminating noise from ADS1115

Post by rbardsley »

I am updating the LED brightness as fast as it can go before 1000ms passes, then I write out the CSV data and loop again.

Actually, what happens when my loop is right on the edge of the interval timer being exceeded?

Code: Select all

void loop()
{
    unsigned long currentMillis = millis();
    [b]compensate_for_LED_brightness();[/b]
    if(currentMillis - previousMillis > interval) 
    {
        ...
So right now, I am calling the compensate_for_LED_brightness() function as often as I can before the interval timer goes off. What happens if compensate_for_LED_brightness() is fired off at 999ms? Does it wait forcompensate_for_LED_brightness() to finish before moving on to the internal timed loop?

The light sensor should be fast enough. Here is the spec:
Screen Shot 2014-01-08 at 9.50.55 PM.png
Screen Shot 2014-01-08 at 9.50.55 PM.png (114.91 KiB) Viewed 2149 times

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Eliminating noise from ADS1115

Post by adafruit_support_bill »

The light sensor should be fast enough. Here is the spec:
That looks good. But it looks like you have some filtering going on there.

Code: Select all

smoothed_ref    = digitalSmooth(normalized_ref, smoothArray_ref);  
That is going to add some lag to your measured signal.
Also, your control algorithm looks like it would not be very stable around the setpoint.

Code: Select all

          if(smoothed_ref < target_irradiance)
          {
            intensity++;
            constrain(intensity, 0, 65535);
            setIntensity(intensity);
          }
          else if(smoothed_ref > target_irradiance)
          {
            intensity--;
            constrain(intensity, 0, 65535);
            setIntensity(intensity); 
          }
What should work better is proportional control (the "P" in PID). Instead of incrementing or decrementing the output by the same amount based on the whether you are above or below the target setpoint, in a proportional controller, the correction factor is proportional to the "difference. In control terms, we would say that the Output changes proportionally to the Error (Setpoint - Measurement). As you get closer to the setpoint, the output changes get smaller.

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

Re: Eliminating noise from ADS1115

Post by rbardsley »

Yes, yes, yes. Exactly what I have in my head...

...but how to implement something like that for a mere mortal? The PID controller example that I found is way over my head. Is there a library out there that has relatively simple examples for a signal like this? Most seem to work for brewing systems where you want to control all three variables. Or do I need that?

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

Return to “Other Products from Adafruit”