Capacitor size to stop 60hz noise

Discussion in 'General Electronics Chat' started by PickyBiker, Sep 22, 2019.

  1. PickyBiker

    Thread Starter Member

    Aug 18, 2015
    88
    4
    In the temperature sensing circuit below, I am getting some 60 Hz in the output. I would like to place a capacitor to help block that but I have questions Bout capacitor size and location. This sensing circuit is for an Arduino that will use a PID controller to adjust a 3D printer bed heater. The more noise free the temp sensor the better the PID control will work.

    1: Should the capacitor be across the output to ground or should it be across the temp sensor which is likely where the noise is being picked up?
    2: If it's too small it won't filter adequately and if it is too large it will slow the temperature response. How can I figure out what the capacitance should be? Tmp.PNG
     
  2. ericgibbs

    Moderator

    Jan 29, 2010
    8,526
    1,713
    hi PB,
    How is the sensor connected to PID input.? is it a longish lead and unscreened.?
    E
     
  3. PickyBiker

    Thread Starter Member

    Aug 18, 2015
    88
    4
    it is about 2.5' of unshielded cable with about 1' of that as part of the heated bed.
     
  4. ericgibbs

    Moderator

    Jan 29, 2010
    8,526
    1,713
    hi,
    A length of 2.5' is OK, you could use shielded to help reduce mains pickup.
    Which type of temperature sensor are you using.?

    The problem with removing 60Hz mains hum is the low frequency requires a highish cap value.
    What is the lowest response time of tempr change that is acceptable.?

    E
     
  5. crutschow

    Expert

    Mar 14, 2008
    23,086
    6,849
    How much is "some"?
    We can't accurately suggest a cap value if we don't know how much interference we are trying to minimize.
    And how low a value of noise can you tolerate?
     
  6. PickyBiker

    Thread Starter Member

    Aug 18, 2015
    88
    4
    Answering the question on "some" will be difficult without using a scope. What I do know is it varies the calculated temp by about 2-2.5 degrees C.

    On the response question, 1-2 degree/second is probably fine because of the mass of the heater bed.

    On the type of sensor, it is the standard 100k resistive Temp sensor used in 3D printers.

    On the shielded cable, that is a good idea, but I am concerned because the sensor is part of an aluminum heatbed which is probably acting like an antenna for the mains.

    Let me know if I can provide any more information about this.
     
  7. crutschow

    Expert

    Mar 14, 2008
    23,086
    6,849
    So what signal voltage represents 1 degree C?
    That will tell us the approximate noise level.
     
  8. ericgibbs

    Moderator

    Jan 29, 2010
    8,526
    1,713
    hi PB,
    Without a scope to measure the suspected 60Hz interference, why do you think its 60Hz.?
    It could be electrical noise from a number of sources, is your 5V supply to the Thermistor noisy, try adding say a 1uF across the +5V, close as possible to the sensor,
    E
     
  9. Dodgydave

    AAC Fanatic!

    Jun 22, 2012
    8,264
    1,440
    You can twist the sensor wires together to cancel out noise, or use ferrite beads..ideally you need a scope...
     
  10. PickyBiker

    Thread Starter Member

    Aug 18, 2015
    88
    4
    Here is the temp/voltage readings I got at about room temperature

    Temp in C Voltage
    20.3 2.33
    22.3 2.43
    24.3 2.53

    looks like .05 V / degree C to me.

    I do not know for certain that it is 60 Hz but when I touch near the sensor, the temp varies more so I assumed it is mains being picked up.
     
  11. ericgibbs

    Moderator

    Jan 29, 2010
    8,526
    1,713
    hi PB,
    You could try a simple filter as per this diagram.
    Increase the C value as required, depends upon the response time required for the Tempr.
    E
     
    • Tmp.PNG
      Tmp.PNG
      File size:
      8.7 KB
      Views:
      19
  12. PickyBiker

    Thread Starter Member

    Aug 18, 2015
    88
    4
    Ericgibbs, I understand about the two capacitors but I'm not sure about the purpose of the 1k resistor in the output. Can you provide a little insight?
     
  13. ericgibbs

    Moderator

    Jan 29, 2010
    8,526
    1,713
    hi,
    If the Arduino is switched Off and its a high value cap, it is to reduce the pins input current.
    Have you tried the filter.
    E
     
  14. PickyBiker

    Thread Starter Member

    Aug 18, 2015
    88
    4
    Thanks, I understand now. I have not tried the filter yet. I am changing to a shielded cable (as soon as I can find that in my raw materials or order some.) and the filters you suggested will be added too.
     
  15. ericgibbs

    Moderator

    Jan 29, 2010
    8,526
    1,713
    hi,
    Have you also considered averaging the ADC readings in the Arduino, before displaying.?
    E
     
  16. MrSoftware

    Senior Member

    Oct 29, 2013
    1,494
    480
    You can oversample the ADC line and average as mentioned above. Not a fix, but it could help. Without a scope you might be able to determine the frequency of your noise using your ADC. Take a couple seconds worth of samples as quickly as you can sample then graph the results. Dump it to a text file and graph it with google sheets or excel, etc.. If the noise frequency is low relative your sample rate, you should see the noise frequency in the graphed results. Note that if your only means of output from the arduino is the terminal, then take your samples first and put them in a buffer, THEN dump the output to the terminal after your sampling is completed. This will significantly increase your ability to sample quickly.

    If you need to add capacitance, I believe you'll get the best results by adding it as closely to the temp sensor as possible. Also if you can incorporate some sort of differential line driver for the temperature signal then that could possibly help a lot as well.
     
    Last edited: Sep 23, 2019
  17. PickyBiker

    Thread Starter Member

    Aug 18, 2015
    88
    4
    ericgibbs, Great minds think alike. I am trying a filter that works by keeping track of the last calculated value and then letting a new values change the result by a small percentage. Right now I have set the function to 95% dependent on the saved old value and 5% on the new value. Once calculated, the result is stored as the lastTemp. So far, that appears to be working quite well. Here is what that looks like in Arduino code where data is the new temp and gain is the % of reliance on the lastTemp. In the setup, I get the temperature once to set lastFiltered so it doesn't start out at 0.

    double filtered, lastFiltered;

    double Filter(double data, double gain)
    {
    filtered = (lastFiltered * gain) + (data * (1 - gain));
    // Serial.print(" Filtered "); Serial.print(filtered); Serial.print(" ");
    lastFiltered = filtered;
    return filtered;
    }
     
  18. MrSoftware

    Senior Member

    Oct 29, 2013
    1,494
    480
    The problem with this approach is that your readings are inaccurate due to noise and you're smoothing the output in an attempt to hide the inaccuracies. The better approach is to make the readings more accurate, though you would know more than we would if your use case requires better accuracy or not.
     
  19. PickyBiker

    Thread Starter Member

    Aug 18, 2015
    88
    4
    This appears to be resolved now. I added a 1uf electrolytic capacitor from the sensor lead to ground. I also used shielded cable for the sensor leads from the heat plate to the Arduino. That brought the temp variation down to .7 to .9 degrees C and it is still responds plenty fast enough to work in this application. I added the software filter at 95% and that brought it down to almost nothing and it still responds fast enough. . I have a very stable temp reading now. Time to work on my PID control.

    Thank you all for the suggestions and help.
     
  20. Andrei Suditu

    Member

    Jul 27, 2016
    51
    6
    You could use an RC filter with a cutoff way lower than 60hz.
    Try a 220ohm resistor and a 47uF cap.
    Cutoff would be at ~15Hz.
    If does not work good enough lower the cutoff freq by increasing R.
    If not good enough try other sensing method.....like Supply the resistor with a constant current and measure the voltage.
    REF 200AU is a constant cuurent source of 100uA.Your 100k val of the sensor is a bit high since it will give 10V and will probably need buffering in your configuration since when you will measure with an ADC it will pull the voltage a bit down.
    So try a CC source and read the value affter you buffer it with an opamp voltage buffer.
     
Loading...