problem: Arduino reset by AC current transformer

I have a circuit that occasionally causes the Arduino to get reset. I have identified the problem area and I would like to get advice on the cause and how to fix it. The system is described below, and a schematic is attached.

My house is heated by “forced air with natural gas”. The basic control circuit runs on 24 VAC. In a normal heat cycle, when the thermostat (switch) closes the gas valve opens. The gas is ignited by a pilot light, and the bonnet warms. Soon thereafter a relay turns on a 110 VAC motor which drives a squirrel cage fan which distributes the heat throughout the house. The thermostat is a “set back” type which turns the heat down at night and up during the day. If the house is cold, such as when the heat first comes on in the morning, after the gas has been on for some time the bonnet may reach an “over temp” condition. This is a normal condition of systems of this design. When this condition occurs, a temperature switch in the bonnet (which is in series with the thermostat switch) opens. This causes the gas valve to turn off the gas. The bonnet cools as the fan continues to run. When the bonnet cools sufficiently the bonnet switch closes, and the gas value turns the gas on again. This cycle repeats until the thermostat switch opens when the house is up to the temperature set at the thermostat.

I want to measure the number and duration of the “over temp” cycles that occur.

The gas valve operates on 24 VAC and draws up to 500 mA according to the data plate.. I want to make as few wiring changes as possible. Also, I only have ready access to the wiring at the thermostat. The basic design is that the Arduino will detect 2 things: (1) when there is a 24 VAC potential across the thermostat switch (I will call this the Arduino “switch detection” part of the circuit),.and (2) when current is flowing in the thermostat circuit (I will call this the “current detection” part of the circuit). I have the system currently implemented on a breadboard with a couple of toggle switches and a sprinkler solenoid valve for a simulated gas valve.

Switch detection
An LED and current limiting resistor are connected across the thermostat switch. When the thermostat is open, the LED is illuminated. When the thermostat is closed, the LED is shorted out of the circuit. A photo cell (light dependent resistor) is placed next to the LED. The photo cell is connected to a digital input pin on the arduino. This part of the circuit is working well. (In an earlier design I used a voltage divider with a low voltage tap connected to an Arduino analog input. While this seemed to work ok, a respose on this forum advised against it, and also, I didn’t like the interconnection between the 24v system and the Arduino, so I changed the design to use this optical isolation).

Current detection
I made a current transformer with about 8 feet of twisted pair phone wire and a 2” diameter metal washer. I wrapped the wire around the washer in “donut” fashion (loops made by passing the wire through the center hole, then around the outside). There are about 80 loops. One wire of the pair (the primary, see schematic) is connected in series with the thermostat. The other wire of the pair (the secondary) is connected to an analog input pin of the Arduino. A 50 ohm burden resistor is connected across the secondary. When the 24v circuit is ON I measured about 49 mVAC on the secondary coil. I added a 1.5 v battery to raise the AC level above 0 for the Arduino input. I calculated the theoretical values that I expected to read on the AI pin. These values are very close to the actual values that the code reports.

The problem:
The circuit works great about 90% of the time. However, about 10% of the time, when I open the thermostat switch, the Arduino gets reset. The reset never occurs when I close the thermostat switch, and it never occurs when the bonnet switch is opened or closed. It only occurs when the thermostat switch is opened.

The reset is detected by observing output on the Serial port. The Setup routine writes a “startup” message, and this message occurs about 10% of the time when the thermostat switch is opened. The reset continues to occur if I disconnect one side (either side) of the current transformer. The reset does not occur if I remove both sides of the current transformer from the circuit.

I attempted to correct the problem by adding a diode in parallel with the burden resistor (shown in the schematic). This made no difference.

It is my guess that when the thermostat opens, and the magnetic field in the primary coil of the transformer collapses (and perhaps enhanced by the collapse of the field in the solenoid), a spike is occurring in the secondary which is affecting the Arduino. But I don’t have the equipment to measure and prove this theory. I also don’t understand why the problem is not seen when the bonnet switch is opened.

Can someone provide a better explanation of the problem and a suggestion for a fix?

currentDetector.pdf (48.8 KB)

Bit of an odd circuit. As I see it you have biased the AC input with a battery so you can read the whole of the AC waveform.

I would remove the diode and place a 0.1 uF cap across the battery.

I would also put catcher diodes to each rail from the analogue input.

An inductive spike could be transformed through your transformer that's used to measure current. The primary (switched side) could use an RC snubber.

On second thought, since you're only measuring about 49 mVAC on the secondary coil, I think connecting 2 diodes in reversed parallel would clamp any excessive voltage spikes to ±700mv (each direction).

Hi,

Can I suggest you use an OptoCoupler instead of your LED/LDR system, this will mean you have proper isolation.

A 0.1uF capacitor across each of the 24Vac switches to help reduce switching transients would be a good idea. (Not electrolytic or polarised types)

I'm surprised you didn't just use two OptoCouplers.


Using the logic of opto1 and opto2 you can tell when the thermostat turns the valve off or the bonnet turns the valve off.

Tom.... :slight_smile:

I made a current transformer with about 8 feet of twisted pair phone wire and a 2" diameter metal washer

You don't make transformer cores from solid iron, it doesn't work well. laminated core or ferrite are
the correct choices.

A current transformer needs a high step-up ratio in turns, 1:500 or something like that, not 1:1 - its
essential to make the secondary act like a short-circuit, so usually much less than one ohm per turn on
the secondary would be used. Otherwise you have something intermediate between a voltage transformer
and a current transformer.

Did you measure the ac voltage drop across the primary of your transformer? It should be tiny.

Did you check if there were dry (spare) contacts on the relay BTW?

Thank you for the comments.

Following the posted comments, I installed a 0.1 uF capacitor at all of the suggested points in the schematic. None of them made any difference to the Arduino resets. I also installed diodes as suggested, but these also had no affect on the resets. I actually expected this to fix the problem, but it did not. The resets continue to occur about 10% of the time when the thermostat switch is opened.

I am using a sprinkler solenoid valve as a simulated gas valve. I believe that this coil is causing the problem. If I use a resistive load I do not see the problem. But my target load (this project, or some next one) is likely to have a solenoid, so I would like to understand why I am getting these resets, and what to do to avoid them.

Does anyone know what causes the Arduino to reset? I am frustrated in not knowing what to go look for as the cause. Is it some "over voltage" detection in the Arduino?

Some people offered comments on a modified design. Here are the reasons for my design:

As I explained in the introduction, I only have access to the circuit at the thermostat. I do not have access to the bonnet switch. Therefore, I decided to detect current flow to determine when the bonnet switch is open or closed. I experimented with the DIY construction of a current transformer. I do not need a calibration of current – I only need to know if there is current flowing in the circuit, or not. I recognize that the "big washer" that I used is unconventional, but it is quite effective in detecting the flow of current, or not. MarkT said that this is not a current transformer. Ok, I can accept that. But it is pretty effective as a current flow detector. I have not seen a problem that I can attribute to this implementation. Is there something that I am overlooking? I experimented with several burden resistor sizes and ultimately chose 50 ohms. Other sizes did not have an effect on the reset problem.

I measured the voltage across the primary winding. It is, indeed, tiny. It is less than 0.4 volts (in the 24 VAC circuit).

There are no spare contacts on the relay, but I don't have access to the relay anyway, so it doesn't make any difference.

As I mentioned, the voltage in the secondary is about 49 mVAC. From other readings I was fearful of allowing a negative AC voltage to reach the analog pin of the Arduino. The recommendations were to raise the AC signal such that the minimum voltage is no less than 0. That is why I added the 1.5 VDC battery. I added it for the electrical reason, not a code reason. I do not need the DC bias in order to detect the current flow in the Arduino code. I could do that with a ½ wave input signal.

TomGeorge said: Can I suggest you use an OptoCoupler instead of your LED/LDR system, this will mean you have proper isolation.

I used an LED and a photo cell because I had these parts at hand, and they seem to work well. I don't understand the statement "… this will mean you have proper isolation". What is improper [electrical] isolation about the LED+photo cell? What am I missing? I recognize that it might be unconventional, but there is no electrical interconnection between the 24 VAC and the Arduino, so isn't the Arduino "isolated"?

As I said in the introduction, I only have access to the circuit at the thermostat. Therefore, I cannot install the suggested opto-couplers even if I had them.

Thanks again for the reviews.

Your homemade current sensor is creating inductive spike(s) when its primary is opened ... the spikes would get transformed to the secondary which is connected to the Arduino.

A dual opto isolated configuration would not provide this path (proper isolation).

Hi,
The arduino is resetting because it is getting a voltage spike on its 5V rail, this is coming from the valve solenoid when it turns off.
Sometimes the bonnet switch will turn off when the AC is at the peak voltage, the magnetic field in the solenoid collapses almost instantaneously generating a large back emf from the coil, this can be in the magnitude of 50 to 100V or more.

This spike can be induced in any wiring that runs parallel to the coil wiring.
So you may have to check your layout, of all wires going to the arduino and keep them away from the 24Vac wiring.

Why just the bonnet switch, I don't know, it may have burnt contacts.
I am surprised that the manufacturer has not fitted switch and coil snubbers.

Tom.... :slight_smile:

Spike free circuit?

As I said in the introduction, I only have access to the circuit at the thermostat. Therefore, I cannot install the suggested opto-couplers even if I had them.

Oh well, never mind. Are there only 2 connection points available - the ones across the thermostat switch or is there any more?

A proper current transformer doesn't create inductive spikes, its secondary is shorted out and no high
voltages appear anywhere.

I measured the voltage across the primary winding. It is, indeed, tiny. It is less than 0.4 volts (in the 24 VAC circuit).

As I mentioned, the voltage in the secondary is about 49 mVAC.

Then its definitely not behaving anything like a current transformer. The output voltage should be small
but the input voltage much smaller still. I repeat you don't make transformers from lumps of iron,
you use laminated silicon steel or ferrite. You also need to calculate if the core is in danger of saturation.

The basic principle of any transformer is that the ampere-turns of all the windings cancel out to nearly
zero, so for my 1:500 CT you would have 500mA in a 1 turn primary and -1mA in the 500 turn secondary.

With a 250 ohm burden resistor the secondary would show 0.25V and the primary 0.0005V (its actual
resistance may well dominate in fact).

If the burden resistor fell off the secondary voltage might rise to 100V or more, note.