CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

How to avoid chattering of relay?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Sid2286



Joined: 12 Aug 2010
Posts: 119

View user's profile Send private message

How to avoid chattering of relay?
PostPosted: Mon Dec 12, 2011 1:43 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Dec 12, 2011 7:05 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Dec 12, 2011 7:24 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Dec 13, 2011 7:13 am     Reply with quote

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

View user's profile Send private message

Re: How to avoid chattering of relay?
PostPosted: Tue Dec 13, 2011 9:20 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group