Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 4th January 2008, 06:32 AM   (permalink)
Experienced Member
ssylee is on a distinguished road
Default Using a PIC microcontroller to interface with a DS1302 real time clock

I am using a PIC18F2620 to interface with a DS1302 real time clock. I haven't manually set the time using push button switches yet. I have a set of functions including various data transfer functions, a set of functions that involves setting the current time, a set of functions involving reading the time and displaying it on the LCD, and a function that starts or stops the clock and another function that sets or clears the write protect bit. It appears that the displaying part of the routine is correct, but the actual time displayed is nowhere close to the time that I have set it to. I have checked the timing on the chip enable as well as the SCLK pin, however, they are quite erratic. Does someone have any recommendations on what I should do next? Thanks!
ssylee is offline   Reply With Quote
Old 4th January 2008, 06:00 PM   (permalink)
New Member
pwssr is on a distinguished road
Default

Quote:
Originally Posted by ssylee
I am using a PIC18F2620 to interface with a DS1302 real time clock. I haven't manually set the time using push button switches yet. I have a set of functions including various data transfer functions, a set of functions that involves setting the current time, a set of functions involving reading the time and displaying it on the LCD, and a function that starts or stops the clock and another function that sets or clears the write protect bit. It appears that the displaying part of the routine is correct, but the actual time displayed is nowhere close to the time that I have set it to. I have checked the timing on the chip enable as well as the SCLK pin, however, they are quite erratic. Does someone have any recommendations on what I should do next? Thanks!
Sounds like there is an issue with the Crystal connection. You need to make sure the leads are as short as possible and solidly connected to the pins (2 & 3).
pwssr is offline   Reply With Quote
Old 4th January 2008, 07:36 PM   (permalink)
Experienced Member
ssylee is on a distinguished road
Default

I have a 32 kHz crystal connected between pins 2 and 3 on the breadboard. Not sure if that helps with the problem.
ssylee is offline   Reply With Quote
Old 4th January 2008, 08:26 PM   (permalink)
Super Moderator
 
Nigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to behold
Default

Quote:
Originally Posted by ssylee
I have a 32 kHz crystal connected between pins 2 and 3 on the breadboard. Not sure if that helps with the problem.
Perhaps the part in red might give you a clue?, breadboards are notorious for poor connections, and have too much capacitance for many uses. Strangely enough I had occasion to scope a 32KHz crystal yesterday - even with a x10 probe it killed the oscillator on one side of the crystal - and that's a LOT less capacitance than a breadboard.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now   Reply With Quote
Old 4th January 2008, 08:30 PM   (permalink)
Experienced Member
ssylee is on a distinguished road
Default

So you're suggesting me to wire up the circuit on an actual circuit board before proceding?
ssylee is offline   Reply With Quote
Old 4th January 2008, 08:40 PM   (permalink)
Super Moderator
 
Nigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to behold
Default

Quote:
Originally Posted by ssylee
So you're suggesting me to wire up the circuit on an actual circuit board before proceding?
Yes, at least the DS1302 part - I NEVER use breadboards at all!.

You don't need to etch a PCB, use a piece of veroboard (stripboard).
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now   Reply With Quote
Old 4th January 2008, 09:51 PM   (permalink)
Experienced Member
 
atferrari is on a distinguished road
Default

Hola Nigel,

I am not trying to say that it should work for anyone else, out there, but in more than 15 years, all my projects, 90% with PICs (starting with the 16C57) were breadboarded. And worked OK.

Yes, with a Xtal of 4 MHz maximum.

Bad quality breadboards (easy to run across) are a trap due to poor contact, I admit.

I insist; that is my experience and not a suggestion to use them.
__________________
Agustín Tomás
In theory, there is no difference between theory and practice. In practice, however, there is.
atferrari is offline   Reply With Quote
Old 4th January 2008, 10:26 PM   (permalink)
Experienced Member
 
picasm will become famous soon enough
Default

Do you have a capacitor (0.1uF) close to the DS1302 chip between the power pins (1&4) and also pullup resistors (4.7K) on pins 5,6&7.
Ommiting any of those items could make it unreliable.

As others have already said, the crystal placement etc. is very important and it is dealt with in a Maxim app note:
http://www.maxim-ic.com/appnotes.cfm/appnote_number/58
picasm is offline   Reply With Quote
Old 4th January 2008, 11:01 PM   (permalink)
Experienced Member
richard.c will become famous soon enough
Default

Don't forget that you can simply connect the 32k crystal and caps to the Tmr1 pins of the 18F2620 and create you own RTC as shown in the Mchip users manual.
richard.c is offline   Reply With Quote
Old 5th January 2008, 12:12 AM   (permalink)
Experienced Member
ssylee is on a distinguished road
Default

Quote:
Originally Posted by picasm
Do you have a capacitor (0.1uF) close to the DS1302 chip between the power pins (1&4) and also pullup resistors (4.7K) on pins 5,6&7.
Ommiting any of those items could make it unreliable.

As others have already said, the crystal placement etc. is very important and it is dealt with in a Maxim app note:
http://www.maxim-ic.com/appnotes.cfm/appnote_number/58
I didn't have a 0.1 uF capacitor connected in between the power pins. I also didn't have pull up resistors on pins 5, 6, 7. I didn't do so b/c I don't recall seeing notes about them on the datasheet.
ssylee is offline   Reply With Quote
Old 5th January 2008, 12:22 AM   (permalink)
Experienced Member
 
Blog Entries: 4
blueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to behold
Send a message via Skype™ to blueroomelectronics
Default

Well you need them. The datasheet will describe the part, not the system. Example in the 16F877A datasheet the USART does not describe a MAX232 and vice versa.
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is offline   Reply With Quote
Old 5th January 2008, 05:09 AM   (permalink)
Experienced Member
ssylee is on a distinguished road
Default

What I meant was I didn't see anything about the pullup resistors in the DS1302 datasheet. Btw, after soldering the circuit on a PCB and adding the pullup resistors, it appears that I am still getting the same result. Could the problem be with my code as well?
ssylee is offline   Reply With Quote
Old 5th January 2008, 06:32 AM   (permalink)
Experienced Member
 
Blog Entries: 4
blueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to behold
Send a message via Skype™ to blueroomelectronics
Default

I hate to show myself wrong but I guess I had I2C on the brain. The DS1302 does have built in 40K pull DOWN resistors, so take out those pullups.

But to make up for it here's the DS1305 and PIC16F628 with schematic and code.
http://www.maxim-ic.com/appnotes.cfm...te_number/2361
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is offline   Reply With Quote
Old 5th January 2008, 09:08 AM   (permalink)
Super Moderator
 
Nigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to behold
Default

Quote:
Originally Posted by atferrari
Hola Nigel,

I am not trying to say that it should work for anyone else, out there, but in more than 15 years, all my projects, 90% with PICs (starting with the 16C57) were breadboarded. And worked OK.

Yes, with a Xtal of 4 MHz maximum.
You didn't fully read my post, a scope and x10 probe stopped the 32KHz (NOT 4MHz) crystal working on Thursday when I had occasion to try one, and that's considerably less capacitance than a breadbopard adds!. Considering he appears to be having trouble with his 32KHx crystal, that could well be the reason?.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now   Reply With Quote
Old 5th January 2008, 10:04 AM   (permalink)
Experienced Member
 
picasm will become famous soon enough
Default

Quote:
Originally Posted by blueroomelectronics
I hate to show myself wrong but I guess I had I2C on the brain. The DS1302 does have built in 40K pull DOWN resistors, so take out those pullups.
Sorry, I was thinking of the DS1307 when I said that it needed the pullup resistors. You are absolutly right, the DS1302 does not need them.
picasm is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
Real Time FLIR Video Feed digital0ne Robotics Chat 3 11th April 2004 06:21 PM
digital clock setting the time mode Jay Duluguin Electronic Projects Design/Ideas/Reviews 0 19th February 2004 10:09 PM
real time clock finst Micro Controllers 4 17th January 2004 12:11 AM
list of Real Time Clock thendo Micro Controllers 2 8th November 2003 05:41 PM
time clock gogo01 Electronic Projects Design/Ideas/Reviews 2 22nd August 2003 05:05 AM



All times are GMT. The time now is 10:30 AM.


Electronic Circuits  |  Radio Controlled
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.