caramoan tour package

caramoan tour package

Author Topic: need help with program to interface DS1307 with 16F877  (Read 5229 times)

Offline elizabeth ann

  • CR2032 Battery
  • **
  • Posts: 28
  • Pogi/Ganda Points: 1
  • omni initium est deficille
need help with program to interface DS1307 with 16F877
« on: February 16, 2008, 09:47:02 PM »
hello everyone.

i'm new here, i would like to ask for some assistance regarding my project, which on interfacing DS1307 with 16F877. basically i will be using this on my programmable medicine dispenser, and i need DS1307 as my clock source and synchronization so that the medications will always be on time. how do i call the DS1307 so that if a preset time is reached (input through keypad), the microcontroller will signal an alarm and a blinking LED indicator?

Thanks!

Elizabeth Ann
bulletproof loneliness....

Philippine Electronics Forum

need help with program to interface DS1307 with 16F877
« on: February 16, 2008, 09:47:02 PM »

Offline toasted siopao

  • She loves me, she loves me not, she loves me...
  • Global Moderator
  • Gas Turbine
  • *****
  • Posts: 2574
  • Pogi/Ganda Points: 107
  • Gender: Female
    • TeknoBlogger
Re: need help with program to interface DS1307 with 16F877
« Reply #1 on: February 16, 2008, 10:31:34 PM »
You are using CCS C, right?

Philippine Electronics Forum

Re: need help with program to interface DS1307 with 16F877
« Reply #1 on: February 16, 2008, 10:31:34 PM »

Offline 0b00000111

  • Technical People
  • Solar Power Satellite
  • *****
  • Posts: 6129
  • Pogi/Ganda Points: 398
  • There is no delight in owning anything unshared.
Re: need help with program to interface DS1307 with 16F877
« Reply #2 on: February 17, 2008, 09:21:46 AM »
hello everyone.

i'm new here, i would like to ask for some assistance regarding my project, which on interfacing DS1307 with 16F877. basically i will be using this on my programmable medicine dispenser, and i need DS1307 as my clock source and synchronization so that the medications will always be on time. how do i call the DS1307 so that if a preset time is reached (input through keypad), the microcontroller will signal an alarm and a blinking LED indicator?

Thanks!

Elizabeth Ann


looking through the datasheet of DS1307, it looks like you have to poll it using I2C to check the reading against your preset time.
E-Gizmo Mechatronix Central: www.e-gizmo.com

Tel #: (63)(2) 536-3378
Globe +63915-973-7691
Smart +63921-779-0748

Location Map

YM: julie.egizmo  aka Born2BeWired  ;D

Philippine Electronics Forum

Re: need help with program to interface DS1307 with 16F877
« Reply #2 on: February 17, 2008, 09:21:46 AM »

Offline paranz

  • Technical People
  • Nuclear Reactor
  • *****
  • Posts: 4525
  • Pogi/Ganda Points: 177
  • Gender: Male
  • 1/4W resistor specialist
    • RapidSignal Electronics
Re: need help with program to interface DS1307 with 16F877
« Reply #3 on: February 17, 2008, 09:53:51 AM »
i think hindi yata makagenerate ng interrupt ang DS1307, if im not mistaken so agree ako na i-poll ng 16F877 via SPI.

Set your microcontroller to sleep mode, to be awaken by the WDT (i think every 2 seconds yata max). When the microcontroller awakens, read data from DS1307, check if preset time is reached, then sleep() again, and so on
PIC16 Programming Tutorial using MPLAB and Hi-Tech C
www.rapidsignalph.com/tutorials/pic16-tutorials

Arduino & gizDuino Tutorials
www.rapidsignalph.com/tutorials/arduino-tutorials

Philippine Electronics Forum

Re: need help with program to interface DS1307 with 16F877
« Reply #3 on: February 17, 2008, 09:53:51 AM »

Offline elizabeth ann

  • CR2032 Battery
  • **
  • Posts: 28
  • Pogi/Ganda Points: 1
  • omni initium est deficille
Re: need help with program to interface DS1307 with 16F877
« Reply #4 on: February 18, 2008, 06:18:16 PM »
many thanks to paranz, sevenstring, and adviser/master glenjoy for the response.

YES i am using CCS C. i have already developed a driver for DS1307. the problem is, i don't know how to call (in a single routine,perhaps) a comparison of the current time generated by DS1307 against my preset time (input using keypad). can anyone share a sample routine for that?pleaseeeeeeeee......

frankly i'm very much a newbie on calling interrupts as well as WDTs, how do i set the microcontroller to sleep mode? i hope this is not a very silly question to you, experts.

your replies will be highly appreciated. thumbs up to all microcontroller masters, and thank you...

elizabeth ann

bulletproof loneliness....

Philippine Electronics Forum

Re: need help with program to interface DS1307 with 16F877
« Reply #4 on: February 18, 2008, 06:18:16 PM »

Offline motion55

  • Technical People
  • Diesel Generator
  • *****
  • Posts: 1880
  • Pogi/Ganda Points: 244
  • Gender: Male
  • Been at this longer than you've been alive.
Re: need help with program to interface DS1307 with 16F877
« Reply #5 on: February 18, 2008, 07:14:02 PM »
Quote
how do i set the microcontroller to sleep mode?

You let the MCU execute a "SLEEP" instruction. Since it is an assembly language instruction and in CCS C, you insert the ff. line of code

Code: [Select]
#asm
 SLEEP
#endasm

Before you execute the sleep instruction, make sure the PIC can wake up from sleep. One way is to enable interrupts for particular event such as the interrupt pin, key press or timer interrupt.

Is the device you are making battery operated? That is the most common use to put to sleep an MCU, to conserve power by shutting down the MCU to conserve power.

Are you forced to use the DS1307? If not why not use the more common clock chip found in the PC's like the DS12887 or similar parts. It has a buillt-in alarm, crystal and battery.
"Set your mind free!"

Offline elizabeth ann

  • CR2032 Battery
  • **
  • Posts: 28
  • Pogi/Ganda Points: 1
  • omni initium est deficille
Re: need help with program to interface DS1307 with 16F877
« Reply #6 on: February 18, 2008, 08:56:43 PM »
You let the MCU execute a "SLEEP" instruction. Since it is an assembly language instruction and in CCS C, you insert the ff. line of code

Code: [Select]
#asm
 SLEEP
#endasm

Before you execute the sleep instruction, make sure the PIC can wake up from sleep. One way is to enable interrupts for particular event such as the interrupt pin, key press or timer interrupt.

Is the device you are making battery operated? That is the most common use to put to sleep an MCU, to conserve power by shutting down the MCU to conserve power.

Are you forced to use the DS1307? If not why not use the more common clock chip found in the PC's like the DS12887 or similar parts. It has a buillt-in alarm, crystal and battery.


many thanks for that reply...very specific. and straightforward.

no, the device that we are constructing is not battery-operated. is the DS12887 i2c-compatible?
bulletproof loneliness....

Offline ferds

  • Size AA Battery
  • ****
  • Posts: 120
  • Pogi/Ganda Points: 22
  • Gender: Male
    • my projects
Re: need help with program to interface DS1307 with 16F877
« Reply #7 on: February 18, 2008, 09:02:43 PM »
nagawa ko na ito.. pero PBP ang gamit ko.. try ko hanapin ung code na ginamit ko...
x--------> www.FerdsAudio.com <---------x

Offline razalas

  • Size AA Battery
  • ****
  • Posts: 132
  • Pogi/Ganda Points: 6
  • Gender: Male
Re: need help with program to interface DS1307 with 16F877
« Reply #8 on: February 18, 2008, 09:13:43 PM »
No, DS12887  is parallel com port. Meron syang interupt so pwede mo syang interface sa PIC using interrupt without using WDT. Pero be sure to init  RTC's control registers.... :)

Offline motion55

  • Technical People
  • Diesel Generator
  • *****
  • Posts: 1880
  • Pogi/Ganda Points: 244
  • Gender: Male
  • Been at this longer than you've been alive.
Re: need help with program to interface DS1307 with 16F877
« Reply #9 on: February 18, 2008, 09:58:20 PM »
Code: [Select]
No, the device that we are constructing is not battery-operated. is the DS12887 i2c-compatible?
Then why do you want to put the PIC to sleep? You can let the PIC constantly poll the DS1307 at least once a second or even faster. There is no harm done by letting it work its idle time off. This way you don't worry about interrupts and stuff.

Why do you need i2c compatibility? Did someone require you to do that? Do you already have the DS1307 on hand? If not, maybe there are more readily available parts you can cannibalize from old PC's.
"Set your mind free!"

Offline ferds

  • Size AA Battery
  • ****
  • Posts: 120
  • Pogi/Ganda Points: 22
  • Gender: Male
    • my projects
Re: need help with program to interface DS1307 with 16F877
« Reply #10 on: February 18, 2008, 10:54:34 PM »
hello everyone.

i'm new here, i would like to ask for some assistance regarding my project, which on interfacing DS1307 with 16F877. basically i will be using this on my programmable medicine dispenser, and i need DS1307 as my clock source and synchronization so that the medications will always be on time. how do i call the DS1307 so that if a preset time is reached (input through keypad), the microcontroller will signal an alarm and a blinking LED indicator?

Thanks!

Elizabeth Ann


Check mo itong mga Sample programs pra sa DS1307.. hindi sila for CCS but for Picbasic Pro pero pwde mo gawing references kung papaano gamitin DS1307.. gud luck..

http://www.melabs.com/resources/samples/xusb/pbp/rtcxu.bas
http://www.melabs.com/resources/samples/submitted/MN1307.txt
x--------> www.FerdsAudio.com <---------x

Offline elizabeth ann

  • CR2032 Battery
  • **
  • Posts: 28
  • Pogi/Ganda Points: 1
  • omni initium est deficille
Re: need help with program to interface DS1307 with 16F877
« Reply #11 on: February 19, 2008, 10:53:29 PM »
Code: [Select]
No, the device that we are constructing is not battery-operated. is the DS12887 i2c-compatible?
Then why do you want to put the PIC to sleep? You can let the PIC constantly poll the DS1307 at least once a second or even faster. There is no harm done by letting it work its idle time off. This way you don't worry about interrupts and stuff.

Why do you need i2c compatibility? Did someone require you to do that? Do you already have the DS1307 on hand? If not, maybe there are more readily available parts you can cannibalize from old PC's.


thanks everyone for the patience and attention...hihi... ;D

by the way, i have been reading the datasheet of DS1307 and it just proved you guys right, we need to keep a monitored record of the time. you're right, maybe i can poll the DS1307 from time to time.

yes i already have samples of DS1307 from Maxim (is it ok to mention the company?Lol i just did!)

by the way, to make things more complicated, i will be needing that same program/routine for a total of 100 medicine dispensers. that's what my project is, in a nutshell. i will be using Port Expanders (specifically MAX7318) to handle all the keypad inputs in just one microcontroller, so that i don't have to complicate the task with letting micros communicate with each other.

are there any better ideas? please i would love to hear them. thank you...

elizabeth ann
bulletproof loneliness....

Offline elizabeth ann

  • CR2032 Battery
  • **
  • Posts: 28
  • Pogi/Ganda Points: 1
  • omni initium est deficille
Re: need help with program to interface DS1307 with 16F877
« Reply #12 on: February 20, 2008, 11:57:31 AM »
ayos ka mcu_expert, fan na fan ka nga ng mga halaman, magkakasundo kayo ng mama ko.hehe...

SPI? d ako masyadong familiar dun... I2C kasi ang pinag-aaralan namin ngayon, d ko alam kung kakayanin pa ng oras na magventure sa iba pang protocol kasi we have roughly 2 weeks to get everything done. pero pag may time ako after graduation, aayusin ko yun para din sa mga halaman ni mama...hihihihi
bulletproof loneliness....

Offline kamote

  • Size AA Battery
  • ****
  • Posts: 126
  • Pogi/Ganda Points: 4
Re: need help with program to interface DS1307 with 16F877
« Reply #13 on: February 22, 2008, 05:30:17 PM »
          tama ang mga masters, you have to regularly poll ds1307, para macheck  ang time, may ginawa akong automatic water sprayer operates like that pero DS1302 ginamit ko, SPI kaya madali, meron itong 32 bytes ram na pwede isave ang time settings in case of power failure, meron din trickle charging option para sa back up battery.

          lab na lab ko kasi mga halaman ko kaya ginawan ko neto, may rain sensor para isara ang kulambo sasara kung umuulan, meron din LM35DZ temp sensor para isara ang kulambo kung mainit, pede iset kung ano oras magdidilig at gaano katagal at kung anong gustong temperatura.


tama gumawa ka ng timer interrupt sa pic madali lang siyang iimplement :P

Offline 0b00000111

  • Technical People
  • Solar Power Satellite
  • *****
  • Posts: 6129
  • Pogi/Ganda Points: 398
  • There is no delight in owning anything unshared.
Re: need help with program to interface DS1307 with 16F877
« Reply #14 on: February 22, 2008, 06:05:14 PM »

thanks everyone for the patience and attention...hihi... ;D

by the way, i have been reading the datasheet of DS1307 and it just proved you guys right, we need to keep a monitored record of the time. you're right, maybe i can poll the DS1307 from time to time.

yes i already have samples of DS1307 from Maxim (is it ok to mention the company?Lol i just did!)

by the way, to make things more complicated, i will be needing that same program/routine for a total of 100 medicine dispensers. that's what my project is, in a nutshell. i will be using Port Expanders (specifically MAX7318) to handle all the keypad inputs in just one microcontroller, so that i don't have to complicate the task with letting micros communicate with each other.

