Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

A/D Conversion accuracy

Status
Not open for further replies.
Finally someone using 8 bit addressing to the LCD; good point !

For the key pad I'm still convinced that we don't know how it's working; bad point!
If your absolutely sure it's only a resistor devider like the sketch I made in a hurry this morning then you should first take your Ohm meter and measure the resistance in all possible combinations.
Then and only then you can design a correct circuit toward the PIC ADC.
 
mcs51mc said:
Finally someone using 8 bit addressing to the LCD; good point !

For the key pad I'm still convinced that we don't know how it's working; bad point!
If your absolutely sure it's only a resistor devider like the sketch I made in a hurry this morning then you should first take your Ohm meter and measure the resistance in all possible combinations.
Then and only then you can design a correct circuit toward the PIC ADC.

Go back and re-read the thread -- this is one of the first things I did...
 
Nigel Goodwin said:
Why would you prefer 8 bit mode?, it's just wasteful of I/O.

Why not, does it look like I'm in need of saving 4 I/O pins? ;)

A three cylinder car will get you to where you're going -- but an 8 is just wasteful, but so much more fun to drive!
 
Last edited:
Kyle-s4h said:
Go back and re-read the thread -- this is one of the first things I did...
I never saw Ohmic values for every key pressed only some weird hex data because of a bad design :p:p

How do you expect us to help you with a good design since you don't give us the basic data needed ? :(
 
mcs51mc said:
I never saw Ohmic values for every key pressed only some weird hex data because of a bad design :p:p

How do you expect us to help you with a good design since you don't give us the basic data needed ? :(


A few points...

1) Why would you possibly call the ADC "weird hex data"?

2) Why would you say this is a "bad design" -- please be specific.

3) I never asked for design help -- I asked specific questions regarding A/D Conversion.

4) What the specific resistance values are are irrelevant (but I will post them for you below) -- the point is to get readings from them for A/D Conversion (which is what I asked about).


#0 R1 0
#1 R2 .527
#2 R3 .962
#3 R4 1.441
#4 R5 2.019
#5 R6 2.692
#6 R7 3.509
#7 R8 4.540
#8 R9 5.770
#9 R10 7.530

I am not concerned with dual button decoding (as mentioned in one of my earlier posts), so dual button resistance values have not been taken at the present time.

I look forward to your new and improved "good design" based on the quoted resistance values.

PS - if you want pass-thru voltage readings, I can post them as well.
 
Kyle-s4h said:
Why not, does it look like I'm in need of saving 4 I/O pins? ;)

A three cylinder car will get you to where you're going -- but an 8 is just wasteful, but so much more fun to drive!

Except in this case the 3 cylinder car performs exactly the same as the 8 cylinder one, but only uses half the petrol :p
 
@Nigel -- page 114 of the 16f87X datasheet;

The maximum recommended impedance for analog sources is 10K:eek:hm:

Thank you -- I will change the resistor (actually, I'll change it a couple of times... ie. 12K, 10K, 2K, 1K, just to see the results).
 
Nigel Goodwin said:
Except in this case the 3 cylinder car performs exactly the same as the 8 cylinder one, but only uses half the petrol :p

Depends on what kind of a guy you are I guess... I'll be there in half the time (and a lot safer... ever seen a "big" 3 cylinder?). :D
 
Oh, I was simply pointing out that you were correct and my 22K resistor was way over the limit! I realize that it will vary from PIC to PIC, but at least I have learned and know to check the datasheet in the future. I'm happy -- the day is young and I've already learned something new today! ;)

I'm going to go change it and see what kind of results I get.
 
Kyle-s4h said:
@Nigel -- page 114 of the 16f87X datasheet;



Thank you -- I will change the resistor (actually, I'll change it a couple of times... ie. 12K, 10K, 2K, 1K, just to see the results).
The 10k ohms limit is required to meet the pin leakage specification.
The equivalent resistance 'seen' by the analog input should be as low as possible. You can change the external resistor, but not those inside the lock. The solution is to use an op amp, wired as a voltage follower, to feed the A/D converter.
 
eng1 said:
The 10k ohms limit is required to meet the pin leakage specification.
The equivalent resistance 'seen' by the analog input should be as low as possible. You can change the external resistor, but not those inside the lock. The solution is to use an op amp, wired as a voltage follower, to feed the A/D converter.

Interesting -- I did a quick read on op-amps -- they'll definitely require more reading than I have time for right now! :)

A question would be -- is that really needed though? If I put a 1K resistor in place of the 22K, with my top resistance reading from the keypad of 7.53K, that would still keep my under the total 10K limit (8.53K), no?

So, without knowing a whole lot about op amps, it seems to me that replacing the 1K resistor with an op amp would only save me 1K of resistance (seeing as I cannot change the resistors in the keypad). Am I confused? :)
 
