Comments on: Digital Clock using PIC Microcontroller and DS1307 RTC https://electrosome.com/digital-clock-pic-microcontroller-ds1307/ You Inspire.....We Create..... Sun, 29 May 2022 09:14:09 +0000 hourly 1 https://wordpress.org/?v=6.1.1 By: B K.Leelesh https://electrosome.com/digital-clock-pic-microcontroller-ds1307/#comments/10079 Sun, 29 May 2022 09:14:09 +0000 https://electrosome.com/?p=1918#comment-10079 Please help me to change the 24 hour format.

]]>
By: Ligo George https://electrosome.com/digital-clock-pic-microcontroller-ds1307/#comments/9844 Sun, 03 Jan 2021 06:47:12 +0000 https://electrosome.com/?p=1918#comment-9844 In reply to Darius Toorkey.

Try adjusting LCD contrast.

]]>
By: Ligo George https://electrosome.com/digital-clock-pic-microcontroller-ds1307/#comments/9840 Sun, 03 Jan 2021 06:40:48 +0000 https://electrosome.com/?p=1918#comment-9840 In reply to Aravindhan Nagaraj.

It won’t be the problem with code. I have experienced similar issue. Refer the datasheet and follow the recommended practices to increase the accuracy. I recommend to use some other RTC chips like DS3231 for better accuracy.

]]>
By: Aravindhan Nagaraj https://electrosome.com/digital-clock-pic-microcontroller-ds1307/#comments/9836 Wed, 23 Dec 2020 14:02:15 +0000 https://electrosome.com/?p=1918#comment-9836 i wrote code for digital clock using pic16f886 and ds1307…….code working but while running for few weeks…..minutes gets increases upto 1- 5 from set time……. why?
i attach my code here………what is the problem? help me
unsigned int hex(int y)
{
switch(y)
{
case 1: return 0xCF;
case 2: return 0xA4;
case 3: return 0x86;
case 4: return 0x8B;
case 5: return 0x92;
case 6: return 0x98;
case 7: return 0xC7;
case 8: return 0x80;
case 9: return 0x83;
case 0: return 0xC0;
}
}

unsigned short ReadI2C(unsigned short address)
{
unsigned short temp;
I2C1_Start();
I2C1_Wr(0xD0); //address 0x68 followed by direction bit (0 for write, 1 for read) 0x68 followed by 0 –> 0xD0
I2C1_Wr(address);
I2C1_Repeated_Start();
I2C1_Wr(0xD1); //0x68 followed by 1 –> 0xD1
temp=I2C1_Rd(0);
I2C1_Stop();
return(temp);

}
void write_ds1307(unsigned short address,unsigned short w_data)
{
I2C1_Start(); // issue I2C start signal
//address 0x68 followed by direction bit (0 for write, 1 for read) 0x68 followed by 0 –> 0xD0
I2C1_Wr(0xD0); // send byte via I2C (device address + W)

I2C1_Wr(address); // send byte (address of DS1307 location)
I2C1_Wr(w_data); // send data (data to be written)
I2C1_Stop(); // issue I2C stop signal
}
int Binary2BCD(int a)
{
int t1, t2;
t1 = a%10;
t1 = t1 & 0x0F;
a = a/10;
t2 = a%10;
t2 = 0x0F & t2;
t2 = t2 <> 4;
t = 0x0F & t;
r = t*10 + r;
return r;
}
unsigned short set_count = 0;
short set;
int minute;
int hour;
int a=1,b=1;
char min,hr,t,l=10;
void main()
{

I2C1_Init(100000);
OSCCON.IRCF0=1;
OSCCON.IRCF1=1;
OSCCON.IRCF2=1;
ANSEL = 0;
ANSELH = 0;
TRISB=0x00;

TRISC.F0=0;

TRISC.F3=1;
TRISC.F4=1;
TRISC.F5=0;

TRISA.F0=1;
TRISA.F1=1;
TRISA.F2=0;
TRISE.F3=1;
TRISA.F5=0;

while(1)
{
// ReadI2C(7);

min=ReadI2C(1);
t= ReadI2C(2);
hr = t & 0b00011111;
min=((min & 0xf0)>>4)* 10 +(min & 0x0f);
hr=((hr & 0xf0)>>4)* 10 +(hr& 0x0f);
if(a==1)
{
PORTB = hex(min%10);
PORTC.F5= 1;
Delay_ms(5);
PORTC.F5=0;
PORTB = hex((min/10)%10);
PORTC.F0 = 1;
Delay_ms(5);
PORTC.F0 = 0;
}
if(b==1)
{
PORTB = hex(hr%10);
PORTA.F5 = 1;
Delay_ms(5);
PORTA.F5 = 0;
PORTB = hex((hr/10)%10);
PORTA.F2 = 1;
Delay_ms(5);
PORTA.F2 = 0;
}

set = 0;
if(PORTE.F3== 0)
{
Delay_ms(100);
if(PORTE.F3 == 0)
{
set_count++;
if( set_count==1)
{
a=0;
b=1;
}
if( set_count==2)
{
a=1;
b=0;
}
if(set_count >= 3)
{
set_count = 0;
a=1;
b=1;
write_ds1307(0,0×00);
write_ds1307(7,0×10);

}
}
}
if(set_count)
{
if(PORTA.F0 == 0)
{
Delay_ms(100);
if(PORTA.F0 == 0)
set = 1;
}
if(PORTA.F1 == 0)
{
Delay_ms(100);
if(PORTA.F1 == 0)
set = -1;
}
if(set_count && set)
{
switch(set_count)
{
case 1:
hour = BCD2Binary(hour);
hour = hour + set;
Delay_ms(250);
hour = Binary2BCD(hour);
if((hour & 0x1F) >= 0x13)
{
hour = hour & 0b11100001;
hour = hour ^ 0x20;
}
else if((hour & 0x1F) = 60)
minute = 0;
if(minute < 0)
minute = 59;
minute = Binary2BCD(minute);
write_ds1307(1, minute); //write min
break;

}
}

}
}
}

]]>
By: Darius Toorkey https://electrosome.com/digital-clock-pic-microcontroller-ds1307/#comments/9816 Thu, 26 Nov 2020 16:33:35 +0000 https://electrosome.com/?p=1918#comment-9816 Thank you for the circuit and explanation. As I do not have the Mickro compiler, I constructed the clock and programmed the PIC using the hex file available in the download. The LCD display just shows black boxes only in the first line after proper adjustment of the contrast. I could not find any other person having a similar comment and am at a loss of what to do. Any suggestion ? Thanks

]]>
By: Sujee Shines https://electrosome.com/digital-clock-pic-microcontroller-ds1307/#comments/7390 Sat, 06 Apr 2019 22:47:02 +0000 https://electrosome.com/?p=1918#comment-7390 Could anyone tell me how to set time for first setup…?!!

]]>
By: Rehman https://electrosome.com/digital-clock-pic-microcontroller-ds1307/#comments/7233 Wed, 02 Jan 2019 19:28:30 +0000 https://electrosome.com/?p=1918#comment-7233 Plz explain how this conversion is taking place.

int Binary2BCD(int a) //Rehman! Here ‘a’ is the given binary number
{
int t1, t2;
t1 = a%10; //Rehman! This will give the 2nd digit ie right dgit
t1 = t1 & 0x0F;
a = a/10; //This will give the First digit i.e left digit……………………
t2 = a%10;
t2 = 0x0F & t2;
t2 = t2 << 4; t2 = 0xF0 & t2; t1 = t1 | t2; return t1; }

]]>
By: Akanksha Kumari https://electrosome.com/digital-clock-pic-microcontroller-ds1307/#comments/7127 Fri, 06 Jul 2018 03:55:15 +0000 https://electrosome.com/?p=1918#comment-7127 Hi, Sir will you provide the header files used in this code specially for the LCD and I2C

]]>
By: Ligo George https://electrosome.com/digital-clock-pic-microcontroller-ds1307/#comments/7054 Sat, 21 Apr 2018 02:54:44 +0000 https://electrosome.com/?p=1918#comment-7054 In reply to Amal.E. Md.

You can compare the time and do it easily. We have a premium and professionally developed school bell project. If you need just drop a mail to [email protected]

]]>
By: Amal.E. Md https://electrosome.com/digital-clock-pic-microcontroller-ds1307/#comments/7045 Fri, 13 Apr 2018 07:40:51 +0000 https://electrosome.com/?p=1918#comment-7045 hi, how to set an alarm for this project?

]]>