Sorry, yet ANOTHER mod question


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Jan 2012
    Location
    Grid EN19MV
    Posts
    159


    Did you find this post helpful? Yes | No

    Default Re: Sorry, yet ANOTHER mod question

    Quote Originally Posted by Gusse View Post
    What kind of voltage divider you are using?
    If you try to get full 0-5V scale with 0-15V input, then you should use 1:3 ratio (e.g. 22kOhm and 11kOhm resistors) to get best measurement accuracy.

    With this divider 15V -> 5V (and 0V -> 0V) at ADC input pin, ADC should show 255 (8bit) or 4095 (12bit).
    I'm using a 10K and a 3.3K and my ADCbits is set to 10. Here's the ADC setup (maybe I'm doing something wrong there)

    Code:
    DEFINE ADC_BITS 10 ' Set number of bits in result
    DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS
    ADCON0 = %11000000 ' Set ADC_CLOCK to Frc, 
    ADCON1 = %10000000 ' Right-Justify result in ADRESH:ADRESL registers, use Vss and Vdd as voltage refernces
    "I have noticed that even those who assert that everything is predestined and that
    we can change nothing about it still look both ways before they cross the street"


    -Stephen Hawking

  2. #2
    Join Date
    Jan 2012
    Location
    Grid EN19MV
    Posts
    159


    Did you find this post helpful? Yes | No

    Default Re: Sorry, yet ANOTHER mod question

    BTW, I should mention that its a 16F886
    "I have noticed that even those who assert that everything is predestined and that
    we can change nothing about it still look both ways before they cross the street"


    -Stephen Hawking

  3. #3
    Join Date
    Dec 2007
    Location
    Finland
    Posts
    191


    Did you find this post helpful? Yes | No

    Default Re: Sorry, yet ANOTHER mod question

    Take a look to Voltage Divider Example.
    There is everything you need.

    10k and 3k3 doesn't give you 1:3 divider. Resistor ratio in your case should be 1:2 (e.g 11k and 22k).
    Link above explain also divider math to calculate right values.

    EDIT: Earlier post 12bit (4095) should have been 10bit (1023). My misstake!
    Last edited by Gusse; - 30th January 2014 at 18:36.

  4. #4
    Join Date
    Jan 2012
    Location
    Grid EN19MV
    Posts
    159


    Did you find this post helpful? Yes | No

    Default Re: Sorry, yet ANOTHER mod question

    Quote Originally Posted by Gusse View Post
    Take a look to Voltage Divider Example.
    There is everything you need.
    Problem solved! When I use the example code and plug in my actual resistor values, I get a reading that is within .1V of the actual. MORE than adequate for what I need. I only wanted it because the smoker controller could be running off battery - and I want to be able to shut it down and generate an alarm if the voltage reaches 10.5V. The user can also press a button while in auto mode to see the current voltage. A tenth of a volt out is NOTHING.

    Thanks!

    Andy
    "I have noticed that even those who assert that everything is predestined and that
    we can change nothing about it still look both ways before they cross the street"


    -Stephen Hawking

Similar Threads

  1. Help with Pic Delay code mod please
    By g7jiq in forum General
    Replies: 1
    Last Post: - 26th March 2009, 00:06
  2. ERROR: Macro MOD?TCB not found in macro file.
    By JohnP in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 17th February 2009, 19:10
  3. 18F4620 HPWM Half Bridge Mod problem
    By showtime in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 2nd November 2007, 12:55

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