16f88 - pin RA4 as analog input


Closed Thread
Results 1 to 21 of 21

Hybrid View

  1. #1
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    ADCIN 4, adval 'Read channel 4 to adval
    adval1 = adval*2/100
    adval2 = adval*4//10
    Lcdout "POWER: ", DEC2 adval1, ".", DEC1 adval2," WATT "

    I have use this code and show ok

  2. #2
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    I was going to ask how would you see say 2.30V, but Darrel already touched that point.

    Now I wonder where did this "Watt" come from?

    Lcdout "POWER: ", DEC2 adval1, ".", DEC1 adval2," WATT "

    ---------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  3. #3
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sayzer
    Now I wonder where did this "Watt" come from?
    I measure the RF of a FM linear with a wattmeter.The output is in volt.
    This volt i want to measure , and show on LCD.

  4. #4
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Ok, that makes sense now.

    -----------------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

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


    Did you find this post helpful? Yes | No

    Default

    ADCIN 4, adval 'Read channel 4 to adval
    adval1 = adval*2/100
    adval2 = adval*4//10
    Lcdout "POWER: ", DEC2 adval1, ".", DEC1 adval2," WATT "
    I don't think that's what you want.

    Let's say that you have 4.8 V on the input. You'll get an A/D reading of 249.

    249 * 2 / 100 = 4   This part is ok
    249 * 4 = 996, and //10 gives 6
    So that would display as 4.6 instead of 4.8

    Or if you had 4.2 V, (214 A/D)

    214 * 2 / 10 = 4   Still OK
    214 * 4 = 856, and //10 gives 6
    Still displays as 4.6 instead of 4.2

    Here are some more results
    Code:
    Volts	A/D	Whole#	4*A/D	//10	Result
    5.00	255	5	1020	0	5.0
    4.90	249	4	996	6	4.6
    4.85	247	4	988	8	4.8
    4.80	244	4	976	6	4.6
    4.75	242	4	968	8	4.8
    4.70	239	4	956	6	4.6
    4.65	237	4	948	8	4.8
    4.60	234	4	936	6	4.6
    4.55	232	4	928	8	4.8
    4.50	229	4	916	6	4.6
    4.40	224	4	896	6	4.6
    4.30	219	4	876	6	4.6
    4.20	214	4	856	6	4.6
    I think you should take another look at the formulas in post #9
    DT

  6. #6
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor
    I don't think that's what you want.

    Let's say that you have 4.8 V on the input. You'll get an A/D reading of 249.

    249 * 2 / 100 = 4   This part is ok
    249 * 4 = 996, and //10 gives 6
    So that would display as 4.6 instead of 4.8

    Or if you had 4.2 V, (214 A/D)

    214 * 2 / 10 = 4   Still OK
    214 * 4 = 856, and //10 gives 6
    Still displays as 4.6 instead of 4.2

    Here are some more results
    Code:
    Volts	A/D	Whole#	4*A/D	//10	Result
    5.00	255	5	1020	0	5.0
    4.90	249	4	996	6	4.6
    4.85	247	4	988	8	4.8
    4.80	244	4	976	6	4.6
    4.75	242	4	968	8	4.8
    4.70	239	4	956	6	4.6
    4.65	237	4	948	8	4.8
    4.60	234	4	936	6	4.6
    4.55	232	4	928	8	4.8
    4.50	229	4	916	6	4.6
    4.40	224	4	896	6	4.6
    4.30	219	4	876	6	4.6
    4.20	214	4	856	6	4.6
    I think you should take another look at the formulas in post #9
    You are right , but I don't understand how to write the code for the remainder to show right the decimal

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


    Did you find this post helpful? Yes | No

    Default


  8. #8
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor
    Thank you

Similar Threads

  1. Is this a K Type sensor?
    By jessey in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 21st November 2009, 14:55
  2. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 18:27
  3. Another RTC, DS1287
    By DavidK in forum Code Examples
    Replies: 0
    Last Post: - 12th December 2006, 18:07
  4. 16F88 reading Analog Input
    By thunderstrike44 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th August 2004, 23:41
  5. Pin RA4 doesn't work
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 0
    Last Post: - 15th July 2004, 13:03

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