kyle-s4h said:
The thing that I have noticed that is strange is the fact that I am only using the ADRESH byte for my calculations. I just got up and have not looked at the datasheet or midrange manual regarding A/D Conversion, but I was under the impression that the high byte should only contain the first 2 LSB, with the upper 6 clear. Nigels tutorial even masks the upper 6 bits to make sure they are clear. Anyway, what I am seeing is a consistent LOW byte (either C0/00 or 80/40) and a HIGH byte that is unique (but using more than the first two bits).

While reading the datasheet on A/D Conversion, I also noted a "left" and "right" justification for the A/D results -- the default is left justified, which is what I am using. This, to me, makes the above statement make sense -- if I am understanding this correctly.

When set to left justify, I am using ALL bits of the HIGH byte, and only the 2 MSB of the LOW byte -- correct? That would explain why I only get two readings from the LOW byte (C0 & 80) and all readings for the HIGH byte are different (as posted above).
 
Kyle-s4h said:
A question would be -- is that really needed though? If I put a 1K resistor in place of the 22K, with my top resistance reading from the keypad of 7.53K, that would still keep my under the total 10K limit (8.53K), no?
The limit for proper operation of the A/D converter is about 2k ohms, as mentioned. Anything lower is better. The op amp provides a low output impedance, in the order of hundreds of ohms.


Kyle-s4h said:
So, without knowing a whole lot about op amps, it seems to me that replacing the 1K resistor with an op amp would only save me 1K of resistance (seeing as I cannot change the resistors in the keypad). Am I confused? :)
Not exactly a replacement. You can still use the external resistor, if required, but it shouldn't be too high or the maximum voltage that appears at the ADC input is far less than 5 V.
 
Kyle-s4h said:
I'm going to go change it and see what kind of results I get.
Sorry but wrong again :)
First calculate what you can expect then change it.

I suppose the values you posted earlier are kOhm.
Then I suggest using 8.2 kOhm serie resistor and like eng1 already suggested a opamp with a gain of 2.
Serie resistor & lock resistors feed from 5V same as Vref of the PIC

That way you get the following results:

Key Voltage ADC bits Hex
# 0 0.000 000 0000
# 1 0.604 123 007B
# 2 1.050 215 00D7
# 3 1.495 306 0132
# 4 1.976 404 0194
# 5 2.472 506 01FA
# 6 2.997 613 0265
# 7 3.564 729 02D9
# 8 4.130 845 034D
# 9 4.787 980 03D4

Like you see no tricky "either C0/00 or 80/40" stuff (what I call weird hex data) only streight forward data from 0000 to almost 0400 (1024) :D

If you get other readings than these with this setup your PIC code is wrong :p

You're welcome.
 
Last edited:
Kyle-s4h said:
Interesting -- I did a quick read on op-amps -- they'll definitely require more reading than I have time for right now! :)
Off topic and with many :):):):):):)
Typical sales man talk.
Sell a "bad" product now and an upgrade later on.
That's twice $$$$$$
:):):):):):)
 
You are correct about the left justification of the ADC result. This is user configurable but after PIC reset, it defaults to left justify on the 16F873.

You should make provisions for your key value comparison routine because you have not taken into account the two LSBs. So a value of 0x05 in ADRESH could means 0XC0 or 0x00 in the ADRESL register. If you test for equality of 0x05 for a particular key, then by some drifts later the value of ADRESL increased or decreased by one bit, your ADRESH will increment/decrement, becoming 0x06 or 0x04. Your routine will then fail to return the correct key value.
 
eng1 said:
The limit for proper operation of the A/D converter is about 2k ohms, as mentioned. Anything lower is better. The op amp provides a low output impedance, in the order of hundreds of ohms.

Man, I really don't want to sound stupid here... but is this 2K limit for "proper operation" just something "you have to know", or am I not following you? I mean, the datasheet for the 16F87X says the limit is 10K (as I stated above).

Page 114 of the datasheet (Figure 11-2) shows an analog input model -- Ric shows a resistor of 1K or less between the sampling switch and the input pin (I am not actually using it BETWEEN, I have it wired as a pull up)... and it also shows a 5pF cap between the input pin and Vss. That would work, and probably better. I have a 0.1 cap on the power rail near the ADC input, but not actually on it. The whole point to the resistor was simply to provide protection against a direct short on initialization -- the cap would do that. It would provide a constant power supply to the ADC input and protect against a direct short, no?
 
mcs51mc said:
Off topic and with many :):):):):):)
Typical sales man talk.
Sell a "bad" product now and an upgrade later on.
That's twice $$$$$$
:):):):):):)


LOL! Not what I was thinking! I am a service tech and pride myself on having a callback rate of as near to zero as one could hope for. I like to do the job once -- and correctly at that! :)

I only meant "at this particular minute" -- I usually print stuff like this out and put it beside my La-Z-boy for later perusal! ;)
 
Last edited:
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top