Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

PIC16 ADC Question

  1. Jul 21, 2012 #1
    Got a couple pic16f819s and was pondering something relatively simple like a voltage meter or a frequency counter.

    My question is the MC I have comes with an ADC that seems to max out at 5 volts. This seems to mean that I couldn't test for more than 5 volts. For instance I could test a 9 volt battery even with this thing. That seems pretty weird but I leave that alone.

    I come from a computer background and have some year of experience pouring over poorly written documentation. Having said that the literature for electronics is pretty rough to understand.

    Take the ADC on my pic16. The way it would be intuitively used would be to take a certain voltage and then send an analog signal (voice or radio) on that voltage. The output would be some digital representation of the analog.

    This already is terribly confusing. There are an infinite number of possible analog values for any length of time. How then does the IC map this onto a digital value?

    Moving on. How does the ADC know whether it's measuring voltage, current or some signal? Many on the internet suggest you can use an ADC as a voltmeter or an ammeter. Great but how does the IC know which it's supposed to be using, the signal the current or the voltage?

    Heres the PIC page: http://www.dimensionengineering.com/appnotes/Gmeter/PIC16F818.pdf

    You can google ADC voltmeter, ammeter, signal converter etc and find tons old projects.
     
  2. jcsd
  3. Jul 21, 2012 #2

    vk6kro

    User Avatar
    Science Advisor

    A to D converters measure 0 to 5 volts in steps of 256 or 1024 steps so each step is 19.5 mV or 4.88 mV.

    The output will then be whichever step is closest to the input voltage.

    So, assuming a 1024 (10 bit) A to D, then a 3 volt input will give a digital output of 614. (3 / 5 * 1024 = 614.4).

    You can then do this a litlle later and you might get a different value which you then use and make use of somewhere. You might record it on a CD perhaps.

    Measuring 9 volts is not a problem. Suppose you put two 10 K resistors in series across the 9 volt supply with one side connected to ground.
    Put the A to D converter across the one connected to ground.
    The bottom one would have 4.5 volts across it which is in the range of the A to D converter. So you read the 4.5 volts and multiply it by 2 in software.
     
  4. Jul 21, 2012 #3
    Thanks for the reply VK.

    Your suggestion is a good one.

    Like I said though, very strange that an ADC would be limited to reading voltage. Why not have a separate IC for converting voltage to a binary or decimal number which then could be outputted without all the nonsense of adding a bunch of resistors in series to artificially multiply max voltage?

    And more to my point why doesn't ADC mean converting analog to digital in the sense of an analog signal (voice, radio) to its digital representation? Why bother calling it ADC? Call it a voltmeter port if that's all it does. ADC has a way different meaning in computing and signal processing - where it's not tied tightly in meaning to voltage.

    One last question - how would one convert from a microphone input (analog) to a digital representation? Can this be done using the ADC or not?

    Thanks.
     
  5. Jul 21, 2012 #4

    Bobbywhy

    User Avatar
    Gold Member

    mearvk, yes, your on-chip Analog-to-Digital Converter (ADC) will digitise audio (voice) frequencies. They convert the applied voltage to (in this case) 10 digital bits, as vk6kro has clearly described. It would digitise a fixed DC also. That's what they do. There are also separate ADCs available that do the same thing. You may use the specification sheet for your PIC, section 11, to read up on how your ADC works and how to use it. Pay particular attention to the "sample and hold" function.
     
  6. Jul 22, 2012 #5

    jim hardy

    User Avatar
    Science Advisor
    Gold Member
    2016 Award

    i came from an analog background and was terribly frustrated by computer literature where everything was defined in terms of something else undefined. As if relative addressing went to the heads of tech writers and destroyed their logic.

    After i learned the vocabulary i realized how precise their writing was after all.

    So dig in and dont think that being a computer whiz makes you an electronics whiz.

    A multiplexer cannot switch a voltage greater than its supply (unless it's a relay mux)
    so if your PIC is running on 5 volts dont hand it ten.
    see para 23.11 of PIC manual
    http://ww1.microchip.com/downloads/en/DeviceDoc/31023a.pdf
    and fig 23.3 diode clamps to VDD and VSS.

    old jim
     
    Last edited: Jul 22, 2012
  7. Jul 22, 2012 #6
    I guess my understanding was a meaningful signal could be transmitted with a constant voltage and thus why would an ADC read inputs using voltage variations. Presumably other physical qualities could be used perhaps current or resistance. That was a question mark in my head. It kind of makes sense, although it was not clear at the time.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: PIC16 ADC Question
  1. ADC and DAC (Replies: 4)

  2. Current ADC (Replies: 5)

Loading...