1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Problems of digital clock by 8051...

Discussion in '8051/8951' started by mikemike, Mar 2, 2008.

  1. mikemike

    mikemike New Member

    Joined:
    Jan 27, 2008
    Messages:
    4
    Likes:
    0
    Hi everyone, i'm new in here.
    i'm now doing a digital clock by using 8051 without using a rtc clock chip.
    i've done it by a 16bit mode timer, but after i show to my tutor, he said a 16bit timer can't be so accurate, and it's quite obvious after days running. He suggests me to use 8bit with auto reload instead.
    So, how to do it with a 8bit ones???:confused:

    Thank you very much.
    i'm not so good at microcontroller:eek:
     
  2. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,228
    Likes:
    641
    Location:
    Derbyshire, UK
    Can't help you on 8051's, but I fail to see why an 8 bit timer would be any more accurate than a 16 bit one?. The accuracy of your clock should be dependent upon the accuracy of it's clock source, and how well you program it.
     
  3. mikemike

    mikemike New Member

    Joined:
    Jan 27, 2008
    Messages:
    4
    Likes:
    0
    My tutor explain to me, according to his experiences, the 16bit requires some :mu: s to count over, but the 8bit is count over using hardware(inside 8051). Therefore, it's more accurate than the 16bit one.

    forgive me for my english.
    anyway,thank you for your reply.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. colin mac

    colin mac New Member

    Joined:
    Jun 3, 2007
    Messages:
    367
    Likes:
    4
    Location:
    Ireland

    http://www.edsim51.com/8051Notes/8051/timers.html

    There's a good simulator on that site too.
     
  6. ikalogic

    ikalogic Member

    Joined:
    Dec 27, 2003
    Messages:
    834
    Likes:
    14
    Location:
    Limoges, France
    Well.. i my point of view, what makes the 8-bit counter more reliable, is that the "autorelaoding" is done automatially, always at the same time, but when using a 16 bit timer (in 8051), you have to reload it manually, after an interrupt is exected, or by pooling, making it more difficult to control the timing and acheive precision.

    to set timers, here is small code example:
    Code (text):

    TMOD = 0X25;  //counter 0 in mode 1 (16 bit counter)  , timer 1 in mode 2 (auto reload from TH1
    TH1 = 100; //start timer 1 from 100, it will count 156 steps
    ET1 = 1; //enable timer 1 interrrupt (if you need to, and that's obvious in your application)
    TR1 = 1; //Enable Timer/counter 1 to count
     
    Now, to obtain even more precise timing, try using the maximum crystal frequency that the micro contoller can support. i think it is 36 Mhz if you'r working with 89s52..
     
  7. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,228
    Likes:
    641
    Location:
    Derbyshire, UK
    So basically it's a limitation of the poor hardware?.
     
  8. ikalogic

    ikalogic Member

    Joined:
    Dec 27, 2003
    Messages:
    834
    Likes:
    14
    Location:
    Limoges, France
    No, simply the characteristics of the hardware of the 8051 archtecture. :)
     
  9. Naresh123

    Naresh123 New Member

    Joined:
    Oct 2, 2007
    Messages:
    1
    Likes:
    0
    CAN any one SEND ME Schimeticts & Hex + Source codes for LED display For 8051/AVR

    THANX
     
  10. xainnasir

    xainnasir New Member

    Joined:
    Jan 7, 2012
    Messages:
    19
    Likes:
    0
    Location:
    Lahore Pakistan
    Commercial link deleted - Moderator
     
    Last edited by a moderator: Feb 1, 2016

Share This Page