eblc1388 said: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.
Awesome, thanks!
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! ) and will post it later. Basically, it grabs the key ADC value from a LUT and then subtracts 2 and sets the "low range", then it adds 4 and sets the "high range", giving me -2 and +2 ( 4 number range) to compare against.
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: