CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

adjust time in DS1307 using keypad

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
elizabeth ann



Joined: 16 Feb 2008
Posts: 33

View user's profile Send private message

adjust time in DS1307 using keypad
PostPosted: Fri Feb 29, 2008 11:16 pm     Reply with quote

hello,

i have tried and successfully displayed the date and time using DS1307, the source of the date and time is my PC. however, i would like to develop a code on how to display the date and time manually, which means it doesn't necessarily have to come from the date and time of my computer.

are there any beginner/sample codes on how to adjust time in DS1307 using a user input like keypad?

thanks.
crystal_lattice



Joined: 13 Jun 2006
Posts: 164

View user's profile Send private message

Adjusting time
PostPosted: Sat Mar 01, 2008 6:26 am     Reply with quote

Hi there. What do you mean by "the source of the date and time is my PC"??

We used a easy 3 button setup in our coffee project. One button to set the alarm time when pressed or display actual time when released. The other two was used to increment the hours and minutes. eg. when hour button is pressed read the current hour value from the RTC increment it and check that it is not bigger than 23 and write it back to RTC.

Sounds like you want to use keypad to enter numbers. You will have to create some menu function or something to get to the "function" of setting time and then requesting the user to enter a valid time and confirm the entry. with say the # key.

Regards
elizabeth ann



Joined: 16 Feb 2008
Posts: 33

View user's profile Send private message

Re: Adjusting time
PostPosted: Sat Mar 01, 2008 10:06 am     Reply with quote

crystal_lattice wrote:
Hi there. What do you mean y "the source of the date and time is my PC"??

We used a easy 3 button setup in our coffee project. One button to set the alarm time when pressed or display actual time when released. The other two was used to increment the hours and minutes. eg. when hour button is pressed read the current hour value from the RTC increment it and check that it is not bigger than 23 and write it back to RTC.

Sounds like you want to use keypad to enter numbers. You will have to create some menu function or something to get to the "function" of setting time and then requesting the user to enter a valid time and confirm the entry. with say the # key.

Regards


hey there,

your project sounds very similar to mine, only that mine is on medicine, yours is on coffee. the 3-button setup sounds interesting, i hope you could share some more tips on that, especially regarding the time input. did you use keypad in setting the time too?

yes, the time and date that the LCD displays is the same as with my PC. this is during a computer simulation. on actual testing, i only get 00:00:00 and it starts counting normally from that number. kidding aside, nothing will be wrong if i actually plugged the module at exactly 12 midnight. by the way, i am planning to display the actual time whenever the microcontroller is idle. Wink

and yes also, i am trying to develop a code that will use the keypad to enter numbers as the actual time, so that i can manually adjust the time anytime i want, with which the clocking will start from. better? or did i just make it more unclear?

make a function to get to the setting of time? that's exactly what i'm working on right now. i have successfully done entering starting time INSIDE the program, but with the keypad, not yet.

can someone give a sample routine for that? any other help will be much appreciated.

thank you.

elizabeth ann
crystal_lattice



Joined: 13 Jun 2006
Posts: 164

View user's profile Send private message

Setting time
PostPosted: Sat Mar 01, 2008 12:40 pm     Reply with quote

As an assignment each student had to "reverse engineer" the firmware of the
"Kenwood" coffee maker and build prototype. It ONLY had 3 buttons, thats it.

You say that your time displays 00 even if it is not. Are you converting the BCD to HEX and vice versa. In our project we read the BCD time, converted it to HEX, did the addition, converted back to BCD and wrote value to RTC.

As for your keypad thing, make sure the keypad routine returns the right "value" and that it does not get mixed up with ASCII conversion.
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Sat Mar 01, 2008 7:29 pm     Reply with quote

Just finished a project using the DS1307. It has 4 buttons and interfaces with a 122x32 graphic LCD. It allows timers to be set relative to sunset and relative to sun rise as well as specific times such as 10:35 PM. It automatically adjusts for daylight savings time in the USA. A popular method to deal with all the items required and just 4 buttons is to implement a state machine. A timer debounces the buttons and moves through a menu sub menu tree ( keeping track with a state machine). EX If the tens of minutes is chosen after a selection of change
clock>>change time>>change tens of minutes the state machine allows a button to now adjust the tens of minutes field. It also has an RS232 interface to a PC so the DS1307 registers can be examined. I would start out with getting the buttons and the debounce to work. Then get the dec to bcd, bcd to dec routines. Then get the I2c working to read the DS1307 registers. Then work on a LCD display interface. Then to timers then to specific types of timers EX sunrise plus 35 mins. Then onto daylight savings. Only take on what you can understand and what you need.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group