Inverting Input Values


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2005
    Posts
    67

    Red face Inverting Input Values

    Hi,
    Is there a simple way to invert the dta you want,ie

    I have an input going from 5 volt to 0 volts, but I would like
    the converted value to read 0 - 5 volts.

    I have a Sunday Brain Block!

    regards

    Peter
    Pete

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Depending on what you need...

    T VAR BIT
    B VAR BYTE

    T = ~PORTB.0 ; Single pin

    B = ~PORTB ; Invert Full Port

    B = PORTB ^ %00000001 ; Read full port and invert bit 0

    OR, if you meant Analog values, simply subtract the value from the highest possible A/D reading.

    ; --- For 8bit results ---
    ADCIN 0, B
    B = 255 - B

    ; --- For 10bit results ---
    ADCIN 0, W
    W = 1023 - W
    <br><br>
    Last edited by Darrel Taylor; - 21st August 2005 at 07:50.
    DT

  3. #3
    Join Date
    Feb 2005
    Posts
    67


    Did you find this post helpful? Yes | No

    Talking Of Course Of Course!!

    Darryl, your light helped!

    Of course all waht you do is subract it from the highest number. as analogue 1024-value.

    thks!

    Peter
    Pete

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Make sure you use 1023, not 1024.

    10bit values go from 0 to 1023<br><br>
    DT

  5. #5
    Join Date
    Feb 2005
    Posts
    67


    Did you find this post helpful? Yes | No

    Thumbs up

    Got that Darrel,

    now working like beauty!

    cheers

    Peter
    Pete

Similar Threads

  1. Sony LanC Program
    By l_gaminde in forum Code Examples
    Replies: 2
    Last Post: - 25th September 2009, 18:51
  2. LED "capacitance" won't get lower
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 3rd May 2007, 20:31
  3. Timing input pulses and re-outputting them
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 28th February 2007, 01:50
  4. Using LEDs as light sensors
    By skimask in forum Code Examples
    Replies: 3
    Last Post: - 30th December 2006, 22:19
  5. Can anyone help a beginner in a struggle?
    By douglasjam in forum mel PIC BASIC
    Replies: 1
    Last Post: - 5th May 2005, 23:29

Members who have read this thread : 1

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