![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
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. |
|
|
|
|
|
|
(permalink) | |
|
Quote:
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. |
||
|
|
|
|
|
(permalink) | |
|
Quote:
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? |
||
|
|
|
|
|
(permalink) | |
|
Quote:
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). |
||
|
|
|
|
|
(permalink) | ||
|
Quote:
Quote:
|
|||
|
|
|
|
|
(permalink) | |
|
Quote:
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) If you get other readings than these with this setup your PIC code is wrong You're welcome. Last edited by mcs51mc; 10th August 2007 at 02:41 PM. |
||
|
|
|
|
|
(permalink) | |
|
Quote:
Typical sales man talk. Sell a "bad" product now and an upgrade later on. That's twice $$$$$$ |
||
|
|
|
|
|
(permalink) |
|
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.
__________________
L.Chung |
|
|
|
|
|
|
(permalink) | |
|
Quote:
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? |
||
|
|
|
|
|
(permalink) | |
|
Quote:
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 by Kyle-s4h; 10th August 2007 at 02:58 PM. |
||
|
|
|
|
|
(permalink) | |
|
Quote:
I have taken into account the "drift" (I think I mentioned it above) -- I am going to finish up the routine this morning (well, that was the plan before we started the 22K resistor talk! Button one, for example is dec 5 -- so my range would be 3-7... button two is dec 10 and would be 8-12, etc. I think that should take care of any noise issues. Last edited by Kyle-s4h; 10th August 2007 at 02:56 PM. |
||
|
|
|
|
|
(permalink) | |
|
Quote:
Your application is on the left side of the ANx pin thus only VA and Rs in that picture. The circuit represented in the dotted line is different for every design. Yours is a 8k2 resisitor in serie with your key pad between +5V and GND. The connection between the 8k2 and the key pad is also connected to the PIC ADC pin preferably with an opamp with a gain of 2 in between |
||
|
|
|
|
|
(permalink) |
|
Ah! I understand you -- thanks!
I found out on my own that it doesn't work by creating a direct short! (It's not too bad with the Inchworm+ and Unicorn USB upgrade though... it simply creates an unknown USB device on any short... delete the device, do a reboot and you're good to go!) I am going to do some reading on op amps later today and will probably go that route as it has been suggested by the pros! For now, I'm going to go stick a 1K in and see what changes -- if for nothing else than to understand what the different resistor values do to the ADC. I have learned SO MUCH this morning -- thank you to all who have replied! |
|
|
|
|
|
|
(permalink) | |
|
Quote:
I would just use the ADRESH result as an index to a lookup table which give me "5" for ADRESH=4,5 or 6. I think a +1 margin each side of the intended value is adequate and sufficient but certainly there is no harm going for a +2 margin.
__________________
L.Chung |
||
|
|
|
|
|
(permalink) |
|
Hmmm... never thought of it that way -- but unless I am not quite understanding what you are saying, my LUT would be huge. Using the posted values above, I would need 66 indices as my largest number is 65 ,plus one on the high side.
Compounding that would be the fact that I just went down to a 1K resistor, which provides bigger steps, but also a bigger range (0 - 226). This would mean I would need 227 indices? |
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Latest |
| Analog Meter | windozeuser | General Electronics Chat | 19 | 3rd October 2007 02:44 PM |
| A/D, value for Vref on PICs for best accuracy. | Odin | Micro Controllers | 12 | 19th June 2007 03:04 AM |
| help on A/D conversion on pic18F2620 | lionman | Micro Controllers | 0 | 15th May 2007 03:28 PM |
| A/D problem | Merkur | Micro Controllers | 8 | 3rd February 2007 10:35 AM |
| Specifications Applied | Caltech | General Electronics Chat | 1 | 25th December 2003 05:00 PM |