PDA

View Full Version : Chattering relay



Ioannis
- 22nd February 2018, 23:51
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.



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

richard
- 23rd February 2018, 00:19
the obvious way is note when a relay state change occurs
then inhibit any further state change until a determined period has elapsed

pedja089
- 23rd February 2018, 00:22
Hysteresis, maybe?

Ioannis
- 23rd February 2018, 01:08
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

picster
- 26th February 2018, 17:51
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.



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:



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

Ioannis
- 26th February 2018, 20:56
Thanks picster.

What I finally did is this:



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

picster
- 27th February 2018, 13:11
VERY slick solution. Great for reference for cases where hysteresis is needed, thanks for sharing!

Picster

Ioannis
- 27th February 2018, 13:36
Thanks picster. It works very reliable, especially in my case where the value does not change too quickly.

Ioannis

amgen
- 27th February 2018, 16:08
I see your software worked but you might need more capacitor filtering of the A/D voltage input, especially when operating relay

Ioannis
- 27th February 2018, 20:34
I always do Averaging or Darrels Analog Oversampling from 12 to 14 bits. 16 bits is better of course but takes too long.

Ioannis

andywpg
- 4th March 2018, 16:15
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