Go Down

Topic: Relay Board Connection help (Read 12 times) previous topic - next topic

tranquills0

Okay if you have successfully connected your sensor shield to your relays and have been able to turn the relay off and on at will , how about adding a real time clock RTC so that you can have your various AC appliances turn off and on based upon the time of day using the RTC.

First of all you can get your RTC here:

http://arduino-direct.com/sunshop/index.php?l=product_detail&p=48

or here:

http://www.sparkfun.com/products/99


And you have instructions on how to set this up here:

http://arduino-info.wikispaces.com/RTC

(Please note the code on this page is missing // after the semi colons  ; so you will have to add // if you cut and paste the code.)


Here is a sample code that will turn on a single relay after 1 minute of elapsed time then turn it off after another minute has lapsed. (You can adjust the time for your situation).



#include<WProgram.h>
#include <Wire.h>
#include <DS1307.h>
int Relay_1 = 2;     // relay_1 will operate through pin #2
int tmin = 0;        // tmin is a variable for storing time in minutes.

void setup()
{
digitalWrite(Relay_1, HIGH);   // relay set as inactive at startup
pinMode(Relay_1, OUTPUT);      // pin  #2 set as output
Serial.begin(9600);

RTC.stop();
RTC.set(DS1307_SEC,1); //set the seconds
RTC.set(DS1307_MIN,0); //set the minutes
RTC.set(DS1307_HR,12); //set the hours
RTC.set(DS1307_DOW,5); //set the day of the week
RTC.set(DS1307_DATE,8); //set the date
RTC.set(DS1307_MTH,9); //set the month
RTC.set(DS1307_YR,11); //set the year
RTC.start();

}

void loop()
{

Serial.print(RTC.get(DS1307_HR,true)); //read and print the hour and also update all the values by pushing in true
Serial.print(":");
Serial.print(RTC.get(DS1307_MIN,false));//read and print minutes without update (false)
tmin = (RTC.get(DS1307_MIN,false));
Serial.print(":");
Serial.print(RTC.get(DS1307_SEC,false));//read and print seconds without update
Serial.print(" "); //some space for a more happy life
Serial.print(RTC.get(DS1307_DATE,false));//read and print date without update
Serial.print("/");
Serial.print(RTC.get(DS1307_MTH,false));//read and print month without update
Serial.print("/");
Serial.print(RTC.get(DS1307_YR,false)); //read and print year without update
Serial.println();
delay(1000);

if (tmin==1){
   digitalWrite(Relay_1, LOW);     // set the Relay ON after the 1st minute has elapsed
}
else {
}
if (tmin==2){
   digitalWrite(Relay_1,HIGH);    // set the Relay OFF after the 2nd minute has elapsed
}
else {
}
}


Enjoy,

s



tranquills0

#16
Sep 21, 2011, 04:20 pm Last Edit: Sep 25, 2011, 02:29 am by tranquills0 Reason: 1
For a very good view of the 4 channel relay and the three terminals marked NO, COM, and NC go here:

http://arduino.cc/forum/index.php/topic,71403.0.html

s

tranquills0

So what type of "relay" do you need for your application? There are 4 types of switching mechanisms to choose from:

1) electromechanical relays -While the mechanical construction of electromechanical relays allows for much flexibility in switching capability, they have one important limitation: speed. When compared to other relays, electromechanical relays are relatively slow devices -- typical models can switch and settle in 5 to 15 ms. This operating speed may be too slow for some applications. (e.g. you would NOT use this for high speed switching projects.) Many EM relays can be made to handle higher voltages.

2) reed relays- Because of the smaller, less massive contacts and the different actuating mechanism, a reed relay can switch about 10 times faster than an electromechanical relay with equivalent ratings. The reed relays's mechanical lifetime is also much higher than an electromechanical relay. The tradeoff, however, is that the smaller contacts on the reed relay make it much more susceptible to damage from arcing when closing a circuit. (good for some high speed switching situations but are limited to lower voltages).

3) solid state relays- SSRs are a faster alternative to electromechanical relays because their switching time is dependent on the time required to power the LED on and off - approximately 1 ms and 0.5 ms respectively. Because there are no mechanical parts, their life expectancy is higher than an electromechanical or reed relay.
SSRs are useful for high-voltage applications because the LED actuation does provide a galvanic isolation barrier between the control circuitry and the MOSFET

4) FET switches- In general, FET switches are the fastest of the switches discussed here. Also, because there are no mechanical parts or LEDs in the packaging, FET switches can be very small. One major drawback of the FET switch, however, is that it lacks a physical isolation barrier and thus may only be used with low-voltage signals.

http://zone.ni.com/devzone/cda/tut/p/id/2774

s


retrolefty

Quote
SSRs are useful for high-voltage applications because the LED actuation does provide a galvanic isolation barrier between the control circuitry and the MOSFET


The vast majority of SSR use thyristor devices to do the switching, not MOSFET, either using a Triac or back to back SCRs.

terryking228

Quote
I am trying to find a source of a similar opto-isolated relay board with 4 relays. Some people don't NEED 8 relays!


OK! Found them...  http://arduino-direct.com/sunshop/index.php?l=product_detail&p=201

A look at a selection of different relay types:  http://goo.gl/8ZEQ8

DISCLAIMER: Mentioned stuff from my own shop...!

@tranquills0 - thanks for your really helpful information on relays here!
Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Go Up