Digital 6-digit 7 segment clock with microcontroller

By IKTech May 29, 2017

What to know about this project is:

1. 7 segment multiplexing

2. C language Functions and header file.

3. Ds1307 idea about RTC IC.

4. Ideas about I2C protocol.

So let’s start,

DS1307 RTC IC

I know you do not read datasheet. So I will show the important topics of the datasheet here.

RTC = Real Time Clock.

This is the normal circuit of ds1307. Rpu’s value is 1K – 4.7K, VCC = 5v, Vbat = 3.7v, crystal = 32KHz

From the upper part, we can understand that the number of ds1307 hours register is 12-hour / 24-hour with the 6 bit. And 12-hour select 5 bit bit as AM / PM.

This table is very important. From the table, we can see data from any address. For example, we need to know hourly then we must take the data from address 0x02.

This rule requires to read data from our IC. S> 1101000 0> Address> Sr> 1101000 1> Read Data> P.

Here,

S = Start = soft_I2C_start ();

1101000 0 = 0xD0 = Device Address + Write mode

Address = Address from the address.

Sr = I2C_repeated_start (); [But we have used soft I2C here so that there is no function named repe_start (). But instead of being told in the library, soft_I2C_start (); Can be used.]

1101000 = 1 = 0xD1 = Device Address + read mode

 

P = Stop = soft_I2C_stop ();

This rule requires us to write data to IC. Similar analysis can be done. So I did not do that
Program Analysis

To make the program short and understandable, I have worked part of the program by parting the header file. The program is divided into 3 files

1. SimpleRTCclcok.c = Main file / code.

2. Ds1307.h = This code has been separated from ds1307 only.

3. 7segment.h = There are 7 segments in this code.

I have described the ds1307.h file above. You can also clear it again

Sbit Soft_I2C_Scl at RA2_bit;
Sbit Soft_I2C_Sda at RA3_bit;
Sbit Soft_I2C_Scl_Direction at TRISA2_bit;
Sbit Soft_I2C_Sda_Direction at TRISA3_bit;

As we have used soft I2C, I2C pins are mentioned here.

Unsigned short read_ds1307 (unsigned short address) {
Return r_data;
}

Read_ds1307 A function which will return data of unsigned short type.

Return r_data; Has been specified with the value tie return of r_data.

This function has an address named parameter. Which basically indicates that we want data from ds1307 IC address.

If (address! = 2) r_data = bcd2dec (r_data);

This line is said to be, when the value of the address is 0x02 [hour], then only r_data will convert from BCD to DEC.

[Note: ds1307 basically understands the BCD number. But 12-hour mode a hour is not converted to BCD. In order to read / write the HEX number.]

I’m not a little lazy to write_ds1307 and analyzed. ?

7segment.h:

Void show_display (char y, unsigned short x) {// y for digit select, x for data
Unsigned short temp;
If (y == ‘H’) {
}

.. .. .. .. .. .. ..

}

This function has done data show in 7 segment.

Show_display (‘h’, value); // ‘H’ for hours, which will show in the value.

I do not see anything else in this file. Even if there is anybody’s problem I am there. ?

SimpleRTCclcok.c:

Hh = tmp & 0b00011111;

As already mentioned, hour is only HEX number. We have another 12-hour [6-bit ‘1’] mode

Hh = 0x51;

// PM = 0x61 – 0x72 [1 – 12]
// AM = 0x41- 0x52 [1 – 12]

0x61 = 0110 0001 // 5bit ‘1’ for PM.

Now, 0110 0001 & 0001 1111 = 0000 0001 = 0x01 = 1

So the display for 0x61 will show ’01’ hour. Clear ????

If (hh> 9) hh- = 6;

Since hh value is HEX, [dec 10 = hex F (dec 16)] So if the value of hh is greater than 9 -6 is done. Eg hh = 0x0F – 6 = 0x10;

For delay (delay = 0; delay <20; delay ++), using ds1307 has been delayed between taking data. [Important] Tmp = read_ds1307 (2); Keeping the value in tmp is due to am / pm [5bit] from this value. Time Match: There are 4 PUSH buttons for matching time. The work of the buttons is given below 1. SETUP: Push once to enter time setup mode. 2. SELECT: Push to next. Hour> Minute> Second> DONE

3. UP: Push to Increment current selected value.

4. DOWN: Push to Decrement current selected value.

