Help with Maxim Ibutton "IF THEN ELSE" statements please


Closed Thread
Results 1 to 39 of 39

Hybrid View

  1. #1
    Join Date
    Apr 2011
    Location
    Welches, Oregon
    Posts
    198


    Did you find this post helpful? Yes | No

    Default Re: Help with Maxim Ibutton "IF THEN ELSE" statements please

    It is typically necessary to use parenthesis between logical comparisons as:

    If (Serial[1]=$15) and (Serial[2]=$D3) and (Serial[3]=$7D) AND (Serial[4]=$16) AND (Serial[5]=$00) AND (Serial[6]=$00) then correct1

    I believe that it forces a Boolean comparison rather than a mathematical evaluation.

    One last - is it necessary to compare ALL bytes, or might you only compare say... the first one. This would seem to yield a unique condition and save the effort and complexity of so long a line:

    If (Serial[1]=$15) then Correct1

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,159


    Did you find this post helpful? Yes | No

    Default Re: Help with Maxim Ibutton "IF THEN ELSE" statements please

    Quote Originally Posted by Amoque View Post
    ...

    One last - is it necessary to compare ALL bytes, or might you only compare say... the first one. This would seem to yield a unique condition and save the effort and complexity of so long a line:

    If (Serial[1]=$15) then Correct1

    Speaking out my bellybutton, I'd say yes. The other serial numbers still have to be validated (knowing absolutely nothing about his application).

    Robert

  3. #3
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: Help with Maxim Ibutton "IF THEN ELSE" statements please

    There is some good code here

    http://www.picbasic.co.uk/forum/cont...r-nine-of-them

    I particularly noted there is no pause between the owout and owin.

  4. #4
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237


    Did you find this post helpful? Yes | No

    Default Re: Help with Maxim Ibutton "IF THEN ELSE" statements please

    Thank you Steve

    Will read though later .... See it reveals any clues !!

    BR
    Andy

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Help with Maxim Ibutton "IF THEN ELSE" statements please

    Hi,
    Tried the above and variants of it....It is now just going staight to the gosub routine (wrong) I suspect because with no Ibutton in place the "Serial Number" is after all wrong!!
    Well, if what you're saying is that you don't actually have an IButton connected then I think you've found the problem. Of course the numbers will be wrong, none of the IF statements will evaluate TRUE so the exection will fall thru to the GOSUB wrong statement.
    Help........!!!!
    This may sound like a totally crazy idea but you might try connecting an IButton and see if that possibly helps.

    :-)

    /Henrik.

  6. #6
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237


    Did you find this post helpful? Yes | No

    Default Re: Help with Maxim Ibutton "IF THEN ELSE" statements please

    Hi Henrick

    Yes works fine with button....But!

    A lot of the time it needs to sit waiting for a button (looping till it sees one... then it jumps to sub routine if right button) "If" wrong button applied I need to jump out and go elsewhere !

    So yes a lot of waiting with no button.

  7. #7
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: Help with Maxim Ibutton "IF THEN ELSE" statements please

    Andy,

    I get it now!

    You are validating ibuttons that are not always present. In fact most of the time there will not be an ibutton to read.

    You are saying you need to detect the presence of an ibutton and when detected check it's serial number and if correct take some action (open a lock for example) if incorrect take some other action (sound an alarm for example)

    Is this true?

  8. #8
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237


    Did you find this post helpful? Yes | No

    Default Re: Help with Maxim Ibutton "IF THEN ELSE" statements please

    That is the Badger!

    Yes.

  9. #9
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: Help with Maxim Ibutton "IF THEN ELSE" statements please

    Your program needs a loop that checks for the presence of an ibutton and if not present continue looping other wise jump out the loop into a serial number read/verify routine eventualy going back to the loop.

    Any ideas of how to test for an ibutton present?

  10. #10
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237


    Did you find this post helpful? Yes | No

    Default Re: Help with Maxim Ibutton "IF THEN ELSE" statements please

    Quote Originally Posted by Demon View Post
    Speaking out my bellybutton, I'd say yes. The other serial numbers still have to be validated (knowing absolutely nothing about his application).

    Robert
    Yes they do ALL need verifying...

    BR
    Andy

Similar Threads

  1. Replies: 0
    Last Post: - 14th November 2013, 03:32
  2. Replies: 3
    Last Post: - 15th October 2012, 08:06
  3. Replies: 8
    Last Post: - 3rd March 2011, 22:20
  4. Replies: 5
    Last Post: - 28th February 2011, 15:33
  5. Replies: 1
    Last Post: - 16th February 2005, 20:05

Members who have read this thread : 0

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

Tags for this Thread

Posting Permissions

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