how to compare data


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default

    Can you post all the code? I suppose you cut and paste a part of it, right?

    Ioannis

  2. #2
    Join Date
    May 2009
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    Code:
    PORTA = 1
    PORTB = 0
    KEY VAR BYTE
    KEY1 VAR BYTE
    ADR VAR BYTE
    SYMBOL SCLK = PORTB.0
    SYMBOL SDAT = PORTB.1
    SYMBOL RELY = PORTB.3
    SYMBOL STRT = PORTA.0
    
    START:
    
    IF STRT = 0 THEN GOSUB SCAN
    ENDIF
    GOTO START
    
    SCAN:
    FOR ADR = 0 TO 7
    I2CREAD SDAT,SCLK,$A0,ADR,[KEY]
    PAUSE 10
    READ ADR,KEY1
    PAUSE 10
     NEXT ADR
     IF UNLCK = 0 THEN 
    I2CWRITE SDAT,SCLK,$A0,ADR,[KEY1]
     PAUSE 1000
    IF (KEY = KEY1) THEN
     HIGH RELY 
    PAUSE 1000
    LOW RELY
    ENDIF
    RETURN
    END 
    DATA @0,14,21,47,56,02,11,22,33
    this is  wat i have in the external eeprom 24c02 "14,21,47,56,02,11,22,33 the same data i want my code to compare it.when it similare with the internal data it toggle relay or led  if not similare it dont please help this wat i want to do but im sure there another way bcz this isnt working it does compare sometimes even the data not similare it toggle the led IF (KEY = KEY1) THEN

  3. #3
    Join Date
    May 2009
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Mus.me View Post
    Code:
    PORTA = 1
    PORTB = 0
    KEY VAR BYTE
    KEY1 VAR BYTE
    ADR VAR BYTE
    SYMBOL SCLK = PORTB.0
    SYMBOL SDAT = PORTB.1
    SYMBOL RELY = PORTB.3
    SYMBOL STRT = PORTA.0
    
    START:
    
    IF STRT = 0 THEN GOSUB SCAN
    ENDIF
    GOTO START
    
    SCAN:
    FOR ADR = 0 TO 7
    I2CREAD SDAT,SCLK,$A0,ADR,[KEY]
    PAUSE 10
    READ ADR,KEY1
    PAUSE 10
     NEXT ADR
    IF (KEY = KEY1) THEN
     HIGH RELY 
    PAUSE 1000
    LOW RELY
    ENDIF
    RETURN
    END 
    DATA @0,14,21,47,56,02,11,22,33
    this is  wat i have in the external eeprom 24c02 "14,21,47,56,02,11,22,33 the same data i want my code to compare it.when it similare with the internal data it toggle relay or led  if not similare it dont please help this wat i want to do but im sure there another way bcz this isnt working it does compare sometimes even the data not similare it toggle the led IF (KEY = KEY1) THEN
    i hope someone will hel me

  4. #4
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    You simply put the IF/THEN in the wrong place. It must be within the FOR/NEXT loop.
    I don't see the setting for the TRIS registers.

    Al.

    Code:
    PORTA = 0
    PORTB = 0
    TrisA = %00000001  ' ????????????????
    TrisB = %00000000  ' ???????????????
    KEY VAR BYTE
    KEY1 VAR BYTE
    ADR VAR BYTE
    SYMBOL SCLK = PORTB.0
    SYMBOL SDAT = PORTB.1
    SYMBOL RELY = PORTB.3
    SYMBOL STRT = PORTA.0
    
    START:
    PAUSE 10
    IF STRT = 0 THEN GOSUB SCAN
    ENDIF
    GOTO START
    
    SCAN:
    FOR ADR = 0 TO 7
    I2CREAD SDAT,SCLK,$A0,ADR,[KEY]
    PAUSE 10
    READ ADR,KEY1
    PAUSE 10
    
    IF KEY = KEY1 THEN
    HIGH RELY 
    PAUSE 1000
    LOW RELY
    Pause 1000
    ENDIF
    
    NEXT ADR
    
    RETURN
    END 
    DATA @0,14,21,47,56,02,11,22,33
    Last edited by aratti; - 28th October 2009 at 23:04.
    All progress began with an idea

  5. #5
    Join Date
    May 2009
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    ty arrati for help
    Last edited by Mus.me; - 29th October 2009 at 01:50.

  6. #6
    Join Date
    May 2009
    Posts
    66


    Did you find this post helpful? Yes | No

    Angry

    ty for reply still the problem it toggle the rely even i change the data in ext epprom or in pic eeprom it still doing error im sure there other way to compare variables .plz need more help how to compare variables i want to do this project for doorlock so i will have 24c02 in my keys ty aratti

    Code:
    SCAN:
    FOR ADR = 0 TO 7
    NEXT ADR
    I2CREAD SDAT,SCLK,$A0,ADR,[KEY] 'same data  as data eeprom  
    PAUSE 10
    READ ADR,KEY1    ' same data as external eeprom 24c02
    PAUSE 100
    IF (KEY = KEY1) THEN , here is the problem it does hight rely even i put diffirent data in key and key1
     HIGH RELY 
    PAUSE 1000
    LOW RELY
    ENDIF
    Last edited by Mus.me; - 29th October 2009 at 01:54.

  7. #7
    Join Date
    May 2009
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    It works i cahnged somethings but the problem i have is it compare just the 7th byte when u change other bytes from 0 to 6 it doesnt detect them but when i change the 7th byte it say error that means it compares it with the 7th byte in the external eeprom NEDD help please .......
    Code:
    DATA @0,$14,$21,$47,$56,$02,$11,$22,$33          EXTERNAL EEPROM = $14,$21,$47,$56,$02,$11,$22,$33
    IT DOES COMPARE 33 AND 33 BUT NOT OTHER 7 BYTE WHY ?
    Last edited by Mus.me; - 29th October 2009 at 05:45.

  8. #8
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    IT DOES COMPARE 33 AND 33 BUT NOT OTHER 7 BYTE WHY ?
    Simply because you have still left out of the FOR/NEXT loop the compare instruction!

    Code:
    SCAN:
    FOR ADR = 0 TO 7
    
    I2CREAD SDAT,SCLK,$A0,ADR,[KEY] 'same data  as data eeprom  
    PAUSE 10
    READ ADR,KEY1    ' same data as external eeprom 24c02
    PAUSE 100
    IF (KEY = KEY1) THEN , here is the problem it does hight rely even i put diffirent data in key and key1
     HIGH RELY 
    PAUSE 1000
    LOW RELY
    ENDIF
    NEXT ADR
    See my correction to your last code posted or just copy and paste the code in post #5 (the one with my correction in read) and try it.

    Al.
    Last edited by aratti; - 29th October 2009 at 08:05.
    All progress began with an idea

  9. #9
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default

    Sorry for the late reply but we had our national holiday.

    Well, what type of EEPROM are you using?

    Ioannis

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 04:47
  2. Nokia 3310 display text
    By chai98a in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 26th August 2007, 03:39
  3. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 02:21
  4. LCD + bar graph
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 5th October 2005, 14:50
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 28th November 2004, 23:56

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