PIC18F45k80 ADC Module

Thread Starter

Djsarakar

Joined Jul 26, 2020
489
Can only guess, but maybe your code sets RA0 as output instead of input?
I am running your code in Post #8. In the code RA0 is input Pin that receive analog signals. When I am running the same program I don't know why I am getting random values shown in post #20
 

hexreader

Joined Apr 16, 2011
581
Makes no sense to me - a bit of wire should have same voltage at both ends.

When I set my Pot to 2.5 Volts I get values wavering around between 2070 and 2080 decimal - exactly as I would expect.
 

JohnInTX

Joined Jun 26, 2012
4,787
I measured output voltage of pot 2.50 v but I get 50m volt at RA0 pin
The wiper of the pot should be connected to PIN2 of the PIC. That is AN0. I don't know why you are referring to AN11 and AN12.
Obviously, the voltage on the pot wiper has to be the same as the voltage on PIN 2 / AN0. If it isn't, it is wired wrong.

EDIT: I didn't see @hexreader 's previous post. I agree with his analysis.
 
Last edited:

hexreader

Joined Apr 16, 2011
581
Pot 11 - Alpha November one one (AN11 - 2 letters, two numbers) - wrong - bad - do not do this
Pot 1 - Alpha November India one (ANI1 - 3 letters, one number) - correct - good
Nothing to do with your issues - but has caused confusion

Does PIC pin2 show 2.5 Volts when wired to Pot 1 set half way yet?
RA0 pin 2 of PIC - is pin 1 (end pin of 9) of the PORTA/E connector BRK21
 
Last edited:

JohnInTX

Joined Jun 26, 2012
4,787
The red wire at ANI 1 pin looks a little flat. Maybe it’s broken at the connector. Try another one. Also, remove the PIC from the socket, power up the board and measure the voltage at pin 2 (RA0) of the ZIF socket to to make sure that the program isn’t the problem. The voltage at the ZIF pin 2 should follow the pot. Poke around until you find out why it isn’t. Fix that; then try the PIC again.

@Djsarakar
EDIT: looking at the back of your board, I think you are hooked to PIC pin 3 not pin 2.
https://forum.allaboutcircuits.com/threads/pic-development-board-with-pk3.172494/post-1554057
 
Last edited:

Thread Starter

Djsarakar

Joined Jul 26, 2020
489
EDIT: looking at the back of your board, I think you are hooked to PIC pin 3 not pin 2.
https://forum.allaboutcircuits.com/threads/pic-development-board-with-pk3.172494/post-1554057
Hi @JohnInTX, All credit goes to you to find the exact problem. Thank you very much for saving me from trouble

Look Up Table
Code:
ADC_VAL   Voltage
-----------------
    0     0.000 V
    1     0.001 V
    2     0.002 V
    3     0.003 V
    4     0.004 V
    5     0.005 V
    6     0.006 V
    7     0.007 V
    8     0.008 V
    9     0.009 V
    11    0.010 V
    12    0.011 V
    12    0.012 V
    13    0.013 V
    14    0.014 V
    15    0.015 V
    16    0.016 V
    17    0.017 V
    18    0.018 V
    19    0.019 V
    20    0.020 V

    21    0.021 V
    22    0.022 V
    23    0.023 V
    24    0.024 V
    25    0.025 V
    26    0.026 V
    27    0.027 V
    28    0.028 V
    29    0.029 V
    30    0.030 V


    31    0.031 V
    32    0.032 V
    33    0.033 V
    34    0.034 V
    35    0.035 V
    36    0.036 V
    37    0.037 V
    38    0.038 V
    39    0.039 V
    40    0.040 V
   
    41    0.041 V
    42    0.042 V
    43    0.043 V
    44    0.044 V
    45    0.045 V
    46    0.046 V
    47    0.047 V
    48    0.048 V
    49    0.049 V
    50    0.050 V

    51    0.051 V
    52    0.052 V
    53    0.053 V
    54    0.054 V
    55    0.055 V
    56    0.056 V
    57    0.057 V
    58    0.058 V
    59    0.059 V
    60    0.060 V
   
    61    0.061 V
    62    0.062 V
    63    0.063 V
    64    0.064 V
    65    0.065 V
    66    0.066 V
    67    0.067 V
    68    0.068 V
    69    0.069 V
    70    0.070 V

    71    0.071 V
    72    0.072 V
    73    0.073 V
    74    0.074 V
    75    0.075 V
    76    0.076 V
    77    0.077 V
    78    0.078 V
    79    0.079 V
    80    0.080 V

    81    0.081 V
    82    0.082 V
    83    0.083 V
    84    0.084 V
    85    0.085 V
    86    0.086 V
    87    0.087 V
    88    0.088 V
    89    0.089 V
    90    0.090 V


    91    0.091 V
    92    0.092 V
    93    0.093 V
    94    0.094 V
    95    0.095 V
    96    0.096 V
    97    0.097 V
    98    0.098 V
    99    0.099 V
    100   0.100 V

    101    0.101 V
    102    0.102 V
    103    0.103 V
    104    0.104 V
    105    0.105 V
    106    0.106 V
    107    0.107 V
    108    0.108 V
    109    0.109 V
    110    0.110 V

    650    0.650

    999    0.999 V
    1000   1.000 V

  ...
4094     4.998 V
4095     4.999 V
result at RA0 pin
Code:
A0 Pot at 0.03 V
  0035
  0036
  0035
  0036
  0037
  0023
  0035
  0036
  0037
  0028
  0035
  0035
  0036
  0037
  0036
  0036
  0035
  0036
  0036
  0035
  0036
  0039
  0030

A0 Pot at 2.30 V

  1877
  1869
  1883
  1876
  1876
  1886
  1886
  1883
  1878
  1886
  1869
  1886
  1869
  1869
  1904
  1883
  1877
  1883
  1869
  1877



A0 Pot at 4.59 V

  3693
  3727
  3717
  3745
  3739
  3732
  3732
  3717
  3738
  3717
  3709
  3709
  3717
  3693
  3717
  3693
  3738
  3717
  3745
  3693
  3709
 
Top