View previous topic :: View next topic |
Author |
Message |
Sid2286
Joined: 12 Aug 2010 Posts: 119
|
How to avoid chattering of relay? |
Posted: Mon Dec 12, 2011 1:43 am |
|
|
Hi,
I have written a code wherein I set the on/off condition,
once the process value reaches the defined on or off state the relay is suppose to turn off or turn on.
However, when the process value is close to the defined state, the relay starts to chatter.
I have taken care of adding diode to avoid freewheeling condition, but i dont know how to avoid hysteresis through program.
please guide.
Sid |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Mon Dec 12, 2011 7:05 am |
|
|
I think you need to ADD hysteresis to stop the relay chattering. Move your setpoint up or down based on the output state. Either that or slow your loop rate so the output is only updated every few seconds. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Mon Dec 12, 2011 7:24 am |
|
|
Since you're using a mechanical relay, the 'process' isn't all that critical to timing or setpoint ,so do all that SherpaDoug suggests.
Typical home heating thermostats have a 1*C hysterisis(2*F) built in,sampling once per second( clock update rate).
You might require different hysterisis values for the positive ramp, versus negative, all depends on what you're trying to accomplish. |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Tue Dec 13, 2011 7:13 am |
|
|
Hi,
As others have stated, you need to add some hysteresis to your control equations to prevent the relay from chattering. The problem is that your 'Process Value' is varying slightly about the Turn On/Turn Off point, and is causing the problem. So, to solve your problem, the ON point should not be the same as your OFF point!
I have a relatively simple terrarium heater control that has 2 degrees F of hysteresis between the On temperature and the Off temperature, so the relay switches at a different point "on the way up", as it does "on the way down". I use code like this to make that happen:
Code: |
if (TempF[0] >= (SetPoint + 1)
if (TempF[0] <= (SetPoint - 1)
|
John |
|
|
sahu77
Joined: 08 Sep 2011 Posts: 202
|
Re: How to avoid chattering of relay? |
Posted: Tue Dec 13, 2011 9:20 am |
|
|
Sid2286 wrote: | Hi,
I have written a code wherein I set the on/off condition,
once the process value reaches the defined on or off state the relay is suppose to turn off or turn on.
However, when the process value is close to the defined state, the relay starts to chatter.
I have taken care of adding diode to avoid freewheeling condition, but i dont know how to avoid hysteresis through program.
please guide.
Sid
|
For better response post here your code. _________________ sahu |
|
|
|