Help with realtime clock and timer


Closed Thread
Results 1 to 21 of 21

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Looks like he's using the internal osc with external crystal for Timer1, but there are still a TON of errors in that schematic.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  2. #2
    geselaw's Avatar
    geselaw Guest


    Did you find this post helpful? Yes | No

    Default

    As you could see in my program("@ device intrc_osc_noclkout" and "PCON.3=1") , I am using the built-in 4MHz internal OSC .The one you see on the schematic was the one that I used for the real time clock on Tmr1 (32.768khz). You will find below the device setup that I used for quick reference.

    Could you please tell me those errors that you saw in the schematic ? I some times have second thought about mixing the digital circuit with the main power (ACS108). I found an error in the schematic and corrected it.The collector part of the phototransistor was connected to the Gnd. It should have been connected to the +ve.The new schematic is attached.

    DEFINE INTHAND myint
    @ device intrc_osc_noclkout
    @ device wdt_off
    @ device lvp_off
    @ device pwrt_on
    @ device cpd_off
    @ device bod_off
    @ device mclr_off
    @ device PROTECT_OFF

    ' **************
    ' *Device setup*
    ' **************
    PIE1.6 = 0 'disable the comparator before mesing with cmcon & vrcon
    VRCON = %10001011 'Voltage Refernece enabled and voltage = 2.97
    pause 10 'for stabiliazing
    CMCON = %10000101 'Single comparator enabled RA0 & RA3 are free for I/O
    PAUSE 10
    PIR1.6 = 0 'clear residing interrupt flag
    PIE1.6 = 1 'enable comparator flag
    pcon.3=1 '1=Internal oscillator 4mhz ,0=37khz
    T1con =%00001111 ' Turn on Timer1 with prescaler = 1
    Pir1.0 = 0 'disable comp & timr1 int flag
    trisb = %00000001
    trisa = %10100110 'PortA 1&2 are analog input ,the rest are digital I/O
    PIE1.0 = 1 ' Enable TMR1 overflow and Comparator interrupt
    INTCON = %11010000 ' Enable global ,peripheral , external interrupts
    Attached Images Attached Images  
    Last edited by geselaw; - 5th October 2005 at 16:17. Reason: Add

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


    Did you find this post helpful? Yes | No

    Default

    geselaw,

    Got your PM. Been gone for a couple days.

    While I'm not real "keen" on the idea of tying AC neutral to VDD, I understand why you did it (for the ACS108's). And if all electricians were guaranteed to wire everything correctly, it may not be a problem. But one day your going to plug this thing into an outlet that's been wired backwards, and somebody's going to get a RUDE awakening when they touch it. Personally, I would use an optically isolated solid state relay, but then, that's just me.

    I see you've increased the resistance to the LED's in the interrupters good, but you didn't increase the ones going to the normal LED's. They'll not last very long with only 15 ohms.

    The collector side of the photo-transistors, after going through the sensitivity adjustment pots, connect to Vss. They need to go to VDD instead.

    The MCLR pin is connected to the 5V out from the 7805. The PIC will RESET when you are trying to run on battery power. It needs to be after the ICL7673. Also, what is R1?

    Hey Bruce, do you see anything else?
    <br>
    DT

  4. #4
    TK5EP's Avatar
    TK5EP Guest


    Did you find this post helpful? Yes | No

    Default Osc ?

    Should't the XTAL be wired between pin 15 and 16 ??

    My 2 cents,

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


    Did you find this post helpful? Yes | No

    Default

    Very funny!!!

    No, he's using the internal oscillator, with a 32768 crystal on Timer1 for a RTC.
    <br>
    DT

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel,

    Haven't gone over the whole schematic - it's pretty cramped & incredibly hard to follow on-screen, but, outside a few things already mentioned, RA4 is an O.C. output attempting to drive an NPN.

    I have no clue what's being controlled with those AC line switches, but I definitely would NOT connect any mains to my DC rails. What happens when one is turned on? With neutral tied to +5Vout and the other AC leg coming right through an AC switched load into the DC rails - it kinda looks like an accident waiting to happen to me...;o}

    I may be wrong. I've never used one of those AC switches, but seems kinda adventurous to me.

    Whole bunch of discreet resistors, pots, etc all with the same part reference #'s, 15-ohm LED limiting resistors (ouch), yada yada.

    I would have to print that one out, and use various colored markers to run it all of it down.

    Looks like a valiant effort, but looks like it may need a little tweaking before flippin the ON switch..}
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  7. #7
    geselaw's Avatar
    geselaw Guest


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel

    All the LED limiting resistors are 150 ohm(typing error).The VDD connection to the phototransistor was corrected and I have posted the new schematic "Scrolling_2" above.About the MCLR though, I thought by disabling it with "@ device mclr_off", I turned it to be a digital input. That is why I tied it to 7805 output so that it would tell the PIC when the main power is off (go to low_power mode to conserve battery energy). I also used (R1)10kohm as a pull down resistor on RA5 so that RA5 would not float when the main power is off. Does it make sense ?

    Hi Bruce

    The ACS108 is used for controlling 110v solenoid.I completely agree with you about using the ACS switch.In the nest version ,opto-isolated solid state really will be used.I have not paid attention to RA4. Thank you for pointing that it is an open drain output. I really need to drive that NPN. I don't know how but either I have to use RA4 with a pull up resistor or use RA2 as in my configuration (VRCON.6 =0) I have not used this port for any thing else. A close examination shows that this pin was configured as digital input (TRISA= %10100110). So I think this might be another problem in my program as this pin could have floated at any time.The problem with RA2 is that it says in the datasheet "The RA2 pin can be used as a simple D/A output with limited drive capability. Due to the limited drive capability, a buffer must be used in conjunction with the Voltage Reference output for external connections to VREF. "

    I really need your advise which way to go.

    Best Regards
    geselaw

Similar Threads

  1. Elapsed Timer Demo
    By Darrel Taylor in forum Code Examples
    Replies: 111
    Last Post: - 29th October 2012, 17:39
  2. Clock with timer interrupt0
    By boban in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 4th November 2009, 14:59
  3. Single digit 7 Seg LED clock - PIC16F88
    By thirsty in forum Code Examples
    Replies: 4
    Last Post: - 17th July 2009, 08:42
  4. Clock using Instant Interrupts
    By PICpocket in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th February 2009, 21:43
  5. clock and date without using real timer
    By eepro in forum Off Topic
    Replies: 1
    Last Post: - 21st September 2008, 02:38

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