Go Down

Topic: LCD freaks out when relay pulls (Read 847 times) previous topic - next topic

Skitskraj

Quote
Using that algorithm after the relay activation would have to be followed by the rest of the initialization procedure.
That is part of the algorithm, no? Point 5 in the algorithm.

Quote
No, it didn't help you, possibly because you didn't do it correctly.
Yes possisbly, but also I think all other people with similar issues that I've found on forums haven't managed to solve it by hardware changes either. Then none of them have done it correctly either. Anyway, the software change is extremely simple and actually works, so I think it should also be one of the "standard answers" to these kind of problems.

cattledog

#16
Jan 20, 2017, 05:23 pm Last Edit: Jan 20, 2017, 05:23 pm by cattledog
Quote
What you are doing is delaying the sending of any commands by the LCD controller until after those transients have died down.
What happens with any unchanging information written in setup() when you use this method? I thought the display controller memory was getting scrambled, and the gibberish on the display was independent of any new data being written.


bodmer

#17
Jan 20, 2017, 09:11 pm Last Edit: Jan 20, 2017, 09:28 pm by bodmer
I've built a thermostat that works as I want it, except that the LCD goes bananas sometimes (not always) when the relay switches between on and off (which connects/disconnects a freezer). Thought I'd post it here, to see if anyone else has seen this kind of behavior (see attachement).

The problem is not with the LCD, the likely cause is that you are using a relay without proper contact arc suppression. The problem is worse because you are driving a highly inductive load (the freezer).  Although you might expect the relay to provide galvanic isolation, in the electromagnetic higher frequency domain the noise can couple into your circuit by many parasitic paths, especially if it has been built with long wires and inadequate grounding.

Without adequate suppression a seismic burst of electrical noise is being coupled into your driving curcuit (Arduino + LCD) when the relay changes state. The amount of noise will depend on when the relay opens/closes in the mains sinewave cycle. The inductive load multiplies the problem greatly because trying to stop a current flowing in an inductor is like expecting to stop a flywheel rotating at high speed instantly, which it does not want to do!

In cases where the electrical noise induces a differential voltage on the power supply rails, then decoupling hides the problem well, but in the decoupling world bigger capacitance is not always better as the ESR (Effective Series Resistance) increases with capacitance and thus high frequencies are not decoupled.  This is why in digital systems a combination on capacitors is used, 1nF, 10nF and 100nF for the really high frequency decoupling, and bulk capacitors starting at 47uF deal with the low frequencies.

In cases where the electrical noise induces voltages on data lines then this messes up any communication that is happening at the time. In this case decoupling on the power rails has little effect.  Inserting a delay after switching the relay is simply ensuring no communication occurs during the electrical "storm" that occurs when the relay changes state.

Note that the root cause has not been fixed by inserting a delay, it is just stopping the noise from affecting communication by ignoring it for a while. This is a bit like driving a car and finding you hear a loud bang when the brakes are put on, the solution is not to get some ear plugs and carry on driving!

Without investigating the real cause, the reliability of the thermostat will be poor, eventually the relay will fail due to the lack of suppression (causing arcing at the contacts) and potentially the freezer will either stay on (welded relay contacts) or more likely will not get switched on (burnt out contacts).





Formerly Rowboteer (now a broken user profile!)

Skitskraj

#18
Jan 21, 2017, 09:42 pm Last Edit: Jan 21, 2017, 09:47 pm by Skitskraj
What happens with any unchanging information written in setup() when you use this method? I thought the display controller memory was getting scrambled, and the gibberish on the display was independent of any new data being written.


No it seems the display moves to incorrect state. After some more relay activation it happens that it jumps back to the correct state again.

Quote
Note that the root cause has not been fixed by inserting a delay, it is just stopping the noise from affecting communication by ignoring it for a while. This is a bit like driving a car and finding you hear a loud bang when the brakes are put on, the solution is not to get some ear plugs and carry on driving!
Well the option of placing capacitors everywhere is also just preventing the noice from reaching the microcontroller, plus it doesnt really seem to work for anyone :P
The only way to fix the spark in the relay is to like add some complicated timing so that it only breaks the current at zero-crossing, or does these arc suppressor prevent the arc, or just prevent the disturbance from reaching outside the relay?

bodmer

Well the option of placing capacitors everywhere is also just preventing the noice from reaching the microcontroller, plus it doesnt really seem to work for anyone.
As stated, it does work if the problem is noise on the supply rails. Mostly these problems are due to poor design practices, poor routing of wires and not taking EMC effects into consideration.

The only way to fix the spark in the relay is to like add some complicated timing so that it only breaks the current at zero-crossing, or does these arc suppressor prevent the arc, or just prevent the disturbance from reaching outside the relay?
Read up about suppression of relay contacts. There are suppression devices cheaply available that will fix your problems in the correct way, these are commonly used in industry.

Consider the cost when the thermostat fails  :(
Formerly Rowboteer (now a broken user profile!)

AmmoMFG

There are a few different ways you can solve this problem. I don't know what kind of relay you are using, however if it's a mechanical type (coil) EMF from your coil may very well be your problem putting noise back into your system. In all cases, I would definitely recommend putting a diode across the relay (reversed) and or using an opto-isolator.

A simpler solution rather than using a mechanical relay is to use a SSR (this may be what you're using without knowing it) the Solid State Relays should not give you this issue, I have used the cheap amazon $10US ones to control some pretty hefty loads (an induction furnace, among others) without having to deal with any noise coming back into my system. To my knowledge most of these devices already include an opto-isolator, and can be driven at a few mA.

This could be the other possible problem and that is if you're using a mechanical relay you may be over-taxing your power supply and the output leads of your MCU, and when you change states (turning relay on or off) it's simply drawing more current than is available. Your display is dependent on your clock, and it could be missing clock cycles if supply voltage to the MCU goes low enough.

Ok, So I went back and looked at your diagram again, the Keyes SR1Y does have a suppression diode on it, and it looks like it probably uses some variety of darlington to boost the switching current for the relay.

I'll be honest, I'm a bit suspicious about this component still, and 10A seems a bit light for the switching currents a major appliance like a freezer can generate.

I looked over your code, and didn't see anything that stuck out as an obvious problem.

The other thing I would suggest you check out, for the mains power, there is a +AC rail, and a neutral (unless it's a High voltage single phase ~220VAC in the US) make sure your relay is switching the +AC and not the neutral. In most cases either will shut the load down, but from an electrical safety perspective, you always want to remove the source, and not the neutral.

If you're up for it, look on amazon for the ANV SSR-25DA. This should be a drop-in replacement for your existing relay, (just hook up the control wires) and it's good for 380VAC@25A.

Go Up