Problems with ADC


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    Dec 2008
    Location
    Charlottesville, VA
    Posts
    31


    Did you find this post helpful? Yes | No

    Post

    Quote Originally Posted by mister_e View Post
    Code:
            PORTB = (LIGHT >>2)
            PORTD.6 = LIGHT.0
            PORTD.7 = LIGHT.1
    Doesn't this line just shift everything two bits to the right:
    Code:
    portb = (light >>2)
    By doing this I'm actually losing two bits right?

    Morris Beasley
    Manufacturing Test Technician
    B.S. Industrial Technology (2007)

    For more information on our robotics, please visit:
    http://www.ish-electronics.webs.com

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    LIGHT is a Word, PORT is a BYTE... this is always hard to fit 16bits in a 8 bit register huh?

    LIGHT>>2 - yes it shift two position to the right... yes you miss bit0 and bit1, but the next lines
    PORTD.6 = LIGHT.0
    PORTD.7 = LIGHT.1

    place them on PORTD.

    no lost at all.

    None of your bit are lost LIGHT>>2 as long as you dont use something like
    LIGHT=LIGHT>>2
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Dec 2008
    Location
    Charlottesville, VA
    Posts
    31


    Did you find this post helpful? Yes | No

    Default

    ok i was thinking that bit 0 and bit 1 would just be moved to where bits 2 and bits 3 are... thus showing bits 0 and 1 twice and losing bits 8 and 9 with the code you provided me with... i'll give it a shot and see what happens...
    Last edited by mcbeasleyjr; - 29th January 2009 at 17:38.

    Morris Beasley
    Manufacturing Test Technician
    B.S. Industrial Technology (2007)

    For more information on our robotics, please visit:
    http://www.ish-electronics.webs.com

Similar Threads

  1. 16F819 ADC problems
    By MUC in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 22nd March 2008, 18:36
  2. PIC18f2423 two 12bit adc input problems
    By Brandon in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 16th December 2007, 09:47
  3. I have problems with de ADC...
    By jomavilla24 in forum Off Topic
    Replies: 1
    Last Post: - 16th February 2007, 16:24
  4. adc problems
    By MARAD75 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 3rd December 2006, 05:47
  5. Newby with ADC problems.
    By Mark Scotford in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th March 2005, 20:09

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