Using Pic as a digital clock/timer. How accurate?


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1
    Join Date
    Aug 2005
    Location
    Los angeles
    Posts
    39


    Did you find this post helpful? Yes | No

    Thumbs up

    Thanks Fazan for the code but one thing i didn't understand is how do i get the actual seconds by simply counting? if you count from 1 to 60 does it mean its 1 to 60seconds? can you clarify how you convert from the simple execution time for the count to actual seconds.
    Thanks a lot

  2. #2
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Another Option - might help get you started
    http://www.picbasic.co.uk/forum/showthread.php?t=2129
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  3. #3
    Join Date
    May 2006
    Location
    Kedah, Malaysia
    Posts
    18


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by rocky79 View Post
    Thanks Fazan for the code but one thing i didn't understand is how do i get the actual seconds by simply counting? if you count from 1 to 60 does it mean its 1 to 60seconds? can you clarify how you convert from the simple execution time for the count to actual seconds.
    Thanks a lot
    How accurate it is depend on the speed of oscillator that u use.

  4. #4
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Also, the ambient temp is the most effective factor.

    You can get a slow running or fast running clock ticks depending on the temperature of the environment in which your PIC is running. (ambient temp)

    --------------------------

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink Have a happy new year, Rocky !!!

    Hi, Rocky

    I just built Thermo-baro-clock with a MS5534 sensor.( 16F876 ) the clock is driven by a 32.7... khz "clock crystal" connected to RC0,RC1 pins and using TMR1 ovf interrupt.

    The only way to adjust reading is to trim the TMR1 preset ( 32768 ...in theory ). an adjustable capacitor parallelled to one of the xtal load caps could also help a bit.

    Possible also to use two pushbuttons to inc/dec the TMR preset value, you then store in the EEPROM ... but do not forget to limit the trim range !!!

    But as always ... no simple automatic trimming.

    Absolute references will always be our main headaches ... cause there's none naturally existing !!!

    best regards
    Alain
    Last edited by Acetronics2; - 22nd January 2007 at 12:41.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  6. #6
    Join Date
    Aug 2005
    Location
    Los angeles
    Posts
    39


    Did you find this post helpful? Yes | No

    Wink Happy New Year Acetronics

    Thanks guys for all the help and links. I found a chip that does all the hard work for me on top of that it is featured with 2 alarm settings.
    http://pdfserv.maxim-ic.com/en/ds/DS3232.pdf

    I will give it try and will see how it goes.
    Thanks again

  7. #7
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default

    I've used the clock only version of the chip (a temp. compensated oscilattor) and can attest to it's accuracy. It was hard to get a hold of at the time, though supply might be better now.

    SteveB

  8. #8
    Join Date
    Aug 2005
    Location
    Los angeles
    Posts
    39


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by SteveB View Post
    I've used the clock only version of the chip (a temp. compensated oscilattor) and can attest to it's accuracy. It was hard to get a hold of at the time, though supply might be better now.

    SteveB
    Hello Steve,
    I am using the RTC DS3232 from dallas. you said you have used it before. Can you share your picbasic code? I am having trouble setting the time.
    when i read the time and date. I get them all as 4.
    Here is mine:
    'Using the pic 16f630

    include "modedefs.bas"
    define OSCCAL_1k 1
    CMCON=%0000011' Turn off comparator module


    minutes var byte
    hours var byte
    day var byte
    date var byte
    month var byte
    year var byte

    reset Var PORTC.0

    rtcyear var byte
    rtcday var byte
    rtcmonth var byte
    rtcdate var byte
    rtchour var byte
    rtcmin var byte
    rtcsec var byte

    ' Set initial time to 8:00:00AM 07/16/99
    rtcyear = $99
    rtcday = $06
    rtcmonth = $07
    rtcdate = $16
    rtchour = $08
    rtcmin =0
    rtcsec =0

    startbigNums con 2
    endBigNums con 3
    clrLCD CON 12
    backLightOn con 14
    backLightOff con 15
    cursorPos con 16
    enter con 10
    bell con 7
    b2 var byte
    CONTL CON %01101000


    Low reset 'reset the RTC
    input reset ' undo reset..basically it puts pin reset at high impedance

    'Set the time
    I2cwrite PORTC.2,PORTC.1,CONTL,$01,[rtcmin] 'minutes
    I2cwrite PORTC.2,PORTC.1,CONTL,$02,[rtchour]'hours
    I2cwrite PORTC.2,PORTC.1,CONTL,$03,[rtcday] 'day
    I2cwrite PORTC.2,PORTC.1,CONTL,$04,[rtcdate]'date
    I2cwrite PORTC.2,PORTC.1,CONTL,$05,[rtcmonth]'month
    I2cwrite PORTC.2,PORTC.1,CONTL,$06,[rtcyear] 'year


    pause 10
    'Low reset
    'input reset
    I2cread PORTC.2,PORTC.1,CONTL,$01,[minutes]
    I2cread PORTC.2,PORTC.1,CONTL,$02,[hours]
    I2cread PORTC.2,PORTC.1,CONTL,$03,[day]
    I2cread PORTC.2,PORTC.1,CONTL,$04,[date]
    I2cread PORTC.2,PORTC.1,CONTL,$05,[month]
    I2cread PORTC.2,PORTC.1,CONTL,$06,[year]

    serout2 0,16780,[clrLCD,"Time",hex hours,":",hex minutes,enter,_
    "date:",hex date,"/",hex month,"/",hex year]
    end

Similar Threads

  1. Digital clock thermometer Calendar PIC 16F628
    By valdirdf in forum Code Examples
    Replies: 0
    Last Post: - 31st May 2009, 01:52
  2. PIC 18f4680 DIGITAL INPUTS
    By MegaADY in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 30th July 2008, 07:34
  3. Digital Holter with PIC ?!
    By Eugeniu in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 28th November 2007, 10:37
  4. Pic driven digital audio delay
    By skimask in forum Off Topic
    Replies: 12
    Last Post: - 19th April 2007, 20:42
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts