RFID medicine teller!! problem with programming


Closed Thread
Results 1 to 23 of 23

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Check out FREQOUT in the manual. It does not look correct the way you have it.
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Nov 2008
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    except FREQOUT and SOUND. have any different command is also for speaker?? While, after display out the result then pause 2000. it will delay the time to go for next stage. for example,

    Code:
    nice:
    lcdout $FE,1,"Sorry,Wrong"
    lcdout $FE,$c0,"Medicine!!"
    freqout porta.5,1000*/$100,115*/$100
    high porta.3
    pause 3000
    
    serin2 portc.7,84,[str buf\10]
    'nextline:
    for tagnum = 1 to 2
    for idx = 0 to 9
    read(((tagnum-1)*10)+idx),char
    if(char<>buf(idx)) then goto bad_char

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Code:
    freqout porta.5,1000*/$100,115*/$100
    If I am doing my math correctly the above code is trying to produce a -256Hz tone for 1 second. I do not think this is possible

    Try:
    Code:
     FREQOUT PORTA.5,1000,440,350
    and see what happens.
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Nov 2008
    Posts
    11


    Did you find this post helpful? Yes | No

    Post

    Code:
    define LOADER_USED 1
    define OSC 4
    define LCD_DREG PORTB
    DEFINE LCD_DBIT 0
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 5
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 4
    DEFINE LCD_BITS 4
    
    adcon1 = 7
    trisa = %11111111
    
    
    hour    var     byte    ' Define hour variable
    dhour   var     byte    ' Define display hour variable
    minute  var     byte    ' Define minute variable
    second  var     byte    ' Define second variable
    ticks   var     byte    ' Define pieces of seconds variable
    update  var     byte    ' Define variable to indicate update of LCD
    
    i       var     byte    ' Debounce loop variable
    
    cl var byte
    buf var byte(10)
    tagNum var byte
    idx var byte
    char var byte
    
    tag1 data "0010828978"
    
    @       device WDT_OFF
    
            CMCON = 7       ' PORTA digital
    
            Pause 100       ' Wait for LCD to startup
    
            hour = 00        ' Set initial time to 00:00:00
            minute = 00
            second = 00
            ticks = 00
            update = 1      ' Force first display
    
    ' Set TMR0 to interrupt every 16.384 milliseconds
    
            OPTION_REG = $55        ' Set TMR0 configuration and enable PORTB pullups
            INTCON = $a0            ' Enable TMR0 interrupts
            On Interrupt Goto tickint
            
            PORTB = 0       ' PORTB lines low to read buttons
            TRISB = %11001111       ' Enable buttons
    
    ' Main program loop - in this case, it only updates the LCD with the time
    mainloop:
            ' Check any button pressed to set time
            If PORTa.0 = 1 Then decmin
            If PORTA.1 = 1 Then incmin
            
            bbb:
            if porta.2 = 1 then nice
            
            ' Check for time to update screen
    chkup:  If update = 1 Then
                    Lcdout $fe,1   ' Clear screen
                    'lcdout $FE,$c0,"Next 12:10:00"
    
                    ' Display time as hh:mm:ss
                    dhour = hour    ' Change hour 0 to 12
                    If (hour // 12) = 0 Then
                            dhour = dhour + 12
                    Endif
    
                    ' Check for AM or PM
                    If hour < 12 Then
                            Lcdout dec2 dhour, ":", dec2 minute, ":", dec2 second, " AM"
                    Else
                            Lcdout dec2 (dhour - 12), ":", dec2 minute, ":", dec2 second, " PM"
                    Endif
                    update = 0      ' Screen updated
            Endif
            
            lcdout $FE,$c0,"Next 12:10:10 AM"
            
            if (dhour = 12) and (minute = 10) and (second = 10) then  aaa
            
            goto mainloop
    
            
     aaa:
     'freqout porta.5,1000*/$100,115*/$100
     sound porta.5, [200,100]
     lcdout $FE,1,"please"
     lcdout $FE,$c0,"Medicine!!"
     high portc.0
     update = 1
     'pause 2000
         
    goto mainloop
      
    
    
    
    
    nice:
    high porta.3
    low portc.0
    'freqout porta.5,1000*/$100,115*/$100
    high porta.3
    'pause 3000
    
    serin2 portc.7,84,[str buf\10]
    'nextline:
    for tagnum = 1 to 2
    for idx = 0 to 9
    read(((tagnum-1)*10)+idx),char
    if(char<>buf(idx)) then goto bad_char
    
    next 
    goto tag_correct
    bad_char:
    next
    bad_tag:
    low porta.3
    'pause 500
    high portc.0
    tagnum = 0
    lcdout $FE,1,"Sorry,Wrong"
    lcdout $FE,$c0,"Medicine!!"
     sound porta.5, [200,100]
    'freqout porta.5,1000*/$100,115*/$100
    'pause 3000
    
    lcdout $FE,1,"Please Take"
    lcdout $FE,$c0,"Medicine A"
    
    goto nice
    
    tag_correct
    low porta.4
    high porta.5
    
    freqout porta.5,2000*/$100,880*/$100
    lcdout $FE,1,"Correct take"
    lcdout $FE,$c0,"Medicine!!"
    high portc.3
    second = second + 1
    pause 3000
    
    
    
    goto mainloop
    
    
            'Goto mainloop   ' Do it all foreve
    ' Increment minutes
    incmin: minute = minute + 1
            If minute >= 60 Then
                   minute = 0
                    hour = hour + 1
                    If hour >= 24 Then
                            hour = 0
                    Endif
            Endif
            Goto debounce
    
    ' Decrement minutes
    decmin: minute = minute - 1
            If minute >= 60 Then
                    minute = 59
                    hour = hour - 1
                    If hour >= 24 Then
                            hour = 23
                    Endif
            Endif
    
    ' Debounce and delay for 250ms
    debounce: For i = 1 to 25
            Pause 10        ' 10ms at a time so no interrupts are lost
            Next i
            update = 1      ' Set to update screen
            Goto chkup
    
    ' Interrupt routine to handle each timer tick
            disable         ' Disable interrupts during interrupt handler
    tickint: ticks = ticks + 1      ' Count pieces of seconds
            If ticks < 61 Then tiexit       ' 61 ticks per second (16.384ms per tick)
    
    ' One second elasped - update time
            ticks = 0
            second = second + 1
            If second >= 60 Then
                   second = 0
                    minute = minute + 1
                    If minute >= 60 Then
                            minute = 0
                            hour = hour + 1
                            If hour >= 24 Then
                                    hour = 0
                            Endif
                    Endif
            Endif
            update = 1      ' Set to update LCD
    tiexit: INTCON.2 = 0    ' Reset timer interrupt flag
            Resume
    
            End
    code shown on top is my program code. i want to know how to let real time work continuing when the time is match which what the time i was setted. because i has foind out the problem when time is matched. the real time will stopped it there.

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Not sure...but I think the code might be hanging here
    I do not see anything else at the moment.
    Code:
    goto nice
    
    tag_correct
    low porta.4
    high porta.5
    
    freqout porta.5,2000*/$100,880*/$100
    lcdout $FE,1,"Correct take"
    lcdout $FE,$c0,"Medicine!!"
    high portc.3
    second = second + 1
    pause 3000
    
    goto mainloop
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Nov 2008
    Posts
    11


    Did you find this post helpful? Yes | No

    Post

    erm.. i has following your instruction, but still remain same thing happening. athrough i ignore the frequency the time still might stopped when the time is matched with the time i setted.

Similar Threads

  1. 16F676 programming problem
    By Christopher4187 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 18th May 2009, 17:39
  2. PIC18F4620 Programming problem
    By JavPar in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 6th December 2008, 04:21
  3. bh 1415f and picbasic problem
    By patricx in forum Off Topic
    Replies: 3
    Last Post: - 18th September 2007, 22:19
  4. Programming Problem with PIC16F819
    By Dick Ivers in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 24th July 2007, 18:42
  5. Problem programming the PIC16F648A
    By Edgardo_2 in forum General
    Replies: 2
    Last Post: - 29th December 2006, 00:02

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts