1
\$\begingroup\$

I'm reading an analogic signal (0-5v) with a pic 18f458 by an0. I'm setting an3 as vref+ and used a 3.3V Zenner. I'm changing the signal with a potentiometer. I've used a multimeter to check the voltage in an0.

An0 is changing with this values: 1, 7, 15, 31, 68, 127, 255, 512, 768, 848, 960, 1001, 1023.

Why doesn't show the other values like 300, 20... ?

The voltage changes in a resolution of mV.

Datasheet

\$\endgroup\$
2
  • 1
    \$\begingroup\$ May I suggest that you configure Vref+ to Vdd and Vref- to Vss to eliminate hardware issues with the "Zener reference" and certify that the software part is correct? It is a 10 bit A/D, so all values from 0 to 1023 should be possible. Besides, if you use a 3.3V reference and read values from 0 to 5V it would not be possible to read voltages from 3.3 V to 5V. \$\endgroup\$
    – devnull
    Commented Oct 12, 2021 at 0:24
  • \$\begingroup\$ what is the resistance value of your potentiometer? \$\endgroup\$ Commented Oct 12, 2021 at 4:29

2 Answers 2

2
\$\begingroup\$

If your ADC is only giving you those numbers you may have done something wrong with the timing. Check your parameters are okay as shown on pages 245 and 246, and check that you're actually waiting until the GO/nDONE flag in ADCON0 is cleared before reading the result bytes (assuming you are polling rather than using the ADC interrupt).

By the way, it's not your problem here, but a 3.3V zener makes a very poor reference, both in regulation and temperature stability. It would be better to use an IC reference.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ You' re right. I checked the timming. Set ADCS and now is working. I'm really greatful. \$\endgroup\$
    – ted9090
    Commented Oct 12, 2021 at 13:13
1
\$\begingroup\$

You are able to measure finer differences than what you can readily produce with your hand and potentiometer. This is a good problem to have. If you keep reading these values in a constant loop, you will eventually be able to get to every number. You just have to keep trying, noise plays a factor too.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.