Go Down

Topic: Programmable Thermostat, Light Dimmer System (Read 7440 times) previous topic - next topic

necouchman

Not sure if this is the place to post these questions, but it seemed the best to me.  I have two separate things I'd like to do with the Arduino that I need a little help figuring out...

The first is a programmable and computer-controllable thermostat.  I have a few issues here.  First, I need the thermostat to keep a day/hour/minute clock and I'm not sure about the best way to do that.  Second, I'm guessing I'll be using relays to control the signals sent to the HVAC units.  Apparently there are four wires - a 24V DC supply from the HVAC transformer and then three signal wires - one for the A/C unit, one for the heater, and one for the fan.  When you close the 24V DC to any of the three control wires, it turns on that  HVAC function.  So, I need relays to control the 24V DC with the signal off the Arduino, correct?

The second thing I'd like to do is a computer and/or button controllable light dimming system.  I have a room with 8 x 120V lighting circuits (probably 600 - 1000W per circuit).  I'd like to build a sort of a small-scale theatre control system, where the Arduino unit itself has two buttons - that will turn on five of the 8 channels to a certain brightness level and one that will turn on all channels to full brightness - and then the USB-connected computer will allow individual channel control.  The code for this is not a problem - what I don't know I'm sure I can find on the Arduino tutorial site, but I'm wondering if anyone knows where I would start on any sort of relay/dimmer system that could interface between the Arduino and the 120V 20A lighting circuits.

Thanks - nick

BigMike

Quote
 The code for this is not a problem - what I don't know I'm sure I can find on the Arduino tutorial site, but I'm wondering if anyone knows where I would start on any sort of relay/dimmer system that could interface between the Arduino and the 120V 20A lighting circuits.


Thyristors and triacs are frequently used for AC light dimming.

This page: http://www.allaboutcircuits.com/vol_3/chpt_7/5.html seems pretty comprehensive.

I have heard of a light dimmer kit available (I believe it was an Elektor kit) that has an analogue input to control brightness which may prove to be suitable.

Mike


BigMike

Quote

First, I need the thermostat to keep a day/hour/minute clock and I'm not sure about the best way to do that.  


There are a number of real time clock chips around that use a two or three wire interface. This one for example: http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2686 though there are others. Just add a 32kHz crystal and a battery and you're good to go.


Quote
Second, I'm guessing I'll be using relays to control the signals sent to the HVAC units.  Apparently there are four wires - a 24V DC supply from the HVAC transformer and then three signal wires - one for the A/C unit, one for the heater, and one for the fan.  When you close the 24V DC to any of the three control wires, it turns on that  HVAC function.  So, I need relays to control the 24V DC with the signal off the Arduino, correct?


This sounds correct. There are many miniature relays around that could switch 24V. The real question is what load is being swithed - ie how much current is drawn. You will probably need a little transistor between the Arduino and the relay coil, though.

You can always test the how circuit works as you expect by wiring toggle switches and putting an ammeter in series with the switch.

Regards,

Mike

TylerW

Quote
The code for this is not a problem - what I don't know I'm sure I can find on the Arduino tutorial site, but I'm wondering if anyone knows where I would start on any sort of relay/dimmer system that could interface between the Arduino and the 120V 20A lighting circuits.


This might work:  http://www.hoelscher-hi.de/hendrik/english/switch.htm down near the bottom of the page it shows the schematic for the power unit.  You may be able to modify is to work with an analogue arduino output.  If you are eventually going to control a lot of lights you may want to include a dmx type controller as shown on the top of the page.

Let me know how you make out with your small home automation project, I am very untested in building the same thing for myself.

sp

Did you get anything working re dimming lights ? interested to know details of what you did in the end.., and anything can advise for controlling brightness of lights in a room space via computer/sensors

thanks

pwillard

#5
Nov 18, 2008, 05:02 am Last Edit: Nov 18, 2008, 05:05 am by pwillard Reason: 1
You could have the arduino control X-10 based dimmers with an OEM interface.  ftp://ftp.x10.com/pub/manuals/technicalnote.pdf

http://www.arduino.cc/en/Tutorial/X10

noenoe

I found this article, which is a tutorial covering both the circuit part, and the overall strategy for the software part. I may be a good foundation to a software controlled dimmer using two digital I/O.

In this circuit there is no analog part, just timing of the firing of a triac (through opto isolation). This makes the circuit part very simple.

Ther is a circuit diagram as well as C-code for a PIC controller.
It should be possible to convert this to a program on the Arduino.

http://www.andrewkilpatrick.org/blog/?page_id=445

Sadly I dont have much time, so : if you try this out before I do (which is very likely), please post a note and maybe your code and hardware descriptions (images, pcb-files etc).


noenoe

Well, I could not help but try to mix a little code for this. The code is not testet in any way, and may not function at all - maybe the concpet is all wrong.

But, here it is, please let me know if this is the right way to go about it, or if you would do otherwise?

Code: [Select]
// AC dimmer with zero-crossing detection
// First edition by Niels Oestergaard
// !!!!!!!! not verified !!!!!!!!!!!!!
// based on design Andrew Kilpatricks tutorial: http://www.andrewkilpatrick.org/blog/?page_id=445

