Making a timer, 32.768kHz+555+DT_INT. Good idea?


Closed Thread
Results 1 to 38 of 38

Hybrid View

  1. #1

    Default Making a timer, 32.768kHz+555+DT_INT. Good idea?

    Hi, I am trying to make a timer where you can store 7 days of ON/OFF times. I have simulated the code & it works fine. The problem is keeping the time right. If I use 32.768kHz as an Oscillator + DT_INT on timer 1, very soon the time goes out of sync, because of the instructions in the main program & also in INT routine.
    I am considering using DT_INT on external INT, and generate 1 sec pulses on PortB.0 using 555 timer IC.
    I would like to know if someone has had the same thought or if there is any other cheaper way to overcome this problem, I don't want to go for expensive RTC ICs.
    ___________________
    WHY things get boring when they work just fine?

  2. #2
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    I think you may just need to adjust the pre load for the timer. If you have access to an O-scope, toggle an output in the INT routine so you can see the actual timing.

    Once the preload is correct, you should find the time is spot on.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  3. #3


    Did you find this post helpful? Yes | No

    Default

    At every interrupt this is what happens in the INT routine.......so actually the number of instructions to be executed, change. So I am not sure tweaking the timer pre-load value will help.
    Code:
    sec=sec+1
    			if sec =60 then
    				sec=0
    				minu=minu+1
    					if minu=60 then
    						minu=0
    						hrs=hrs+1
    							if hrs=24 then
    								hrs=0
    								days=days+1
    									if days=8 then
    										days=1
    									endif
    							endif
    					endif
    			endif
    ___________________
    WHY things get boring when they work just fine?

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Alain did a modification to the Elapsed Timer for use with a 32768hz crystal.

    http://www.picbasic.co.uk/forum/show...5914#post95914
    DT

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Alain did a modification to the Elapsed Timer for use with a 32768hz crystal.

    http://www.picbasic.co.uk/forum/show...5914#post95914
    I am using 16F877A, as not being an expert in programming, my code is quiet long. The amended file is for PIC18 devices.

    @scalerobotics -These RTC ICs are not available that easy where I am. So I am trying to stay clear of them is possible.
    ___________________
    WHY things get boring when they work just fine?

  6. #6
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    The number of instructions in your int routine does not matter as long as it doesn't take more then the amount of time to re interupt. I am guessing your int fires every sec (sec=sec+1). So there is plenty of time. What does matter is the time between the interupt firing and the time your routine is actually entered.This number may well be the difference here. What happens is this:
    The interupt fires (you think 1 sec has passed or whatever your time base is)
    context gets saved
    PBP variables get saved (depends on how you set up DT_INT)
    and finally you enter interupt routine.

    The above can take from 20 - 70 fosc/4 so that could be the out of sync.

    Also I don't see where you re-load the timer, Does it just free run and interupt on each rollover? If so the above information prolly IS NOT relevant. As a side note, you could update all the counters within your main code, just set a flag in the interupt so main can see one has occured.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  7. #7
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by financecatalyst View Post
    .... or if there is any other cheaper way to overcome this problem, I don't want to go for expensive RTC ICs.
    How about cheap RTC ICs? The MCP79410 RTCs are under $1.00 in singles. I got a few samples but have not tried them yet. http://www.microchip.com/en_US/techn...ock/index.html Downside is soic is as big as it gets, no dips. Cheapest from Microchip Direct: http://www.microchipdirect.com/Produ...words=mcp79410

    Features:
    • Real-Time Clock/Calendar (RTCC), Battery
    Backed:
    - Hours, Minutes, Seconds, Day of Week, Day,
    Month and Year
    - Dual alarm with single output
    • On-Chip Digital Trimming/Calibration:
    - Range -127 to +127 ppm
    - Resolution 1 ppm
    • Programmable Open-Drain Output Control:
    - CLKOUT with 4 selectable frequencies
    - Alarm output
    • 64 Bytes SRAM, Battery Backed
    • 1 Kbits EEPROM (128x8):
    - 8 bytes/page
    - Block/sector write protection
    - Protect none, 1/4, 1/2 or all of array
    • Separate 64-Bit Unique ID:
    - User or factory programmable
    - Protected area
    - EUI-48™ or EUI-64™ MAC address
    - Custom ID programming
    • Automatic VCC Switchover to VBAT Backup
    Supply
    • Power-Fail Time-Stamp for Battery Switchover
    • Low-Power CMOS Technology:
    - Dynamic Current: 400 A max read
    - Dynamic Current: 3mA max EEPROM write
    - Battery Backup Current: <700nA @ 1.8V
    • 100 kHz and 400 kHz Compatibility
    • ESD Protection >4,000V
    • More than 1 Million Erase/Write Cycles
    • Packages include 8-Lead SOIC, TSSOP, 2x3
    TDFN, MSOP
    • Pb-Free and RoHS Compliant
    • Temperature Ranges:
    - Industrial (I): -40°C to +85°C.
    Last edited by ScaleRobotics; - 18th December 2010 at 17:22.
    http://www.scalerobotics.com

  8. #8
    Join Date
    Jul 2005
    Location
    Midwest
    Posts
    81


    Did you find this post helpful? Yes | No

    Smile

    Thanks for posting up about the rtc, I'm digging it.
    Happy Holidays.....


    Quote Originally Posted by scalerobotics View Post
    How about cheap RTC ICs? The MCP79410 RTCs are under $1.00 in singles. I got a few samples but have not tried them yet. http://www.microchip.com/en_US/techn...ock/index.html Downside is soic is as big as it gets, no dips. Cheapest from Microchip Direct: http://www.microchipdirect.com/Produ...words=mcp79410

    Features:
    • Real-Time Clock/Calendar (RTCC), Battery
    Backed:
    - Hours, Minutes, Seconds, Day of Week, Day,
    Month and Year
    - Dual alarm with single output
    • On-Chip Digital Trimming/Calibration:
    - Range -127 to +127 ppm
    - Resolution 1 ppm
    • Programmable Open-Drain Output Control:
    - CLKOUT with 4 selectable frequencies
    - Alarm output
    • 64 Bytes SRAM, Battery Backed
    • 1 Kbits EEPROM (128x8):
    - 8 bytes/page
    - Block/sector write protection
    - Protect none, 1/4, 1/2 or all of array
    • Separate 64-Bit Unique ID:
    - User or factory programmable
    - Protected area
    - EUI-48™ or EUI-64™ MAC address
    - Custom ID programming
    • Automatic VCC Switchover to VBAT Backup
    Supply
    • Power-Fail Time-Stamp for Battery Switchover
    • Low-Power CMOS Technology:
    - Dynamic Current: 400 A max read
    - Dynamic Current: 3mA max EEPROM write
    - Battery Backup Current: <700nA @ 1.8V
    • 100 kHz and 400 kHz Compatibility
    • ESD Protection >4,000V
    • More than 1 Million Erase/Write Cycles
    • Packages include 8-Lead SOIC, TSSOP, 2x3
    TDFN, MSOP
    • Pb-Free and RoHS Compliant
    • Temperature Ranges:
    - Industrial (I): -40°C to +85°C.

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