Arduino - Smoothing Capacitor for 24Vac (Thermostat)?

 
User avatar
CoalisCoolxWarm
Member
Posts: 2323
Joined: Wed. Jan. 19, 2011 11:41 am
Location: Western PA
Stoker Coal Boiler: Keystoker KA-6
Hand Fed Coal Furnace: old Sears rebuilt, bituminous- offline as of winter 2014
Coal Size/Type: Anthracite Buckwheat
Other Heating: Oil Boiler

Post by CoalisCoolxWarm » Mon. Dec. 26, 2016 2:45 pm

Probably a simple question for those who know ;)

I am using an optoisolated IC to detect 24vac, which closes a 5vdc set of pins that I am detecting with an Arduino Mega 2560.

It works fine, MOST of the time.

But about 8 times out of 100 it will flip-flop on the Arduino side. Yes, I've debounced the digital input, which does make it better, but it's my thermostat detector and I want it 100%, not turning on a zone for 1 sec as it cycles through the loop :shock:

Obviously I have chosen the optoisolator IC instead of rectifying and then dividing the voltage and I'd like to stay with this method... which leads me to my question.

WHAT Capacitor/circuit would you recommend on the 24vac side to prevent the flip flop on zero crossing?

I currently have 2x 22k 1/4 watt resistors in parallel (I didn't have higher power ones here) to limit the current.

The IC detects up to 220v with proper resistors, uses two opposing internal LEDs for the optoisolation. So I don't mind if BOTH LEDs overlap, just no dark moments.

My inexperience at circuit design is showing :oops:

Any tips would be most appreciated.


 
titleist1
Member
Posts: 5226
Joined: Wed. Nov. 14, 2007 4:06 pm

Post by titleist1 » Mon. Dec. 26, 2016 3:57 pm

I am an arduino newbie (only one halloween prop project) and I am sure have less circuit design know how than you - but could you program a short delay then a second read of the DI before triggering the DO in the arduino program to filter out the effect of the false trip at the zero crossing?

Just curious why you are locked into using the optoisolator IC. I used interposing relays with the appropriately rated coil voltage and I am wondering what I am missing out on!

 
User avatar
Rob R.
Site Moderator
Posts: 17977
Joined: Fri. Dec. 28, 2007 4:26 pm
Location: Chazy, NY
Stoker Coal Boiler: EFM 520
Hand Fed Coal Stove: Chubby Jr

Post by Rob R. » Mon. Dec. 26, 2016 3:59 pm

I do not think I have ever seen another post on this forum with so many words I do not know. :shock:

 
User avatar
CoalisCoolxWarm
Member
Posts: 2323
Joined: Wed. Jan. 19, 2011 11:41 am
Location: Western PA
Stoker Coal Boiler: Keystoker KA-6
Hand Fed Coal Furnace: old Sears rebuilt, bituminous- offline as of winter 2014
Coal Size/Type: Anthracite Buckwheat
Other Heating: Oil Boiler

Post by CoalisCoolxWarm » Mon. Dec. 26, 2016 4:42 pm

Here is the debouncing setup I'm using in code: http://forum.arduino.cc/index.php?topic=266132.0 Yes, it does read, delay, read. But if I can condition the input side, then I only have to account for normal Arduino bouncing (crazy boards), and make sure I decouple my ICs as any circuit grows.

Relays are one method, but expensive and bulky for my needs.

I want to stay with optoisolation because it keeps the entire 24vac site 100% separate from the logic side. Cost and complexity is much less with the IC handling some functions for me.

Rob- It gets better, LOL. Not too bad once you get the basics down, but some real gotchas for newbies to circuit designs.

The chip I'm using uses (in this case) 24vac of the thermostat line to light a very tiny LED inside the chip. LEDs only work in one direction, so on its own it would only light on either the top or bottom of the AC sine wave. So the chip includes a second one on the other half of the AC circuit (in reverse) so that one of them will be lit up any time there is AC power on the line.

The other side of the chip is a tiny detector that sees the LEDs light up and closes an internal switch between two legs on the logic side, completing a DC circuit. Because there is no physical connection between the separate electrical paths, there is no chance of short circuits or AC getting on a DC line (poof!) or DC causing interference on the AC line (malfunctions).

Since the method involves Optical emission and detection, the circuit is said to be Opto-Isolated (and derivatives of that term are acceptable)

The Arduino has digital input pins than can detect this circuit because it has a tiny amount of power that goes through the chip's two legs when closed and passes through a resistor to ground. The resistor prevents a dead short when the circuit is closed (like putting a screwdriver across battery terminals would be :shock: )

The problem is where the top half of the AC sine wave drops from positive to negative. It must cross the zero voltage line, aka "zero crossing." It is at this point that NEITHER LED is lit up. So it has a little internal flicker.

This causes the output on the logic side to have matching gaps, aka pulses or ripple.

To complicate things, the circuit is pulsing twice in a cycle, which is 60 times per second, making it 120 times per second that it will be at zero (plus a little padding). The Arduino reads the digital input at some frequency that depends on the chip frequency, the circuit, the program running, etc etc etc.

MOST of the time the Arduino will miss the zero crossing, but once in a while it will hit it.

A debounce software method most often will read, make a small delay and read again, returning a "my switch changed state" message only if they match. This method helps a great deal because the odds of hitting that zero crossing corridor twice in a row get much smaller. But the chances are not zero.

Now...

Rectifying an AC circuit is just a fancy way of saying you are chopping off one half of the sine wave, usually to convert it to DC. For this example, let's say we are keeping the top half and cutting off the bottom half.

We use a diode (not Light Emitting Diode, but it could be), which act as one-way check valves. They block flow in the backwards direction and permit flow in the forward direction- when the "pressure" on the other side of the check valve drops. Just like hydronic systems.

So once we've eliminated the "backwards" part of an AC circuit, we have little one way pulses. But for DC, we usually want one way SOLID current without pulses. Enter the capacitor.

Capacitors are like little stateful batteries. They charge when there is power and once the circuit drops, it discharges its stored power into the circuit. The use we are discussing here is their ability to "bridge" or "power" a circuit during very short outages...like pulses.

The capacity, type, and power rating of a capacitor has to be appropriate for the circuit so that it will bridge the gap between pulses without dropping too low (which would be seen as an outage pulse by the circuit), but not so large that it powers the circuit too long and we miss a proper drop when the circuit is turned off on purpose.

Making a mistake either doesn't work properly, or it releases the magic smoke inside all electronics, LOL.

****

I don't want to have any chances of shorting either side of the circuit. I don't want any chance of interfering with the 24vac side. It takes just an extra pair of wires attached to anywhere in the thermostat circuit to detect when a thermostat is closed, without any impact on the system (50ma won't be noticed)

I am not expert at selecting capacitors. I've read it is common to specify at least 2x the expected voltage. For an electronics guru, this is a very normal and simple day to day thing. I'm hoping one will lend his expertise here so I don't make a mistake.

Edit to add: Once rectified, then the voltage would have to be adjusted from 24vdc down to 5vdc. The 24vac input is often 29-31vac, so it takes some caution, usually a voltage divider- or better, a regulator. When I re-read my post, I forgot this part.

Make sense?
Last edited by CoalisCoolxWarm on Mon. Dec. 26, 2016 4:53 pm, edited 3 times in total.

 
User avatar
CoalisCoolxWarm
Member
Posts: 2323
Joined: Wed. Jan. 19, 2011 11:41 am
Location: Western PA
Stoker Coal Boiler: Keystoker KA-6
Hand Fed Coal Furnace: old Sears rebuilt, bituminous- offline as of winter 2014
Coal Size/Type: Anthracite Buckwheat
Other Heating: Oil Boiler

Post by CoalisCoolxWarm » Mon. Dec. 26, 2016 4:43 pm

titleist1 wrote:I am an arduino newbie (only one halloween prop project)
Got a link? Or send me some pics? I always appreciate others' creations 8-)

 
User avatar
freetown fred
Member
Posts: 30293
Joined: Thu. Dec. 31, 2009 12:33 pm
Location: Freetown,NY 13803
Hand Fed Coal Stove: HITZER 50-93
Coal Size/Type: BLASCHAK Nut

Post by freetown fred » Mon. Dec. 26, 2016 4:57 pm

Huh????????????????????????????????????????? :woot: :clap: toothy

 
User avatar
CoalisCoolxWarm
Member
Posts: 2323
Joined: Wed. Jan. 19, 2011 11:41 am
Location: Western PA
Stoker Coal Boiler: Keystoker KA-6
Hand Fed Coal Furnace: old Sears rebuilt, bituminous- offline as of winter 2014
Coal Size/Type: Anthracite Buckwheat
Other Heating: Oil Boiler

Post by CoalisCoolxWarm » Mon. Dec. 26, 2016 5:01 pm

freetown fred wrote:Huh????????????????????????????????????????? :woot: :clap: toothy
Pay attention, Fred, this will be on the test. toothy LOL.


 
titleist1
Member
Posts: 5226
Joined: Wed. Nov. 14, 2007 4:06 pm

Post by titleist1 » Mon. Dec. 26, 2016 5:12 pm

You've probably already seen this on the arduino forum describing a circuit very much like you are doing. they indicate a 35V 100microF capacitor would work along with a couple resistors and a diode to fill in the zero crossing.

http://forum.arduino.cc/index.php?topic=20102.0
CoalisCoolxWarm wrote:Got a link? Or send me some pics?
I'll post a video when I get it done. Its a groundbreaker prop, the arduino is motion triggered and controls sound, lights and arm motions. I have the programming done, but will probably adjust the relay timing once I see it in action to maximize the creepy factor. I have the prop frame done but I am waiting on a couple fittings to connect up the solenoids to the cylinders for the movement. One thing I am scratching my head on now is how to package the boards and wiring, its just breadboarded and spread out on the workbench now.

 
User avatar
CoalisCoolxWarm
Member
Posts: 2323
Joined: Wed. Jan. 19, 2011 11:41 am
Location: Western PA
Stoker Coal Boiler: Keystoker KA-6
Hand Fed Coal Furnace: old Sears rebuilt, bituminous- offline as of winter 2014
Coal Size/Type: Anthracite Buckwheat
Other Heating: Oil Boiler

Post by CoalisCoolxWarm » Mon. Dec. 26, 2016 5:23 pm

titleist1 wrote:You've probably already seen this on the arduino forum describing a circuit very much like you are doing. they indicate a 35V 100microF capacitor would work along with a couple resistors and a diode to fill in the zero crossing.

http://forum.arduino.cc/index.php?topic=20102.0
Yeah, but that is rectified and then using the resistors as voltage divider. Okay as a one-off, limited use, but I'm looking to be more cautious.
I'll post a video when I get it done. Its a groundbreaker prop, the arduino is motion triggered and controls sound, lights and arm motions. I have the programming done, but will probably adjust the relay timing once I see it in action to maximize the creepy factor. I have the prop frame done but I am waiting on a couple fittings to connect up the solenoids to the cylinders for the movement. One thing I am scratching my head on now is how to package the boards and wiring, its just breadboarded and spread out on the workbench now.
Cool! Can't wait to see it!
Check your PM

 
User avatar
CoalisCoolxWarm
Member
Posts: 2323
Joined: Wed. Jan. 19, 2011 11:41 am
Location: Western PA
Stoker Coal Boiler: Keystoker KA-6
Hand Fed Coal Furnace: old Sears rebuilt, bituminous- offline as of winter 2014
Coal Size/Type: Anthracite Buckwheat
Other Heating: Oil Boiler

Post by CoalisCoolxWarm » Mon. Dec. 26, 2016 9:58 pm

I think the 5v side will be better to smooth the signal...

 
User avatar
Rick 386
Member
Posts: 2508
Joined: Mon. Jan. 28, 2008 4:26 pm
Location: Royersford, Pa
Stoker Coal Boiler: AA 260 heating both sides of twin farmhouse
Hot Air Coal Stoker Stove: LL Hyfire II w/ coaltrol in garage
Coal Size/Type: Pea in AA 260, Rice in LL Hyfire II
Other Heating: Gas fired infared at work
Contact:

Post by Rick 386 » Tue. Dec. 27, 2016 8:19 am

freetown fred wrote:Huh????????????????????????????????????????? :woot: :clap: toothy
Hey F-fred,

As soon as they get this ironed out, I'm sure they make one for your Hitzer !!!! :out:

Rick

 
titleist1
Member
Posts: 5226
Joined: Wed. Nov. 14, 2007 4:06 pm

Post by titleist1 » Tue. Dec. 27, 2016 8:52 am

Rick 386 wrote:
freetown fred wrote:Huh????????????????????????????????????????? :woot: :clap: toothy
Hey F-fred,

As soon as they get this ironed out, I'm sure they make one for your Hitzer !!!! :out:

Rick
F-Fred's will be the super deluxe Freetown Hill version that not only controls the Hitzer but also warms up the plow truck!! :notworthy:

 
User avatar
BunkerdCaddis
Member
Posts: 708
Joined: Sun. Jan. 18, 2015 10:26 am
Location: SW Lancaster County
Stoker Coal Boiler: Bairmatic-Van Wert
Hand Fed Coal Boiler: Van Wert VW85H
Hand Fed Coal Stove: Saey Hanover II working when I feel the desire, Waterford 105 out on vacation, Surdiac Gotha hiding somewhere
Coal Size/Type: pea/nut/rice/stove-anthracite, nut/stove bit when I feel the urge
Other Heating: oil fired hydronic

Post by BunkerdCaddis » Tue. Dec. 27, 2016 9:03 am

If I my ask... I understand just enough of the words to follow the conversation. Is there a bigger reason that you are using an Arduino to control your heating system or just because you can? I know they use them in solar systems and the like but I wouldn't have thought there was much to gain in a basic hydronic setup? :gee:

 
KLook
Member
Posts: 5791
Joined: Sun. Feb. 17, 2008 1:08 pm
Location: Harrison, Tenn
Other Heating: Wishing it was cold enough for coal here....not really

Post by KLook » Tue. Dec. 27, 2016 9:19 am

Thank you Bunker.....how bout some mercury in a glass tube??? Anyone? :shock:
I love technology but this is way out there. But sounds fun if you have the time to play. No different then the solar users in here just playing and experimenting with them. No ROI needed.
I was able to follow along mostly, but your explanation was excellent.

Kevin

 
titleist1
Member
Posts: 5226
Joined: Wed. Nov. 14, 2007 4:06 pm

Post by titleist1 » Tue. Dec. 27, 2016 10:08 am

I think I remember its part of a STEM project for school.


Post Reply

Return to “Coal Bins, Chimneys, CO Detectors & Thermostats”