Efficient comparison on data (iButton)


+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Jul 2003
    Location
    Lancashire
    Posts
    50

    Default Efficient comparison on data (iButton)

    Hi All

    Having completed the code for DS1990A reading (thanks Darrel) I have a working code section but I`m looking for a much more efficient way to compare the results. Code section included below for reference. The individual iButtons are used to identify room access by person.

    The iButton id number is contained in these variables, 6 hex bytes:
    id[0],id[1],id[2],id[3],id[4],id[5]

    Assuming there is a button in the socket, whats the best way to do a compare to see if its the same button or a different one, without strings of comparsons against the last valid number?


    Cheers Pete




    Fam var byte
    id var byte[6]
    crc var byte

    OWOUT portb.0,1,[$33], NotThere ' Issue Read ROM, jump to NotThere if no button

    OWIN PORTA.1,0,[Fam,id[0],id[1],id[2],id[3],id[4],id[5],crc] 'Read the button

    (code required)

    goto main



    NotThere:

    id[0]=0:id[1]=0:id[2]=0:id[3]=0.id[4]=0:id[5]=0 'set all to zero if no iButton inserted

    goto main

  2. #2
    skimask's Avatar
    skimask Guest

    Default

    Quick and dirty, add all 6 bytes together into a word and compare that number to the 'new' number. If they're not equal, you know you've got a different button. If they're the same, you MIGHT NOT have the same button and have to do further comparisons.
    Any way you go, you're going to have to do some comparisons somewhere...

    A bit less quick and not so dirty, put those 6 bytes into 3 words and compare those 3 words the same way as above.

    I don't know why you're against comparisons. PBP supports them just fine.

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405

    Default

    I would for sure compare the whole number. Leave just a fraction of room for
    Murphys' Law to creep in, and it does...;o}
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4
    Join Date
    Jul 2003
    Location
    Lancashire
    Posts
    50

    Default Thanks

    Hi All

    I`m not so much against comparisons just looking for the smallest way to implement this. I shall give this more thought and see what I can manage. Certainly adding the total is a good quick and dirty method, I`ll look at this first.

    Cheers Pete



    Quote Originally Posted by Bruce View Post
    I would for sure compare the whole number. Leave just a fraction of room for
    Murphys' Law to creep in, and it does...;o}

  5. #5
    Join Date
    Aug 2010
    Posts
    4

    Default i have a question

    can you please tell me how to compare 2 word in picbasic ??

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

    Default

    Look in the manual under sections
    4.18 Comparison Operators
    and
    4.19 Logical Operators.
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Aug 2010
    Posts
    4

    Default help please

    i have finish a temperature regulator system with rs232 serial port
    to finish the project i have to create a interface for real time mesurement of the temperature
    ,,,,,
    Can somebody give a interface (GUI )maltab or other php with a code for reading from the port rs232 reading
    the temperature >>>>>thank you

  8. #8
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,154

    Default

    barcosta , Why don't we just do the project for you? It's one thing to ask for help, and another to ask for the code....
    What are YOU learning?
    Dave Purola,
    N8NTA

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 04:47
  2. Read/Write Problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th February 2010, 01:51
  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

Posting Permissions

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