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.
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.
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).
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.
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.
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.
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?
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).
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.
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
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.
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?
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!