//strategy for dimming part of the sketch:
//
// set counting interval to reach 255 in one half-period (50 hz = 10 millis pr. half-period / 60 Hz 8.3333333333333 pr. halft periode )
// set output to 0 - 255
// detect zero crossing (on interrupt pin)
// in interrupt rutine calculate time for turning on
// when millis reaching time, turn on for a short while
// turn output off to be sure not to trigger to early in next halfperiod

// interrupt 0 - (pin 2)


int dimmer1Pin = 10;             //output to opto triac (MOC 3010/3020)
int ledPin = 13;                 //reserved for sanity check and visual feedback
volatile int freqAdjTime = 20;   //set to 10 for 50 Hz, and 8 for 60 Hz
volatile long nextOnTime = 0;    // variable for storing a time (in millis) for when to fire the output next
volatile int outputValue;        // Varialble for storing the output value 0-255
//unsigned int inputValue;       // Variable for storing input value (ie. a potentiometer)
long lastMillis;                 // for timing purposes


void setup()
{
 pinMode(ledPin, OUTPUT);      // sets the digital pin as output
 // sanity check
 digitalWrite(ledPin, HIGH);
 delay(500);
 digitalWrite(ledPin, LOW);
 delay(500);  
 digitalWrite(ledPin, HIGH);
 delay(500);  
 digitalWrite(ledPin, LOW);
 // end of sanity check
 attachInterrupt(0, zero, RISING); //Attachment of zero crossing detection, which means the interrupt rutine "zero" is called each 20 millis
}

void loop()
{
//  
 if (nextOnTime < millis()) {         //is it time to set pin on?
   digitalWrite(dimmer1Pin, HIGH);    // then set it
   delay(2);                          // wait a bit to be sure the triac is on
   digitalWrite(dimmer1Pin, LOW);     // turn of the trigger to be sure it is not trigger in the very beginning of next halfperiod
 }
 
// A loop that slowly increases outputvalue
if (millis()-lastMillis > 250 ) {       //increase output each fourth of a second
   outputValue++;                      //increase outputvalue by one
   
   //Check if max is reached
   if (outputValue  > 255) {           // output = maximum
       outputValue = 0;                // set output to zero
   }
 }
}

void zero()
{
// set a volatile variable with the millis value + (the value of the desired output (0-255) multiplied by the freq adj time)
nextOnTime = millis() + (freqAdjTime * outputValue); //how long will this calculation take? too long to enable low output??
}


ryanjmclaughlin

I tried this code with no luck, I just get the light steady on...  any other ideas to try?

noenoe

Hi Ryan

Could you post a schematic for your circuit?

Do you have a scope, freq.counter or just a digital probe to very that the opto-triac is fired.

It might be at timing problem. As mentioned, the code is not verified in any way, and I guess it will be a couple of weeks before I am able to mock up a circuit and start testing.

A quick glance on the code revealed at least one bug: the loop that is to rise slowly from 0 to 250 is faulty. There is no line setting the value of lastMillis..

I guess a simpler test without this loop, and with a hardcoded outputValue could be first step.
Maybe a loop reading an analog input mounted with a potentiometer (remeber to divide the value by 4 or some other conversion: analog input is 0-1024 and the calculations for timing is 0-255 for 50Hz)

Let us know if you get it up and running

ryanjmclaughlin

I am fairly sure it is a timing issue or my interrupt is not working properly.

I tried coding from scratch and was still having problems.  See http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1230333861

I got it working for a bit, but just for a few flickers.  Then the whole thing seems to "lock up".  Not sre what is going on.


ryanjmclaughlin

So,  I managed to snag an old scope from work to verify a few things, and indeed the freq is 8.3 ish uS  AND the interrupt pin is outputting what I want it to...  However, there is one difference than the schematic.  I am using a H11AA1 instead of a 4N25.

Here are the picures if you are interested of the different scope output http://picasaweb.google.com/ryanjmclaughlin/NerdyStuff?authkey=3HlunapsF6k#

I am going to work on adjusting the code tomorrow.  I think I was firing the triac too late to dim...  will look into it tomorrow and report back.

Inizul

#12
Jul 07, 2010, 09:21 am Last Edit: Jul 07, 2010, 09:29 am by inizul Reason: 1
Hello everyone,
In the blog "Txapuzas Electrónicas" there are two available circuits
http://txapuzas.blogspot.com/p/indice-de-txapuzas-electronicas.html

Relay output card
http://txapuzas.blogspot.com/2010/07/rele-controlado-por-transistor.html


and

Power control with triac (8 levels of regulation)
http://txapuzas.blogspot.com/2010/06/regulador-de-potencia-por-triac-para.html


The blog is in Spanish, but well documented.

Regards





jonesangela

#13
Nov 10, 2010, 03:41 pm Last Edit: Nov 10, 2010, 03:42 pm by jonesangela Reason: 1
Well, that is might be a timing problem you mentioned the code is not verified in any way. It will be a couple of weeks before able to mock up a circuit and starting testing. In a quick glance on code revealed at least on bug in the loop that is not rise slowly from 0 to 250 in fault.

My TV shows Thermostat

Go Up