Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to set an alarm for rtc with PIC16F877A?

Status
Not open for further replies.

IsaacChuah90

Banned
Joined
Oct 4, 2011
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
0
Hey guys, I'm new at here. Nice to meet you all. Can I know how to set an alarm for my real time clock? I'm using PIC16F877A interface with DS1307 real time clock chip. I'm using mplab High-Tech C Compiler. Hope can get your guys replies soon.
Thanks a lot.:)
 

Re: Help my code for alarm clock !

Hey guys, I'm also doing rtc with pic16f877a. Now want to implement an alarm on it. Can I know how to write a coding for the alarm? I have saw the previous post is about
if (current_time == alarm_time)
{
// enable alarm
}

but I have no idea how to define for the current time and alarm time. Seeking for helps from you guys. I have just post a new post which is how to set an alarm for rtc with pic16f877a. Hope can get replies from you guys soon.
Thanks a lot.:)
 

Re: Help my code for alarm clock !

Hey guys, I'm also doing rtc with pic16f877a. Now want to implement an alarm on it. Can I know how to write a coding for the alarm? I have saw the previous post is about
if (current_time == alarm_time)
{
// enable alarm
}

but I have no idea how to define for the current time and alarm time. Seeking for helps from you guys. I have just post a new post which is how to set an alarm for rtc with pic16f877a. Hope can get replies from you guys soon.
Thanks a lot.:)

You need an input mechanism of some sort. Think about a regular alarm clock. You generally hold down the "set time" or "set alarm" button, then press hour/minute until the correct time is displayed. If you are holding "set time" then the you update the current_time variable in your code until the button is released. Once it's released, you update your RTC to that same time, then the RTC runs like normal.

If the user is pressing the "set alarm" button, when they let it go, you load the displayed time into the alarm_time variable. Your main() program runs an infinite loop that checks for current_time (read it from the RTC) and compares it to the value in the alarm_time variable... for the result, see the pseudo-code above. Once the alarm is activated, you'll want an interrupt/deactivate function, too. Case in point, if the user presses a "snooze" button, turn off the alarm and set alarm_time = alarm_time + 8 minutes (or whatever you decide). Then, when the infinite loop in main() hits current_time == alarm_time 8 minutes later, the alarm will sound again, etc.
 

Re: Help my code for alarm clock !

You need an input mechanism of some sort. Think about a regular alarm clock. You generally hold down the "set time" or "set alarm" button, then press hour/minute until the correct time is displayed. If you are holding "set time" then the you update the current_time variable in your code until the button is released. Once it's released, you update your RTC to that same time, then the RTC runs like normal.

If the user is pressing the "set alarm" button, when they let it go, you load the displayed time into the alarm_time variable. Your main() program runs an infinite loop that checks for current_time (read it from the RTC) and compares it to the value in the alarm_time variable... for the result, see the pseudo-code above. Once the alarm is activated, you'll want an interrupt/deactivate function, too. Case in point, if the user presses a "snooze" button, turn off the alarm and set alarm_time = alarm_time + 8 minutes (or whatever you decide). Then, when the infinite loop in main() hits current_time == alarm_time 8 minutes later, the alarm will sound again, etc.
Thanks for your reply enjunear. I get what you mean. Now I have done until the LCD can show time date and time. Besides, I have also use 2 switches for the project,1 is mode button and another 1 is add button which is add the time or date. Now I plan to add an alarm into my project. I'm quite poor in writing coding. Hope you don't mind. Can I know how to write for the coding? I know the idea you have given my just now but I don't have the idea how to write it. Any code can I refer to? Thanks for the reply. Appreciate the reply from you.:)
Hope can get helps from you guys. Thank you!
 

Hey guys, I have done until the LCD can show the time and date. Now I plan to add an alarm for the rtc to become alarm clock. So can anyone tell me how to write for the coding to set an alarm?Any coding can I refer to?
Hope to see you guys replies soon.Thank you very much.:)
 

Re: Help my code for alarm clock !

Thanks for your reply enjunear. I get what you mean. Now I have done until the LCD can show time date and time. Besides, I have also use 2 switches for the project,1 is mode button and another 1 is add button which is add the time or date. Now I plan to add an alarm into my project. I'm quite poor in writing coding. Hope you don't mind. Can I know how to write for the coding? I know the idea you have given my just now but I don't have the idea how to write it. Any code can I refer to? Thanks for the reply. Appreciate the reply from you.:)
Hope can get helps from you guys. Thank you!

I haven't written PIC code in almost 7 years, so I wouldn't do you much good. Learning how to program is a HUGE and valuable skill to have in your professional "toolbox". You really should practice as much as you can. Start out with a basic block diagram showing steps and decision points, using arrows to show the path you would logically take between steps and actions. Once that is done, start writing the code for each section. The decision blocks become if/then/else and case statements (or similar logical decision functions). Start simple, build the basic framework of decisions, leaving comments in places where you need to put something in, but don't want to get distracted with it right away. Then start filling in the sections where big things happen. Debug and test run often. Practice, practice, practice and the code will begin to feel like a second language.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top