The Godfather talking
This is god damn my place! Capisci?
Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 19, 2024, 07:35:14 19:35


Login with username, password and session length


Pages: [1]
Print
Author Topic: Clock, hours, minutes, seconds  (Read 8692 times)
0 Members and 1 Guest are viewing this topic.
Leonardo
Active Member
***
Offline Offline

Posts: 164

Thank You
-Given: 10
-Receive: 63


« on: November 11, 2008, 04:38:08 16:38 »

Hello friendly,

I want to do a clock with pic16f628 or some other pic that marks the hours, minutes and seconds. ¿Somebody of the forum has some example realized in picbasic pro?.

Thanks for its aid.
Logged
bbarney
Moderator
Hero Member
*****
Offline Offline

Posts: 2430

Thank You
-Given: 405
-Receive: 545


Uhm? where did pickit put my mute button


« Reply #1 on: November 11, 2008, 05:21:35 17:21 »

Do your own searching,there are ton's of examples here and all over the internet if you just tried searching!
but here's a good one to start your lazy ass Wink

Logged

Ever wonder why Kamikaze pilot's wore helmet's ?
fernandodiaz
Junior Member
**
Offline Offline

Posts: 73

Thank You
-Given: 1
-Receive: 18


« Reply #2 on: November 12, 2008, 03:53:01 03:53 »

'here some sample clock timer0  proton plus   xtal 4mhz  output LCD   remplace   all  dims   Dim ticks   as     byte   for  var 
' and some directives lcd remplace print  for lcdout $fe read manual pbp   
 
Code:
'DECLARE WATCHDOG = off ' xtal 4mhz

      DEVICE = 16F877

       'device = 16f874a

        XTAL = 4

LCD_DTPIN = PORTb.4       

LCD_RSPIN = PORTb.2

LCD_ENPIN = PORTb.3

LCD_INTERFACE = 4 ' 4-bit Interface

LCD_LINES = 2

LCD_TYPE = 0



SCL_PIN = PORTe.0

        SDA_PIN = PORTe.1

SERIAL_BAUD = 9600

RSOUT_PIN = PORTb.0

RSOUT_MODE = INVERT

RSOUT_PACE = 1

'   dim contador as dword           

Dim MINUTO  as     byte    ' Define MINUTO variable

Dim SEGUNDO as     byte    ' Define SEGUNDO variable

Dim ticks   as     byte    ' Define pieces of seconds variable

Dim update  as     byte    ' Define variable to indicate update of LCD

Dim i       as     byte    ' Debounce loop variable



        Delayms 100        ' Wait for LCD to startup

                          ' Set initial time to 00:00:00

        MINUTO = 0

        SEGUNDO = 0

        ticks = 0

        update = 1      ' Force first display



        OPTION_REG = %1010111        ' Set TMR0 configuration and enable PORTB pullu

        INTCON = $A0            ' Enable TMR0 interrupts

            Cls       

       

        On Interrupt Goto Tickint '_________________Interrupcion___________________________ 



 

'____________________________

mainloop:

 

    If update = 1 Then

           ' Clear screen

Print AT 1,1,    dec2 MINUTO, ":", dec2 SEGUNDO

     update = 0      ' Screen updated           

    Endif





Goto mainloop    ' Do it all forever

       

 '______________________________   

        Disable          ' Disable interrupts during interrupt handler



Tickint:

tmr0 = 12 ' .0625s * 16 = 1 seg   36 microseg de error por tick o 576 microseg x seg

   

  ticks = ticks + 1          ' Count pieces of seconds

        If ticks < 16 Then tiexit       ' 16 ticks per SEGUNDO (.0625 per tick)





        ticks = 0

        SEGUNDO = SEGUNDO + 1

        If SEGUNDO >= 60 Then

           SEGUNDO = 0

MINUTO = MINUTO + 1

If MINUTO >= 60 Then

   MINUTO = 0             

    Endif

        Endif



        update = 1      ' Poner en lcd  update LCD



Tiexit: INTCON.2 = 0    ' Borrar bandera timer interrupt flag

        Resume


best regards
« Last Edit: November 15, 2008, 11:16:05 23:16 by Wizpic » Logged
Shinta
Newbie
*
Offline Offline

Posts: 21

Thank You
-Given: 20
-Receive: 3


« Reply #3 on: November 15, 2008, 11:11:59 23:11 »

Why you don't try the ds1307 ic commanded via I2C bus with 16f628. is too much easy an exactly.
Logged
Biggles
Junior Member
**
Offline Offline

Posts: 47

Thank You
-Given: 15
-Receive: 23



« Reply #4 on: November 16, 2008, 08:57:37 20:57 »

Many clocks on Google search for PIC Basic Pro, but here is a nice one I have used myself:


3 Button adjustment of a DS1307 RTC

"The circuit uses a PIC16F84 and a standard 16*2 LCD.
.. tested the program on the following Pic chips, 16F84, 16F628(7), 18F1320(1220) and 18F452(252). "

http://anonym.to/?http://wiki.picbasic.org/index.php?n=ThreeButtonadjustmentofaDS1307RTC.RTC

Also easy to modify to SPI bus. I used it on a clock with good results using DS1305.

For clock only, a RTC is a little overkill. My application had a time display function when in standby, so I had to use a RTC. Very easy!

« Last Edit: November 16, 2008, 09:18:50 21:18 by Biggles » Logged

Man who act in haste, repent at leisure.
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC