caramoan tour package

caramoan tour package

Author Topic: patulong naman po... PIC Alarm Clock  (Read 1545 times)

Offline fushinji1128

  • LR44 Battery
  • *
  • Posts: 6
  • Pogi/Ganda Points: 0
patulong naman po... PIC Alarm Clock
« on: September 12, 2009, 11:06:20 PM »


nakita po namin yang schematic na yan sa net at me kasama xang source code ng MIKROBASIC.. na ayun dun pang beginners daw.. wahaha.. natuwa naman kame kasi makakatulong na sya para maitawid namin project namin sa micro.. pero bigla.. nung itry na naming ibuild yang source code na yan...

hai

ayun error daw
sabi
not enough RAM'blah blah blah'

ano po kaya ang sanhi ng error?
help po.. its a matter of life and death... :'(


eto po yung site na pinakunan namin[/url]http://www.micro-examples.com/public/microex-navig/doc/084-alarm-clock[/url]

eto yung code nya

'******************************************************************************
' PIC16F84A ALARM CLOCK
'******************************************************************************
'
' feel free to use this code at your own risks
'
' target : PIC16F84A, 16 Mhz crystal
' HS clock, no watchdog.
'
' Author : Bruno Gavand, September 2007
' see more details on http://www.micro-examples.com/
'
'******************************************************************************

program alarmClock

'
' if you are using COMMON CATHODE LED display, uncomment this definition.
' if you are using COMMON ANODE LED display, comment this definition.
'
'#define CATHODE_COMMUNE

symbol  LUNDI           = 0     ' monday
symbol  MARDI           = 1     ' thuesday
symbol  MERCREDI        = 2     ' wednesday
symbol  JEUDI           = 3     ' thursday
symbol  VENDREDI        = 4     ' friday
symbol  SAMEDI          = 5     ' saturday
symbol  DIMANCHE        = 6     ' sunday
symbol  LMMJV           = 7     ' from monday to friday included

'
' alarm definitions, to be changed on your needs
'
symbol  NBALARM         = 16    ' number of programmed alarms

const   alarmTable   as byte[NBALARM * 4] = (
'       JOUR            HEURE   MINUTE  DUREE (secondes, 59 maxi)
'       DAY             HOUR    MINUTE  DURATION (in seconds, max is 59)
        LUNDI,          8,      30,     10,
        LUNDI,          12,     30,     10,
        LUNDI,          14,     00,     10,
        LUNDI,          16,     30,     10,
        MARDI,          8,      30,     10,
        MARDI,          12,     30,     10,
        MARDI,          14,     00,     10,
        MARDI,          16,     30,     10,
        JEUDI,          8,      30,     10,
        JEUDI,          12,     30,     10,
        JEUDI,          14,     00,     10,
        JEUDI,          16,     30,     10,
        VENDREDI,       8,      30,     10,
        VENDREDI,       12,     30,     10,
        VENDREDI,       14,     00,     10,
        VENDREDI,       16,     30,     10
        )

dim maxcount    as word         ' number of TMR0 overflow per second
dim scaler      as word         ' RTC scaler
dim jj          as byte         ' day of week, 0 is monday
dim hh          as byte         ' hour
dim mn          as byte         ' min
dim ss          as byte         ' sec
dim digiled     as byte[4]      ' 4 x 7 segment table
dim digit       as byte         ' number of current digit to be displayed
dim dp          as byte         ' decimal point
dim key         as byte         ' key code
dim alarm       as byte         ' alarm flag

'
' the ISR works as real time clock
'
sub procedure interrupt
        dim i as byte

'
' count time
'
        scaler = scaler + 1
        if scaler > maxcount
        then
                scaler = 0

                inc(ss)
                if ss = 60
                then
                        ss = 0
                        inc(mn)
                        if mn = 60
                        then
                                mn = 0
                                inc(hh)
                                if hh = 24
                                then
                                        hh = 0
                                        inc(jj)
                                        if jj = 8
                                        then
                                                jj = 1
                                        end if
                                end if
                        end if
                end if
        end if

'
' LED display
'
#ifdef CATHODE_COMMUNE
        PORTA = PORTA and $f0
        TRISA = $0f
        key = PORTA
        TRISA = 0
        PORTB = 0
