how to compare data


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    Join Date
    May 2009
    Posts
    66

    Default how to compare data

    hello everyones i need help plz . im readin i2c eeprom and i wrote the same data in my code so im trying to write a code to compare the data of the ext eeeprom and the code data ex:

    Code:
    Include "modedefs.bas"
    define osc 4
    
    
    PORTA = 1
    PORTB = 0
    KEY VAR BYTE
    KEY1 VAR BYTE
    ADR VAR BYTE
    
    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
    
     ENDIF
    RETURN
    
    END 
    DATA @0,14,21,47,56,02,11,22,33
    SO ID DID THIS CODE BUT IT WONT COMPARE ME THE SAME DATA FROM THE EXT EEPROM WITH THIS DATA IN THE CODE AND I WANT IT NOT TO TOGGLE LED1 WHEN ITS NOT THE SAME DATA FROM EXTERNAL EPPROM
    Last edited by Mus.me; - 27th October 2009 at 01:50.

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,847


    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

  3. #3
    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

  4. #4
    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

  5. #5
    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

  6. #6
    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.

  7. #7
    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.

  8. #8
    Join Date
    May 2009
    Posts
    66


    Did you find this post helpful? Yes | No

    Default came bk again looking for some help ...?

    im trying to read and write gold card,i know it has pic16f877 and 24c16, useing pic 16f628 ,anyone has any ideas or datasheet or how to adress it or it need to be slave or wat ?and which 1 i use shiftout & shiftin or i2c, plz help
    Last edited by Mus.me; - 1st November 2009 at 01:01.

  9. #9
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,847


    Did you find this post helpful? Yes | No

    Default

    Gold card? Does this have to do with Sat TV?

    Watch out. Jail is waiting for new roomers....

    Ioannis

  10. #10
    Join Date
    May 2009
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by ioannis View Post
    gold card? Does this have to do with sat tv?

    Watch out. Jail is waiting for new roomers....

    Ioannis
    i know THEY were using them to watch tps france and digital plus spainISH before 2005 .but now they use abracadabra moresate team DSR SAT COMPANY IN EUROPE selling them i havnt got 1 ITS CHEAPER HERE 18£ TO WATCH ALL SCREMBEL CHANNELS BUT WE DONT USE THEM BCZ U HAVE TO FLASH UR DSR EVERY 3 DAYS NOW NONE HACKIN CHANNELS HERE BCZ THEY CHANGED TO OTHER SYSTEMS AND THE OTHER PROBLEM IS NOT ALOWED . Well im programing gold card but i donno how to adress it from pic.i want to use IT for my own project instead 24c02 scroll up , so just want help how to transfer data between pic and goldcard or piccard they call it just adress how can i access its eeprom is 24c16 thank u anyway for ur ideas
    Last edited by Mus.me; - 1st November 2009 at 22:24.

  11. #11
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,847


    Did you find this post helpful? Yes | No

    Default

    I have not used this cards, but I recall reading somewhere that you have to write some piece of software to have access in the EEPROM.

    It is not directly accessible from the pins of the cards.

    Check here: http://ucables.com/ref/SILVERCARD

    If you know the internmal EEPROM connection you can do the rest...

    Ioannis
    Last edited by Ioannis; - 1st November 2009 at 22:34.

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