Help need to make a simple clock

Go To Last Post
33 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all

 

I just make a simple clock with Atmega8 and 7 segment Display.

 

I got a code from a website. But in display all "0" not shown correclty.

and this is the code

 

Select Case Cifra

 Case 0 : Y = &H10 '   (Dec 16 ; Bin 00010000)

 Case 1 : Y = &H73 '

 Case 2 : Y = &H48 '

 Case 3 : Y = &H41 '

 Case 4 : Y = &H23 '

 Case 5 : Y = &H81 '

 Case 6 : Y = &H80 '

 Case 7 : Y = &H53 '

 Case 8 : Y = &H00 '

 Case 9 : Y = &H1 '

 End Select

 

dont find the problem with code.... Can somebody help me to overcome this issue?

 

Thanks and regards

 

Manoj

Attachment(s): 

This topic has a solution.
Last Edited: Sat. Feb 6, 2021 - 05:43 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Welcome to AVRFreaks!

 

manojsethu wrote:
I got a code from a website

What website would that be?  Please provide link, so we know what your talking about.

Why not ask your questions there, they would be more familiar with how their code works?

 

Jim

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Welcome to the Forum.

 

Are you using real hardware,or is this a simulaiton?

 

Is this a school project?

 

Skipping the clock for now, can you display any numbers correctly on the display?

 

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:

Welcome to AVRFreaks!

 

manojsethu wrote:
I got a code from a website

What website would that be?  Please provide link, so we know what your talking about.

Why not ask your questions there, they would be more familiar with how their code works?

 

Jim

 

I got this file from year ago. But now, I need to make it one. But I forget the link.....I think its a Spanish site.

 

Regards Manoj

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
 Case 0 : Y = &H10 '   (Dec 16 ; Bin 00010000)

My guess is the "1" is the  center segment that is not lit for zero.

H10 must be some strange (to me) notation for 0x10

 

Are you sure you have the segments wired correct?...since your photo shows the top segment dark instead of the center segment....try showing some other numbers & see if there is a pattern.

Or better yet, test by turning on only 1 segment at a time to verify your wiring,

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:

 Case 0 : Y = &H10 '   (Dec 16 ; Bin 00010000)

My guess is the "1" is the  center segment that is not lit for zero.

H10 must be some strange (to me) notation for 0x10

 

Are you sure you have the segments wired correct?...since your photo shows the top segment dark instead of the center segment....try showing some other numbers & see if there is a pattern.

Or better yet, test by turning on only 1 segment at a time to verify your wiring,

 

Hi

 

all other segment works correctly.....except segment a... :(

 

regards

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

all other segment works correctly.....except segment a... :(

Test them one-by-one...I suspect you have a mixup...there are many points where a swap can occur, so you need to look very carefully & write down what you find.  what happens when you try to show an 8?

Note you could have a top/middle swap AND have the middle segment disconnected (a double error).

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:
H10 must be some strange (to me) notation for 0x10

 

The programe written in Bascom AVR IDE

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:

all other segment works correctly.....except segment a... :(

Test them one-by-one...I suspect you have a mixup...there are many points where a swap can occur, so you need to look very carefully & write down what you find.  what happens when you try to show an 8?

Note you could have a top/middle swap AND have the middle segment disconnected (a double error).

 

Please check the attachment for files..

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

manojsethu wrote:
what happens when you try to show an 8?

 

showing the digit 8 correctly except segment a...

segment A not light up....   :(

Last Edited: Wed. Feb 3, 2021 - 09:04 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

manojsethu wrote:
segment A not light up....   :(

do you have current limiting resistor in each segment?  If not, you may have blown that port pin, LED's, even those in 7 seg displays need a resistor to prevent too much current from flowing, i.e. ohms law!

Show us your circuit schematic, please do not say you don't have one.

 

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

When you say that you are making a clock with an ATmega8 and 7-seg display, do you mean that:

    - the AVR is controlling the (I assume) four 7-seg displays?

    - the AVR is initialized to a real-time value (hours:minutes:seconds) when the code is compiled?

    - the AVR program determines when a second has passed and updates the initialized real-time value each second?

    - the AVR changes the H_M_S display each second. (or minute)?

 

 If this is what you mean, then it would help if you had told us this.  Because I would assume that "making a clock" for a Mega8 would entail adding a DS3231 module board such as this one: https://www.ebay.com/itm/DS3231-... to the TWI pins (PORTC4 :SDA and PORT C5: SCL) of the Mega8 so that the Real-Time does not get clobbered when the Mega8 is power-cycled or reset.

 

By the way, how do you handle doing a PowerOn/reset?

 

As for the 7-seg display; you need a code routine to multiplex the digit displays (here multiplex means to quickly display each of the four 7-seg units faster than the eye can detect that they are changing, or faster than 30 times a second.)  If one segment is off (test by incrementing a number display of 0000 to 9999 several times a second), then it is a wiring issue, as other posters have noted. 

 

Is this a hand-wired protoboard?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


manojsethu wrote:
7 segment Display

See this thread - only last week: https://www.avrfreaks.net/forum/interfacing-two-7-segments-display-and-temperature-sensor-atmega32

 

It's easier if you put your picture in the post, where we can see it - like this:

 

See Tip #1 in my signature for how to do that

 

DocJC wrote:
Are you using real hardware,or is this a simulaiton?

Now that we can see the picture, it looks pretty much like a simulation

 

So the top segment of all digits is not lighting.

 

As avrcandies said, write a simple test program which steps through lighting each segment individually

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:

manojsethu wrote:
segment A not light up....   :(

do you have current limiting resistor in each segment?  If not, you may have blown that port pin, LED's, even those in 7 seg displays need a resistor to prevent too much current from flowing, i.e. ohms law!

Show us your circuit schematic, please do not say you don't have one.

 

Jim

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

manojsethu wrote:
you may have blown that port pin

 

Is it need to connect the current limiting resistors in proteus too?  I dont think so..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Simonetta wrote:
this is what you mean, then it would help if you had told us this.  Because I would assume that "making a clock" for a Mega8 would entail adding a DS3231 module board such as this one: https://www.ebay.com/itm/DS3231-... to the TWI pins (PORTC4 :SDA and PORT C5: SCL) of the Mega8 so that the Real-Time does not get clobbered when the Mega8 is power-cycled or reset.

What are you talking about??? 🙄🙄🙄🙄

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If this is just a simulation, then you have some sort of segment or scanning bug & need to trace through from giving the segment value all the way through to the display segment pin and find it (including checking that port directions are set properly)

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Thu. Feb 4, 2021 - 04:40 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

manojsethu wrote:
Is it need to connect the current limiting resistors in proteus too? 

You need to ask Proteus that - this is not a Proteus support forum!

 

https://www.avrfreaks.net/commen...

 

I guess it depends how well/fully the proteus simulation works - whether it actually simulates failures/problems due to overloading the output pins.

 

It might well simulate the 'on' resistance of the port driver, and its LED simulation might conclude that you don't have enough voltage left to light the LED ...

 

But, really, why even raise the question? Simulated resistors cost you nothing - just do it properly!

 

You haven't said whether this is a common-anode or common-cathode display.

 

Again, just start with a simple program that lights each segment, one at a time.

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Thu. Feb 4, 2021 - 09:54 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

manojsethu wrote:

Simonetta wrote:

(a load of stuff)

What are you talking about??? 

You titled this thread, "Help need to make a simple clock" but your question is purely about driving 7-Segment LEDs - nothing about making timepiece.

 

Simonetta is extending the question to the full topic of making a timepiece.

 

Like giving your variables meaningful names, giving your threads accurate titles helps to identify the topic ...

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

manojsethu wrote:
I got this file from year ago. But now, I need to make it one. But I forget the link.....I think its a Spanish site.
Well Google seems to think it probably came from a Russian site in fact:

 

https://www.radiokot.ru/forum/vi...

 

that includes:

Select Case Cifra 'Начинаем выбор переменной Cifra
Case 0 : Y = &H10 'Если Cifra = 0, Y равен &H10 (Dec 16 ; Bin 00010000)
Case 1 : Y = &H73 '
Case 2 : Y = &H48 '
Case 3 : Y = &H41 '
Case 4 : Y = &H23 '
Case 5 : Y = &H81 '
Case 6 : Y = &H80 '
Case 7 : Y = &H53 '
Case 8 : Y = &H00 '
Case 9 : Y = &H1 '
End Select 'Конец выбора

which looks awfully familiar! (except your copy seems to have all the Russian comments removed)

 

EDIT: actually when I get that page translated:

 

https://translate.google.com/tra...

 

the post actually says "taken from another site" so perhaps this is NOT the original source?

Last Edited: Thu. Feb 4, 2021 - 10:40 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Did the schematic come from the same site as the code ... ?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

Sometimes the best medicine is to learn from your mistakes and start over.

By now you probably wish you had done various portions differently; now you have the chance.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:

Sometimes the best medicine is to learn from your mistakes and start over.

By now you probably wish you had done various portions differently; now you have the chance.

 

 

Ok and Thank you for your valuable suggession....

 

I will try

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:

Sometimes the best medicine is to learn from your mistakes and start over.

+1

manojsethu wrote:
I will try

Are you wedded to BASCOM, or could you use a more widely-supported language instead?

 

If you consider this thread now concluded, please mark the solution - see Tip #5 in my signature, below:

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Thu. Feb 4, 2021 - 02:19 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

manojsethu wrote in Post#1 wrote:

 

Select Case Cifra

 Case 0 : Y = &H10 '   (Dec 16 ; Bin 00010000)

 Case 1 : Y = &H73 '

 Case 2 : Y = &H48 '

 Case 3 : Y = &H41 '

 Case 4 : Y = &H23 '

 Case 5 : Y = &H81 '

 Case 6 : Y = &H80 '

 Case 7 : Y = &H53 '

 Case 8 : Y = &H00 '

 Case 9 : Y = &H1 '

 End Select

 

The above looks like Visual Basic code (Link - scroll down to Example).

 

Are you using Visual Basic in  Proteus?  If not, what language are you using?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Chuck99 wrote:
what language are you using?

in #8, manojsethu wrote:
The programe written in Bascom AVR IDE

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What you are reporting makes no sense.

 

You tell us all other digits work:

 

   8     1
  ---    ---
 |   |  |   |
  ---    ---
 |   |    |
  ---    ---

 
 

This proves that segment A can be lit and extinguished and is wired correctly.

 

I have briefly checked the case values. With some confusion over the decimal point DP (which the select-case values indicate would always be lit up) that too is correct.

 

Your simulator shows you have written the byte 0x34 to PORTD. This cannot come frrm the select-case so must be written somewhere else. You should look for where.

Last Edited: Fri. Feb 5, 2021 - 09:38 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What do I know about electronics? But even though it's a four digit 7-seg module don't you still need current limiting resistors (notable by their absence in #14)? If one of the 'a' segments is dead could it have simply "burned out" ?

 

One possible test of that is if you have access to a second 4 digit module (but you may want to consider resistors before connecting?)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

N.Winterbottom wrote:
some confusion over the decimal point DP (which the select-case values indicate would always be lit up)

Yes, I noticed that.

 

Looking at the links clawson provided, it seems that the original code had two tables;  presumably one with DP on, and the other with DP off - and the OP had just posted the one with DP always on ?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

clawson wrote:
don't you still need current limiting resistors

Yes, you do (unless the module has them built in - but I don't think that's common?)

 

example (from google's "visually similar images"):

 

 

EDIT 

 

see #18

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Fri. Feb 5, 2021 - 09:46 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
the original code had two tables

I think that was Common-Anode versus Common Cathode thing.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Nothing more to say... The schematic and code working fine without any modification.

But problem shows only in proteus simulation.!!! Dont know why.....!!!!

Real hardware working fine with the above code....

Thank you so much for all who like to help...🙏

Finally the problem solved and the thread has been close.

Thank you all...

Regards

Manoj soorya

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

manojsethu wrote:
Finally the problem solved and the thread has been close.

So you need to mark the solution - see Tip #5 in my signature, below:

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...