#else
        PORTA = PORTA or $0f
        TRISA = $0f
        key = PORTA
        key = not(key)
        TRISA = 0
        PORTB = $ff
#endif
        key = key and $07

        digit = digit + 1

        if digit > 3
        then
                digit = 0
                i = $01
        else
                i = $01 << digit
        end if

#ifdef CATHODE_COMMUNE
        PORTB = digiled[digit]
        PORTA = PORTA or i
#else
        PORTB = digiled[digit]
        PORTB = not(PORTB)
        PORTA = PORTA and not(i)
#endif

        INTCON.T0IF = 0
end sub

'
' converts digit to 7 segment
'
sub function intTo7seg(dim n as byte) as byte
        select case n
                case 0  result = $3F
                case 1  result = $06
                case 2  result = $5B
                case 3  result = $4F
                case 4  result = $66
                case 5  result = $6D
                case 6  result = $7D
                case 7  result = $07
                case 8  result = $7F
                case 9  result = $6F
        end select
end sub

'
' select a value with keys
' value is pointed to by v, display char s as header, maximum value is max
'
sub procedure setValue(dim v as ^byte, dim s as byte, dim max as byte)
        digiled[0] = s
        digiled[1] = 0

        while 1
                if key.0
                then
                        inc(v^)
                        if(v^ > max)
                        then
                                v^ = 0
                        end if
                end if

                if key.1
                then
                        if(v^ = 0)
                        then
                                v^ = max
                        else
                                dec(v^)
                        end if
                end if

                if key.2
                then
                        Delay_ms(50)
                        while key.2
                        wend
                        Delay_ms(50)
                        scaler = 0
                        ss = 0
                        return
                end if

                digiled[2] = intTo7seg(v^ / 10)
                digiled[3] = intTo7seg(v^ mod 10)

                delay_ms(300)
        wend
end sub

'
' program entry
'
main:
        dim i as byte

'
' init variables
'
        dp = 0

        hh = 0
        mn = 0
        ss = 0
        jj = 0

        maxcount = 15625

'
' init I/O
'
        PORTA = %00010000
        TRISA = %00000000

        PORTB = 0
        TRISB = $00

'
' init interrupts
'
        INTCON = %10100000
        OPTION_REG = %11011000

        Delay_ms(50)

'
' clock adjustment
'
        setValue(@hh, 116, 23)
        setValue(@mn, 55, 59)
        setValue(@jj, 14, 6)

'
' forever loop
'
        while true
                if key
                then
'
' display day and seconds (what for ? don't remember !)
'
                        digiled[0] = intTo7seg(jj)
                        digiled[1] = 0
                        digiled[2] = intTo7seg(ss / 10)
                        digiled[3] = intTo7seg(ss mod 10)
                else
'
' display hours and minutes
'
                        if hh < 10
                        then
                                digiled[0] = 0
                                digiled[1] = intTo7seg(hh)
                        else
                                digiled[0] = intTo7seg(hh / 10)
                                digiled[1] = intTo7seg(hh mod 10)
                        end if
                        digiled[2] = intTo7seg(mn / 10)
                        digiled[3] = intTo7seg(mn mod 10)
                end if

'
' blinks semicolon (or decimal point)
'
                if scaler > maxcount / 2
                then
                        dp.1 = 1
                else
                        dp.1 = 0
                end if

'
' set decimal points
'
                digiled[0].7 = dp.0
                digiled[1].7 = dp.1
                digiled[2].7 = dp.2
                digiled[3].7 = dp.3

'
' check for alarm condition
'
                alarm = 0
                for i = 0 to (NBALARM - 1) * 4
                        if ((alarmTable = jj) or ((alarmTable = LMMJV) and (jj < SAMEDI)))
                                        and (alarmTable[i + 1] = hh)
                                        and (alarmTable[i + 2] = mn)
                                        and (alarmTable[i + 3] > ss)
                        then
                                inc(alarm)
                        end if
                next i

                if alarm
                then
'
' set alarm
'
                        dp.3 = 1
                        PORTA.4 = 0
                else
'
' clear alarm
'
                        dp.3 = 0
                        PORTA.4 = 1
                end if
        wend
end.

Philippine Electronics Forum

patulong naman po... PIC Alarm Clock
« on: September 12, 2009, 11:06:20 PM »

insomartin

  • Guest
Re: mga boss at ma'am.. patulong naman po...
« Reply #1 on: September 13, 2009, 01:52:27 AM »
i PM mo ako.

Philippine Electronics Forum

Re: mga boss at ma'am.. patulong naman po...
« Reply #1 on: September 13, 2009, 01:52:27 AM »

Offline marky2007

  • CR2032 Battery
  • **
  • Posts: 9
  • Pogi/Ganda Points: 0
Re: mga boss at ma'am.. patulong naman po...
« Reply #2 on: September 14, 2009, 04:28:20 PM »
Hello there,

meaning puno n ung RAM ng MCU because of ur routines..revision will solve your problem, or upgrade your MC.

Philippine Electronics Forum

Re: mga boss at ma'am.. patulong naman po...
« Reply #2 on: September 14, 2009, 04:28:20 PM »

insomartin

  • Guest
Re: mga boss at ma'am.. patulong naman po...
« Reply #3 on: September 14, 2009, 04:35:04 PM »
^ no. i already compiled code with room to spare. ok naman na and working. tested and simulated on proteus already.  ;D

Philippine Electronics Forum

Re: mga boss at ma'am.. patulong naman po...
« Reply #3 on: September 14, 2009, 04:35:04 PM »

Offline fushinji1128

  • LR44 Battery
  • *
  • Posts: 6
  • Pogi/Ganda Points: 0
Re: mga boss at ma'am.. patulong naman po...
« Reply #4 on: September 14, 2009, 09:53:29 PM »
ok na nga po.. wahaha medyo natanga lang po ako.. salamat po...
ai di pa pala ok.. me problema pa pala ako dun sa output.... try ko po muna sa proteus.. ^^,

Philippine Electronics Forum

Re: mga boss at ma'am.. patulong naman po...
« Reply #4 on: September 14, 2009, 09:53:29 PM »

Offline fushinji1128

  • LR44 Battery
  • *
  • Posts: 6
  • Pogi/Ganda Points: 0
Re: patulong naman po... PIC Alarm Clock
« Reply #5 on: September 14, 2009, 11:01:50 PM »
bat ganun? dapat po ba common anode? o common cathode?
@ boss martin...

ano po ginawa nyo sa proteus? common cathode po ba?

Offline kraze

  • Size AA Battery
  • ****
  • Posts: 138
  • Pogi/Ganda Points: 1
  • Gender: Male
  • The electrons is not there till we put it there
Re: patulong naman po... PIC Alarm Clock
« Reply #6 on: September 16, 2009, 02:44:02 AM »
Quote
bat ganun? dapat po ba common anode? o common cathode?
@ boss martin...

ano po ginawa nyo sa proteus? common cathode po ba?

@fushinji1128 just use the two common mode and if this not still work, maybe there something wrong with your circuit

Offline marcelino

  • Moderator
  • Solar Power Satellite
  • *****
  • Posts: 6016
  • Pogi/Ganda Points: 258
  • ...keep moving forward! - Robinson's
Re: patulong naman po... PIC Alarm Clock
« Reply #7 on: September 16, 2009, 09:21:27 AM »
as per schematic, dapat common cathode.
"Don't take life seriously. After all, no one has ever come out of it alive. -Bugs Bunny"

Offline SpongeBob

  • Lead Acid Battery
  • *******
  • Posts: 660
  • Pogi/Ganda Points: 33
Re: patulong naman po... PIC Alarm Clock
« Reply #8 on: September 16, 2009, 05:57:41 PM »
ang schematic common cathode pero ang source code pang-common anode kasi may comment ang definition

Offline merxyboy

  • LR44 Battery
  • *
  • Posts: 1
  • Pogi/Ganda Points: 0
Re: patulong naman po... PIC Alarm Clock
« Reply #9 on: February 15, 2010, 10:19:40 AM »
hello po.. panu nio naresolusyonan ung 'not enough ram' prob
medyo newbie pa po kc ako sa proteus eh...
pls, ska po sa 7seg-mpx1-cc sa proteus, ung h po b ung dp?
salamat po sa reps...

Philippine Electronics Forum

Re: patulong naman po... PIC Alarm Clock
« Reply #9 on: February 15, 2010, 10:19:40 AM »

 

Privacy Policy

Contact Us: elabph@yahoo.com