================================================================================================================================================

Saturday, June 23, 2018

Relay-Timer Circuit with RTC (for auto-operating appliances) using AtmelStudio or Arduino




Hi friends,
     it's been years since I put up a new post here. So, starting again with a simple circuit, based on ATmega8, might be useful for newbies in AVR, RTC, Relay, etc.This is RTC based relay operating circuit to automatically power ON/OFF any electrical device/appliance at a preset time. 
    The necessity behind it was this: I had started taking a 230V AC electrical Tiffin (lunch) box to office a few months back, which takes minimum 30 minutes to very slowly heat up the food (it's kept slow heating as the idea is to just heat the food without re-cooking it). That means it's necessary to turn the box ON 30 minutes before lunch-time. And it happened quite a lot of time that I simply forgot or could not power on due to a meeting in another building. So, one day I quickly cooked up this circuit as I was already having all the required components (including an ATmega8 development board and a relay module, to minimize the soldering job).
    Before anything further, if you try to make this circuit, WARNING!! High Voltages are involved here, extreme care is necessary while testing/operation. Ensure proper insulation for the high-voltage lines.
    This circuit can be used for powering any electrical device by setting start and stop time, which is stored in EEPROM of ATmega8, so no need to set again upon power off. RTC (based on DS1307) is used for similar reasons, no need to keep the circuit ON when not necessary, or during power off, it will maintain the date/time running (with the help of the common 3v Li button-cell). RTC setting or start/stop time setting can be changed anytime using three push-buttons provided onboard.
    Now, the main components: The microcontroller is AVR ATmega8, small enough and with sufficient flash for the code required here. Initially (before making the custom-made PCB shown in the above pics), I used a off-the-shelf available 28-pin AVR Development board from Extreme Electronics. The board is shown here:

    Using such a board avoids soldering the IC base, power supply components, ISP connector, etc. And it's having some user area for soldering, which was sufficient for this project.
    The Dual-channel Relay board used initially is from EmbeddedMarket.com:


    This module is having two independent relays with transistor circuits for activation. The VCC supply line of the coils here are connected with 9V or 12 V DC (as per the DC adapter used to power the development board) and the AVR port lines are connected to RL1 and RL2 terminals. Two devices can be independently operated with this module by connecting the AC live input to the NO (Normally Open) terminal of the Relay and taking the output from C (common) terminal to the electrical device live input. The return line of the electrical device can directly go from device to the mains, without connecting to this unit. (Note: As I was having only one device to control, I passed the Phase (Live) through one relay and Neutral through the another relay. The program operates both the relays simultaneously to power the electrical device, i.e.Tiffin-box in this case).
    Here is the Proteus simulation screen-shot (during simulation, LEDs are used in place of the relays to check the functionality and the serial terminal is unused):


 
  Following is the simulation using ATmega328 (Arduino):


 (The Proteus simulation files are included in the source code download at the end of the post).

    As shown, upon powering on, after displaying a welcome message, the LCD displays current date and time, and the output status (via two relays). The output ON is also indicated using a Red LED on the circuit. The terminal (UART) in the circuit is kept extra, in case someone wants to use terminal instead of LCD and push-buttons to display/set timings (This further reduces the hardware onboard, it will add only a UART-USB converter module for PC/laptop connection, which are quite commonly available).
    The program reads the set-time in EEPROM by checking for a valid EEPROM signature. If time is not set, it sets default time of 1230 HRS for start time and 1300 HRS for stop time. Whenever a new time is set, it's stored in the EEPROM and used during operation thereafter.
    The quickly made proto of the circuit with whatever came handy is shown here (underneath the LCD are the AVR and relay boards with the rest of the circuitry):



       The 230V lines are properly screwed and totally insulated using glue-gun inside the box, including the relay terminals, so that not even a single strand of the wire comes out of the insulation.
     Of course, the circuit can be totally tested (or time can be set/ changed) without connecting the 230V lines, as we can confirm the continuity of the relay line by checking with multimeter. The high voltage line is necessary only during the actual operation.
    Later on, the schematic and layout of the PCB were designed using KiCad (latest version 5.0), as KiCad has recently become a really great tool (and free, too!), as compared to my quite earlier experience with it. I instantly liked it even better then the EAGLE lite, which I had been using so far.
The schematic is given here (when using Arduino, replace ATmega8 with ATmega328 in the circuit, in the same PCB):


       The PDF schematic can be downloaded from here.

The operation of the circuit is described here:

Circuit Operation:
--------------------------------------------
For setting RTC Date/Time:
  1. Press 'SET' button and Power ON the circuit, keeping the button pressed while the circuit is starting.
  2. "RTC Setting.." message will be displayed on the first row of the LCD.
  3.  Release the 'SET' button "Date: XX" will be displayed on the second row of the LCD, where XX is the existing current date as per the RTC.
  4.  Press 'UP' or 'DOWN' button to increase or decrease the Date. When desired date is displayed, press 'SET' button to store it
  5. "Month: XX" message will be displayed, where XX is the current month as per the RTC
  6. Press 'UP' or 'DOWN' button to increase or decrease the Month. When desired month is displayed, press 'SET' button to store it
  7. "Year: XXXX" will be displayed, use 'UP'/ 'DOWN' buttons to change the year and then press 'SET' button to store the year value
  8. Then "Hour: XX" will be displayed, set it as per the previous steps and also set next "Minutes: XX" similarly, and store using 'SET' button.
  9. When the Minutes is set, "RTC Setting" mode is over and normal operation resumes, where the LCD will display Date and time in the first row and O/P: ON/OFF status in the second row.
 Normal Operation:
  1.  When the circuit is powered ON without pressing the 'SET' button, it displays "Welcome, -Relay timer-" message for two seconds and then directly enters into the normal mode
  2. During the normal operation, the LCD display will be as per the above step 9. The Date and time are continuously updated on the display every second
  3. In the normal operation, whenever the RTC time matches with the Start Time, the Relays are energized, connecting the output lines with the respective input lines. 
  4. When the output is ON, as soon as the RTC time matches with the Stop time, the relays are turned OFF, cutting off the output
  5. The output ON and OFF are displayed on the LCD as well as indicated by Red LED ON and OFF, respectively
Setting Start/ Stop time:
  1.  Start and Stop time can be changed anytime  during the normal operation
  2.  Pressing the 'SET' button during normal operation displays currently set values of Start and Stop (End) times in "S:HH:MM E:HH:MM" format in the second row, where 'S' indicates Start time and 'E' indicates End (Stop) time. 'HH' and 'MM' are hours and minutes, respectively. The first row continues to display current date and time.
  3. During step 2, if 'SET' button is pressed again, display goes back to normal operation. But if 'UP' or 'DOWN' button is pressed instead, the program enters into the Start/Stop time setting mode, where "Start Hour: XX" is displayed in the second row.
  4. Use the 'UP'/'DOWN' and 'SET' keys to adjust Start Hour, followed by Start Min (Minutes), then Stop Hour and Stop Min. Each value is stored by pressing the 'SET' button.
  5. After the Step 4, the new values are stored in EEPROM and normal operation resumes.
       Here are two more views of the operational unit:
     


 Notes:
  • After RTC and Start/stop times are set, no intervention is required for circuit operation
  • Whenever necessary, the circuit can be switched off, the date/time settings will be maintained
  • If the circuit power is OFF and the start time is missed before the power is ON, the circuit will not set the o/p even if the Stop time is still quite away. It will set the o/p only when the next start time match with RTC. (This can be changed by minor modification in the code, if necessary).
  • Warning again, proper insulation and extreme care from high voltage line is must!! Never keep you high voltage outlet pins 'Male' type, always use socket type. Use 'male' types only for the high voltage 'inlet' pins.
    So, for last couple of months, I connect the Tiffin with the circuit (first thing after reaching office), using standard 230V AC plug, and power ON the circuit, check the display for normal operation and then continue with my work. The Tiffin gets ON and OFF as per the set time before lunch. At lunch time, I turn off the power (coz it's not necessary till next morning) and enjoy the hot meal!! The power can be kept ON also, if desired. For example, in case if you want to water your plants periodically by turning on the electrical motor, whether you are available nearby or not.

Here is the complete source code in AtmelStudio7 and Arduino project files along with the Proteus simulation files (please ensure programming the fuse bites for proper clock frequency values). When using Arduino, ATmega8 needs to be replaced with ATmega328:

Downloads

Source Code (AtmelStudio) and Simulation Download (ATmega8, @8 MHz internal clock)

Source Code (Arduino) and Simulation Download (ATmega328, @16 MHz External clock)

KiCad Project Schematic, PCB and Gerber files


Datasheets/ Links:   ATmega8,   ATmega328,   DS1307,   Arduino Website


Enjoy!!

Thanks & Regards,
CC Dharmani 
--------------------------------

236 comments:

«Oldest   ‹Older   201 – 236 of 236
Tech To Review said...
This comment has been removed by the author.
Quickbooks Support Phone Number. +18882724881,Houston. said...

Good blog!!
We are provide a best service Quickbooks Support Phone Number +18882724881,Houston.

Nancy said...

Thanks for sharing this post. Many difficulties occur when using QuickBook as QuickBooks Error 9999. The error 9999 is a script problem that causes your bank's connection to QuickBooks Online to be disrupted (QBO). For the time being, WebConnect is the only way to get your transactions in.

Quickbooks Support Service Phone Number.+1 855-746-5668,DE. said...

Hey!! good content.
if you are searching for a best service support so move to Quickbooks costumer service you can contact us at.+1 855-746-5668,DE.

Quickbooks Support Phone Number. +1 877-603-0806,Illniois. said...

Thanks for sharing this post. Many difficulties occur when using QuickBook Customer Service as QuickBooks Error 9999. The error 9999 is a script problem that causes your bank's connection to QuickBooks Online to be disrupted (QBO). For the time being, WebConnect is the only way to get your transactions in.you can reach us at.+1 877-603-0806,IL.

Quickbooks Support Phone Number.+18666695068,NJ said...

Hey!
What a wonderful blog. I loved your blog. QuickBooks is the best accounting software; however, it has lots of bugs like QuickBooks for MAC Support . To fix such issues, you can contact experts via QuickBooks Support Phone Number +1 866-669-5068,NJ.

Nancy said...

Nice Blog, Your bank and QuickBooks Online may be unable to connect to the internet due to a script issue known as QuickBooks Error 9999. The system hangs, responds slowly, or simply stops working when this problem occurs. When you try to modify your bank information in QuickBooks, you'll run into a banking issue.

gabriel2020evelyn said...

Interesting post. I have been wondering about this issue, so thanks for posting. Pretty cool post.It 's really very nice and Useful post.Thanks

Top 2 Effective Methods to Fix QuickBooks Error H202
How to Permanently Fix QuickBooks Error 1904?
How to Troubleshoot QuickBooks Error 404?
How to Use Undeposited Funds Account in QuickBooks
How To Resolve QuickBooks Error 1712?
How To Resolve QuickBooks Error 557?
How to Solve QuickBooks Error 3371 and 404?

Tech To Review said...

Giggl is also Rabb.it Alternatives, lets you share a multiplayer browser with your pals to watch web content, anime, movies, or even surf sites and apps like TikTok, Netflix, Reddit, and Twitter. To browse the web, chat, or make a voice call, you can create a public or private portal.

Jai Jaiswal said...


Brilliant blog. Start your day from Suryanamaskar to make day Energetic. meditation basics yoga , yoga benefits , types of yoga , yoga history , health benefit yoga , yoga pose , yoga asanas - theyogainfo.com you reach us at

Smartphone Crunch said...

VIRGO is a fastest supercomputer in India based on the IBM iDataplex dx360 M4 that was created by the Indian Institute of Technology (IIT) Madras. Its primary goal is to acquire satellite data that will improve the region's weather forecasting accuracy. Researchers can use the supercomputer to analyse data from prior cyclones and compare it to real-time weather data to improve predictions.

nik jones said...

This post is great. I really admire your post. Your post was awesome. If you need any support for QuickBooks then get immediate help from our QuickBooks Experts.

QuickBooks Error 12029

nik jones said...

Thanks for sharing superb knowledge with us. Your thought is very impressive. If you are a QuickBooks user and facing an error, if you need any help, so contact our QuickBooks Expert for solving your problem.

QuickBooks Error 6143

Smartphone Crunch said...
This comment has been removed by the author.
Tech To Review said...

Stream2Watch is one of the largest streaming sites where you can watch live sports activities. You may see a list of all live sports matches on the site's home page. It’s best Firstrowsports alternative Immediately! HD provides a new way to access and enjoy your favourite live sports for free. The most significant downside of using this website is the abundance of pop-up ads, which irritate users when they try to watch live events or play activities. Furthermore, the service provides various links or mirrors for each game to be seen.

glennmaxwellusa said...

Thanks for sharing such an informative post.
If you are willing to learn how to install, update, and set up QuickBooks Database Administrator, you can read on this blog post. We have created this to assist you in finding out what you require to successfully

login problems of quickbooks online
QuickBooks File Doctor

Anonymous said...

https://www.blogger.com/comment.g?blogID=8014888555955763990&postID=671380140574576190

David John said...

Best Software Development Company

Courier Management Software

Delivery Management Software
Logistics Management Software
Transport Management Software
Payroll Management Software

Cyra Khan said...

Visit Our Site: nagpur model girls

Adam Smith said...

QuickBooks error code 80070057 is a run-time error that typically occurs when users try to open company files. Here are some simple steps to quickly fix this error.

Also Visit this QuickBooks Error H202

Anisa William said...

Generally .ND files in QuickBooks Desktop(Network data files) are configuration files that permit the QuickBooks software to access the company file in a multi-user environment.

Anisa William said...

QuickBooks Error 12029 is a most common error that occurs when the software fails to access the server. In this post we have discussed about the procedure to fix this error.

Anisa William said...

According to a quick survey the QuickBooks Error Code 30159 occurs while trying to upgrade the payroll or while working on the company’s payroll.

Hostdocket said...

Are you troubling with printing, emailing or saving as a PDF from QuickBooks Desktop? If yes, then this blog will help you to resolve the problem. QB users do face technical issues at times. A common error faced is the QuickBooks unable to create PDF issue this error can be easily resolved and in this article we will discuss how to handle it
https://www.hostdocket.com/quickbooks-unable-to-create-pdf/

Anisa william said...

Troubleshoot QuickBooks Error 15271 is generally occurs when one downloads the payroll updates or tries to update the tables of payroll. To fix this error follow the given steps here.

Hostdocket said...

QB Software has been considered the widely used software. From simple calculations to complex algorithms, the QuickBooks Software has it all. But it does get prone to errors sometimes and the common one is QuickBooks Error Code 193

amelia smith said...

QuickBooks Error Code 193
Solution can only be discovered once you know the reason behind it. We have talk about this error and its solution.

Siliguri Independent Escorts said...

Your material is absolutely stunning in various designs. I consider this to be friendly and educational content. I have gotten endless considerations from your blog. Many thanks.

vishalnegi said...

Lavender Oil For Hair, Lavender is a perennial herb native to the Mediterranean region, known for its sweet, floral fragrance. The essential oil is extracted from the plant's flowers through steam distillation, retaining the plant's volatile compounds, including linalool, linalyl acetate, and camphor. These compounds are responsible for lavender oil's numerous therapeutic properties, including its effectiveness in hair care.

jhon carry said...

Thank you for sharing this informative blog with us. Your blog is very useful for us. If you're studying management in Australia and find yourself facing challenges with your assignments, worry not! Management Assignment Help in Australia is here to assist you on your academic journey.
Our service is specifically designed to support students like you who are pursuing management studies. We understand that assignments can sometimes be overwhelming due to their complexity or the sheer volume of work. That's why our team of experienced professionals is dedicated to providing you with the guidance you need to excel.

Newguy said...

Thanks to sharing this information this information help me lot sir thanks for sharing I am following you since very long time your content is always on top thanks to sharing again

Fmovies

Tradeflock said...

FMovies, a popular online platform for streaming movies and TV shows, offers a vast collection of content for free. Users can enjoy a wide range of genres and titles, making it a go-to choice for movie enthusiasts. However, be aware of potential copyright issues and use the site responsibly.

prashant said...

Diamond Motors appears to be a business that specializes in selling second-hand or used cars. Such businesses typically acquire pre-owned vehicles and offer them for resale to customers. Customers often choose to buy used cars for various reasons, such as cost savings compared to purchasing a new car, a wider selection of models and makes, and the potential for finding vehicles that are no longer in production.

If you have specific questions about Diamond Motors or if you need information about buying a used car from them, it's a good idea to contact them directly or visit their website if they have one. You can inquire about their inventory, pricing, and any other details you need to make an informed decision when purchasing a used car.

diamondmotors

shelby said...

Your blog about "Relay-Timer Circuit with RTC (for auto-operating appliances) using AtmelStudio or Arduino" is consistently provides a wealth of knowledge and inspiration. Your dedication to delivering valuable content is truly commendable. I always look forward to reading your posts and appreciate the effort you put into making your blog an enriching experience for readers. Keep up the excellent work! Dismiss Order Of Protection New Jersey Reckless Driving Attorney In New Jersey

Anonymous said...

Experience the personalized touch at Healing Buddha, where every healing session is crafted to address individual needs, fostering empowerment and transformation.
benefits of pranic healing

Goa Female Escorts said...

Thanks for sharing this information Goa Independent Female

«Oldest ‹Older   201 – 236 of 236   Newer› Newest»