Wierd result when inverting an input


Closed Thread
Results 1 to 20 of 20

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: Wierd result when inverting an input

    Thank you Dave for the suggestion, but no luck it doesn't work either. With "~" I get ascii 46 when portB.0 is false and the same ascii 47 when the portB.0 is True.

    Looking into the manual the character for the NOT is "!", I could not find any reference to "~" as a NOT notation.

    Cheers

    Al.
    All progress began with an idea

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: Wierd result when inverting an input

    Quote Originally Posted by aratti View Post
    Thank you Dave for the suggestion, but no luck it doesn't work either. With "~" I get ascii 46 when portB.0 is false and the same ascii 47 when the portB.0 is True.

    Looking into the manual the character for the NOT is "!", I could not find any reference to "~" as a NOT notation.

    Cheers

    Al.
    The "tilde" character ~ is a BITWISE NOT. pp35 in the old green book, have misplaced my PBP3 book.

    This works:
    Code:
    
    Bell var portB.6
    Report var byte
    main:
    Report = ~~(Bell + 48) 
    debug report
    pause 500
    
    goto main
    Last edited by Archangel; - 19th June 2015 at 18:02.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

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


    Did you find this post helpful? Yes | No

    Default Re: Wierd result when inverting an input

    Code:
    Bell var portB.6
    Report var byte
    main:
    Report = ~~(Bell + 48) 
    debug report
    pause 500
    
    goto main
    Thank you Archangel for your snippet.
    I tried with one tilde character ~(Bell + 48) and it does't work. (Just strange characters)
    I tried with two tildes, as per your example, and what I get is the original Logic state of the pin. It seems that two tildes are simply ignored.

    So, at the moment I have used the IF/THEN/ELSE/ENDIF workaround. Conclusion we cannot invert a pin alias and convert it to ascii using the "!" or the bitwise "~"

    Cheers
    Al.
    Last edited by aratti; - 19th June 2015 at 18:57.
    All progress began with an idea

Similar Threads

  1. 16F628 PortA pin connections - wierd
    By john meiers in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 10th December 2011, 17:28
  2. Wierd sleep issue
    By orca in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 14th March 2006, 22:06
  3. Inverting Input Values
    By Peter1960 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 21st August 2005, 08:09
  4. wierd problem with 12f629 Need Help Despretly
    By Nadeem in forum Off Topic
    Replies: 1
    Last Post: - 15th June 2005, 20:59
  5. Very wierd problem
    By jswayze in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 15th November 2004, 04: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