are there any better ideas? please i would love to hear them. thank you...

elizabeth ann

product ba yan ng company nyo? you will be able to reduce your BOM cost by just eliminating the MAX7318 and creating instead a 4X4 Hex Keypad Matrix using 8bits of port...
E-Gizmo Mechatronix Central: www.e-gizmo.com

Tel #: (63)(2) 536-3378
Globe +63915-973-7691
Smart +63921-779-0748

Location Map

YM: julie.egizmo  aka Born2BeWired  ;D

Offline elizabeth ann

  • CR2032 Battery
  • **
  • Posts: 28
  • Pogi/Ganda Points: 1
  • omni initium est deficille
Re: need help with program to interface DS1307 with 16F877
« Reply #15 on: March 02, 2008, 12:50:10 AM »
sorry for the very late reply...

well i'm glad to tell everyone that our project is almost finished...DS1307 with 16F877A worked fine both in simulation and actual basis. also, i have successfully implemented basic(i mean, easy) codes such as displaying text and current time in the LCD by pressing certain buttons in the keypad.

and yes sevenstring, i have successfully implemented the port expander to handle the 100 alarm events. that's the reason that i needed a port expander, to facilitate the alarm indicator of 100 independent alarm notifications.

product ba yan ng company nyo? you will be able to reduce your BOM cost by just eliminating the MAX7318 and creating instead a 4X4 Hex Keypad Matrix using 8bits of port...

i don't work for anyone (YET), i am still in school, on my last year in college now.

my recent problem is on how to manually set the time from which the RTC will begin to work, and i want to do this by using the keypad. i have been trying to write in the registers but to no avail.

any advice or sample routines for this problem?
thank you....
bulletproof loneliness....

Offline Shey

  • Administrator
  • Gas Turbine
  • *****
  • Posts: 2004
  • Pogi/Ganda Points: 154
  • Gender: Female
  • "E tangi ana koe Hine e hine, E hine e Hoki maira"
    • Elab.PH
Re: need help with program to interface DS1307 with 16F877
« Reply #16 on: March 02, 2008, 09:41:17 PM »
post kayo ng schematics at yung source code if possible..
I wish for this night-time to last for a lifetime
The darkness around me
Shores of a solar sea
Oh how I wish to go down with the sun
Sleeping
Weeping
With you

I walk alone
Every step I take
I walk alone
My winter storm
Holding me awake
It’s never gone

I fear that soon you'll reveal
Your dangerous mind
As your true colours show
A dangerous sign

Offline elizabeth ann

  • CR2032 Battery
  • **
  • Posts: 28
  • Pogi/Ganda Points: 1
  • omni initium est deficille
Re: need help with program to interface DS1307 with 16F877
« Reply #17 on: March 08, 2008, 10:04:56 PM »
yes bosing, as soon as mafinalize lahat at madouble check namin for errors, ishishare po namin lahat yun.

meanwhile, i hope i get a chance to post some of the rtc/scheduling routines when i come back online sometime later.

magis!

elizabeth ann
bulletproof loneliness....

Offline toasted siopao

  • She loves me, she loves me not, she loves me...
  • Global Moderator
  • Gas Turbine
  • *****
  • Posts: 2574
  • Pogi/Ganda Points: 107
  • Gender: Female
    • TeknoBlogger
Re: need help with program to interface DS1307 with 16F877
« Reply #18 on: March 08, 2008, 10:06:50 PM »
Oi anntot, kamusta na yung project nyo? Ok na ba yung pcb?

Offline paranz

  • Technical People
  • Nuclear Reactor
  • *****
  • Posts: 4525
  • Pogi/Ganda Points: 177
  • Gender: Male
  • 1/4W resistor specialist
    • RapidSignal Electronics
Re: need help with program to interface DS1307 with 16F877
« Reply #19 on: March 09, 2008, 12:39:05 AM »
yes bosing, as soon as mafinalize lahat at madouble check namin for errors, ishishare po namin lahat yun.

meanwhile, i hope i get a chance to post some of the rtc/scheduling routines when i come back online sometime later.


are you using proteus VSM?
PIC16 Programming Tutorial using MPLAB and Hi-Tech C
www.rapidsignalph.com/tutorials/pic16-tutorials

Arduino & gizDuino Tutorials
www.rapidsignalph.com/tutorials/arduino-tutorials

Philippine Electronics Forum

Re: need help with program to interface DS1307 with 16F877
« Reply #19 on: March 09, 2008, 12:39:05 AM »

 

Privacy Policy

Contact Us: elabph@yahoo.com