Chattering relay


+ Reply to Thread
Results 1 to 11 of 11
  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,750

    Default Chattering relay

    Looking for ideas to eliminate chattering of my relays that are activated depending on the ADvalue that is read from the analog input.

    The Analog value is filtered through DT_Analog module (Analog oversampling to 12 bits).

    But on the decision point, relays are chattering on/off as the analog value is slow changing.

    Code:
    gosub getADC
        'ADvalue=abs (ADvalue-818)
        if ADvalue < upper then
            relay.0=1
        else
            relay.0=0
        endif
           
        if ADvalue < mid_upper then
            relay.1=1
        else
            relay.1=0
        endif
        
        if ADvalue < mid then
            relay.2=1
        else
            relay.2=0
        endif
        
        if ADvalue < mid_lower then
            relay.3=1
        else
            relay.3=0
        endif
        
        if ADvalue < lower then
            relay.4=1
        else
            relay.4=0
        endif
    Any ideas?

    Ioannis

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    1,511

    Default Re: Chattering relay

    the obvious way is note when a relay state change occurs
    then inhibit any further state change until a determined period has elapsed

  3. #3
    Join Date
    Sep 2009
    Posts
    677

    Default Re: Chattering relay

    Hysteresis, maybe?

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,750

    Default Re: Chattering relay

    Thanks.

    I tried hysteresis but there are 4 decision points and things are getting messy.

    I set up Timer 1, counting seconds. The main loop runs fast but the relays are set (or reset) only after the defined time delay, now 10 sec.

    Seems OK.

    Ioannis

  5. #5

    Default Re: Chattering relay

    Quote Originally Posted by Ioannis View Post
    Looking for ideas to eliminate chattering of my relays that are activated depending on the ADvalue that is read from the analog input.

    The Analog value is filtered through DT_Analog module (Analog oversampling to 12 bits).

    But on the decision point, relays are chattering on/off as the analog value is slow changing.

    Code:
    gosub getADC
        'ADvalue=abs (ADvalue-818)
        if ADvalue < upper then
            relay.0=1
        else
            relay.0=0
        endif
           
        if ADvalue < mid_upper then
            relay.1=1
        else
            relay.1=0
        endif
        
        if ADvalue < mid then
            relay.2=1
        else
            relay.2=0
        endif
        
        if ADvalue < mid_lower then
            relay.3=1
        else
            relay.3=0
        endif
        
        if ADvalue < lower then
            relay.4=1
        else
            relay.4=0
        endif
    Any ideas?

    Ioannis
    how about something like this for virtual hysteresis:

    Code:
        if ADvalue < upper then
            if upperbufferflag=0 then 'add the buffer only once
                upper=upper+upperbuffer:upperbufferflag=1
            endif
            relay.0=1
        else
            if upperbufferflag=1 then 'subtract the buffer
                upper=upper-upperbuffer:upperbufferflag=0
            endif
            relay.0=0
        endif
    
    (typical for each instance)

    picster

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,750

    Default Re: Chattering relay

    Thanks picster.

    What I finally did is this:

    Code:
     if ADvalue < upper-hyst then
                relay.0=1
            elseif ADvalue > upper+hyst then
                relay.0=0
            endif
    The user through menu, can set the hyst (hysteresis) window.

    Also the update of the relays is not done immediately but every xx seconds also user defined.

    Both these did the trick.

    Ioannis

  7. #7

    Default Re: Chattering relay

    VERY slick solution. Great for reference for cases where hysteresis is needed, thanks for sharing!

    Picster

  8. #8
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,750

    Default Re: Chattering relay

    Thanks picster. It works very reliable, especially in my case where the value does not change too quickly.

    Ioannis

  9. #9

    Default Re: Chattering relay

    I see your software worked but you might need more capacitor filtering of the A/D voltage input, especially when operating relay

  10. #10
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,750

    Default Re: Chattering relay

    I always do Averaging or Darrels Analog Oversampling from 12 to 14 bits. 16 bits is better of course but takes too long.

    Ioannis

  11. #11
    Join Date
    Jan 2012
    Location
    Grid EN19MV
    Posts
    156

    Default Re: Chattering relay

    The other option (just spitballing here) would be to put a cap across the coil. It slows down the coil release. Not very useful if you need the relay to release fast, but I have used it in a couple of oddball cases over the years.

    Andy
    "I have noticed that even those who assert that everything is predestined and that
    we can change nothing about it still look both ways before they cross the street"


    -Stephen Hawking

Similar Threads

  1. Question on Relay?
    By Megahertz in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 29th May 2010, 16:02
  2. PIC to Relay
    By Kalind in forum Schematics
    Replies: 14
    Last Post: - 24th January 2009, 02:53
  3. Relay
    By menta in forum General
    Replies: 14
    Last Post: - 1st October 2008, 16:04
  4. SPST Relay
    By docwisdom in forum Off Topic
    Replies: 2
    Last Post: - 15th June 2006, 00:16
  5. drive relay?
    By serdar_ozcan in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 26th November 2005, 12:01

Members who have read this thread : 26

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts