How do I use 10 bit A/D on 8 bit Pic? 12F675


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Nov 2009
    Location
    Wagoner, USA
    Posts
    52

    Default How do I use 10 bit A/D on 8 bit Pic? 12F675

    How do I input the 10 bit A/D value, do math on it and use the value in the program or output it to debug?
    All the examples I've seen only use 8 bits.
    Does it have to be split into 2- 8 bit bytes then ...?

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


    Did you find this post helpful? Yes | No

    Default

    Yup, needs split.
    A couple of the hard to find examples.... can be found here

    http://www.melabs.com/resources/samples.htm

    and here is one on the forum
    http://www.picbasic.co.uk/forum/showthread.php?t=11947
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    You don't need to split it. Just save it in a WORD variable. Yes, the PIC is an 8-bit device, but can easily work on number 16 bits long.
    Charles Linquist

  4. #4
    Join Date
    Nov 2009
    Location
    Wagoner, USA
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Ok so if I read that right I can store the highbyte & lowbyte A/D value in a word variable (adval) then I can do math on the entire 10 bits of the word?
    For example:
    Code:
     
    ADCIN 0, adval	      ' Read channel 0 to adval
    
    adval=adval *2/10      'do math on 10 bit adval
    
    Debug "A/D Value: ",dec adval,10,13 'Send decimal value out

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


    Did you find this post helpful? Yes | No

    Default

    Yes, that should work. Just watch that the math does not over flow the word size var.
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Nov 2009
    Location
    Wagoner, USA
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Yes, that should work. Just watch that the math does not over flow the word size var.
    So I can actually do 16 bit math?
    Cool!
    Thanks

Similar Threads

  1. Serout problem
    By lerameur in forum mel PIC BASIC Pro
    Replies: 94
    Last Post: - 25th February 2007, 14:33
  2. Need help with 16f819 10 bit ADC
    By bannrikae in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 26th September 2005, 16:20
  3. Need clever way to convert 10 bits to 8 bits
    By MikeTamu in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 2nd September 2005, 16:13
  4. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th March 2005, 00:14
  5. 8 Bit output
    By barkerben in forum General
    Replies: 3
    Last Post: - 17th November 2004, 15:39

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