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

Master Slave Clocks with PIC16F887

Discussion in 'Microcontrollers' started by koolguy, Mar 31, 2015.

  1. granddad

    granddad Active Member

    Joined:
    Jan 18, 2015
    Messages:
    762
    Likes:
    76
    Location:
    Worcestershire UK
    Ian is your second name Job ... :) as in patience of...
     
    Last edited: Apr 13, 2015
  2. koolguy

    koolguy Active Member

    Joined:
    Aug 24, 2010
    Messages:
    2,196
    Likes:
    9
    there should sensor i.e. ADC to detect power failure and store in Memory.

    I think i should be stored in EEPROM or internal register of DS1307.
     
  3. koolguy

    koolguy Active Member

    Joined:
    Aug 24, 2010
    Messages:
    2,196
    Likes:
    9
    Hello sir,
    I have changed some code!
    actually i am once writing the time in micro. after that i am removing/re programming the micro by deleting the write function.
    so, it run internally the ds1307 chip...
    it is working is it fine procedure to run ds1307??
     
  4. dave

    Dave New Member

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


     
  5. koolguy

    koolguy Active Member

    Joined:
    Aug 24, 2010
    Messages:
    2,196
    Likes:
    9

    Hello,
    The Clock is running internaly i have set the time one and removed the write function for making update from outter switch!
    i have place the up and down switch with pull ups at RD4-5 . but it is not responding here is if code parrts

    Code (C):
    if(RD4==0|| RD5==0){
    //Time[] = {0x05, 0x30 ,0x08, 0x22 , 0x10, 0x4, 0x15};

    if(RD4==0) // UP MIN HOUR
    {
    up_min= up_min+1;
    up_hour=up_hour+1;
    Time[1]=up_min;
    Time[2]=up_hour;
    WriteClock(&Time[0]);
    }
    if(RD5==0) // UP MIN HOUR
    {
    up_min= up_min-1;
    up_hour=up_hour-1;
    Time[1]=up_min;
    WriteClock(&Time[0]);
    Time[2]=up_hour;

    }
    }
     
  6. koolguy

    koolguy Active Member

    Joined:
    Aug 24, 2010
    Messages:
    2,196
    Likes:
    9
    Hello,
    ds3231 vs ds1307 which better?
    Is Ds1307 fine for RTC projects??
     
  7. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,310
    Likes:
    914
    Location:
    Rochdale UK
    Hi R... I have been in Scotland these past few days.... Please give me a while to catch up!!

    I always use the DS1307.. Can't comment about the other one...
     
    • Like Like x 1
  8. Mosaic

    Mosaic Well-Known Member

    Joined:
    Jun 3, 2010
    Messages:
    2,620
    Likes:
    129
    Location:
    Caribbean
    • Like Like x 1
  9. koolguy

    koolguy Active Member

    Joined:
    Aug 24, 2010
    Messages:
    2,196
    Likes:
    9
    Hello,
    How to add external time set switch to update clock?
     
  10. koolguy

    koolguy Active Member

    Joined:
    Aug 24, 2010
    Messages:
    2,196
    Likes:
    9
    hello,
    I don't know how to write, need guidance.

    Code (C):
      if(RD5==1){
    unsigned char a=0;
    a=a+1;
    }
    if(RD6==1){
    unsigned char a=0;
    a=a-1;
    }
    WriteClock(&Time[0]);
      }
      }  
    unsigned char Time[] = {0x11, 0x11 ,0x11, 0x00 , 0x10, 0x4, 0x15};
     
     
  11. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,310
    Likes:
    914
    Location:
    Rochdale UK
    The function I wrote was this
    Code (c):

    void WriteClock(char *array)       // Not used
       {
       char x;
       int tmp;
       for(x=0;x<7;x++)
         {
         tmp = array[x] / 10;
         tmp << = 4;
         tmp += array[x] % 16;
         WriteRTC(x,tmp);
         }
       }
     
    This function takes care of writing to the RTC... The array is pointing to the Time[] array.. Whatever is in that array will be written to the RTC... The function also takes care of the BIN / BCD conversion, so you don't need to!!
     

Share This Page