31 thoughts on “Digital 6-digit 7 segment clock with microcontroller

  • It is really a great and useful piece of information. I’m glad that you shared this helpful information with us. Please keep us informed like this. Thanks for sharing.

  • My husband and i got very cheerful that Chris could conclude his web research from the precious recommendations he discovered from your very own web page. It’s not at all simplistic to simply possibly be giving out tricks that many others might have been making money from. And now we fully understand we’ve got you to appreciate for this. These illustrations you’ve made, the straightforward website menu, the friendships you can assist to instill – it is mostly overwhelming, and it’s letting our son and our family imagine that that concept is interesting, which is certainly rather indispensable. Many thanks for all the pieces!

  • There are some interesting time limits on this article however I don抰 know if I see all of them center to heart. There may be some validity however I’ll take maintain opinion till I look into it further. Good article , thanks and we would like more! Added to FeedBurner as nicely

  • Needed to create you one very small word just to say thanks yet again considering the marvelous solutions you’ve provided on this page. It’s quite remarkably open-handed of you to make without restraint all that a lot of folks might have offered for sale for an e-book in order to make some bucks on their own, precisely now that you could have done it in the event you decided. The concepts likewise acted like a good way to fully grasp someone else have similar fervor much like my personal own to figure out way more in regard to this issue. I think there are lots of more pleasant opportunities up front for folks who go through your site.

  • Spot on with this write-up, I actually suppose this website needs much more consideration. I抣l probably be again to learn rather more, thanks for that info.

  • I needed to create you the little bit of observation in order to say thanks a lot as before just for the pretty techniques you’ve featured in this article. It was simply strangely generous with you to grant unreservedly all a number of us could possibly have made available as an e-book in order to make some dough on their own, most notably since you might have tried it in case you desired. Those tactics in addition worked like the good way to understand that the rest have the same dreams much like my very own to understand much more with regards to this matter. Certainly there are numerous more pleasurable opportunities up front for individuals who browse through your site.

  • Howdy would you mind letting me know which webhost you’re using? I’ve loaded your blog in 3 completely different internet browsers and I must say this blog loads a lot quicker then most. Can you recommend a good web hosting provider at a fair price? Thank you, I appreciate it!

  • I frequently go through your content attentively. I am also fascinated with Arvind Pandit Kansas, you could discuss this at times. See you.

  • I’m just writing to make you understand what a fine discovery my wife’s princess experienced reading your web site. She noticed too many things, including what it is like to possess an excellent teaching mood to let others without hassle learn several complicated matters. You truly did more than my desires. Thanks for providing such warm and friendly, safe, revealing not to mention unique thoughts on your topic to Tanya.

  • I was more than happy to find this web-site.I wished to thanks to your time for this wonderful learn!! I positively having fun with each little bit of it and I’ve you bookmarked to check out new stuff you weblog post.

  • Needed to compose you the very little word in order to thank you so much over again considering the stunning suggestions you have documented above. It is simply pretty generous of you to offer extensively exactly what a number of us might have advertised as an ebook to help with making some dough for themselves, especially considering that you could have tried it if you ever desired. The ideas also acted as the fantastic way to know that many people have the same dream just like my very own to understand good deal more in regard to this issue. I know there are a lot more pleasant sessions up front for individuals who read your site.

  • I constantly look over your posts closely. I am furthermore fascinated by new years greetings, you could talk about this occasionally. Take care.

  • I must express my admiration for your generosity in support of men and women that should have help with this theme. Your very own dedication to getting the message all around had become amazingly productive and have continually enabled girls just like me to reach their desired goals. Your amazing valuable hints and tips denotes a great deal to me and additionally to my office colleagues. Thanks a ton; from all of us.

  • Oh my goodness! an incredible article dude. Thanks However I am experiencing problem with ur rss . Don抰 know why Unable to subscribe to it. Is there anybody getting equivalent rss downside? Anybody who knows kindly respond. Thnkx

  • I would like to express thanks to you for rescuing me from such a condition. Because of surfing around throughout the internet and obtaining views which are not helpful, I believed my entire life was well over. Being alive without the presence of strategies to the issues you’ve resolved through your main guideline is a critical case, as well as ones which may have adversely damaged my entire career if I had not discovered your blog. Your personal expertise and kindness in dealing with all the stuff was useful. I’m not sure what I would have done if I had not discovered such a solution like this. I am able to at this point look forward to my future. Thanks for your time very much for your professional and effective help. I will not be reluctant to recommend the blog to any person who requires direction on this issue.

  • I wanted to jot down a simple word so as to express gratitude to you for all the pleasant solutions you are posting at this site. My extensive internet search has now been compensated with sensible facts and techniques to write about with my partners. I would admit that many of us website visitors are really blessed to live in a perfect network with many awesome individuals with useful methods. I feel rather lucky to have discovered your entire weblog and look forward to some more entertaining minutes reading here. Thanks a lot once again for everything.

  • Thank you very much for writing the idea, I bookmarked the webpage. I am furthermore seeking out info on intercom system installation NY, have you any idea where I can find a thing such as this? I’ll return in a little while!

  • I must express my appreciation for your kind-heartedness giving support to folks that absolutely need help on that niche. Your real commitment to passing the solution up and down had become particularly beneficial and have frequently enabled girls much like me to achieve their goals. Your warm and helpful instruction can mean so much a person like me and substantially more to my peers. Regards; from everyone of us.

  • Aw, this was a really nice post. In thought I wish to put in writing like this additionally ?taking time and precise effort to make a very good article?however what can I say?I procrastinate alot and under no circumstances appear to get something done.

  • Wow that was unusual. I just wrote an extremely long comment but after I clicked submit my comment didn’t show up. Grrrr… well I’m not writing all that over again. Anyways, just wanted to say excellent blog!

  • My spouse and I stumbled over here coming from a different web page and thought I should check things out. I like what I see so now i am following you. Look forward to looking into your web page repeatedly.

Leave a Reply

Your email address will not be published. Required fields are marked *