I am building a cable tester and need to test pin connections with each other. I want to be able to detect hard wired connections as well as resistance, so I chose Pic18F46K22 due to the amount of Analog pins (28) for connections with each other. All 28 pins are pulled to ground with a 10k resistor. I donít care about actual resistance values, but I do want to be able to detect a hard wired short verses a resistor.
I set up an outside loop from 0-27 which sets up All Analog capable ports to Analog/Inputs (ANSELx/TRISx registers), except for the testing pin which I set up to Digital/Output and set high. I then enter an inside loop from 0-27 reading all analog pins except for the current testing pin. Any values other than zero should indicate a connection between the testing digital pin and the analog pin being tested. I use the defines (ADC_BITS 8, ADC_CLOCK 3, ADC_SAMPLEUS 50).
I am able to detect shorts between pins as well as resistance when I jumper wires/resistors between pins o.k., but I am having a problem where I always detect connections between certain pins although there is no connection between them. The pins falsely detecting shorts are always the same. The following lines show the pins falsely detected along with the digital pin index, and ANSELx register settings during the current test. You can see a pattern in the error where the Analog pin 16 thru 27 (Digital RC4-RD7) shows shorts. Even the pin it shows to be shorted with increases by 1 each time.
Pins 16-0 = 127 Dpin:20 A:00101111 B:00111111 C:11101100 D:11111111 E:00000111
Pins 17-1 = 127 Dpin:21 A:00101111 B:00111111 C:11011100 D:11111111 E:00000111
Pins 18-2 = 127 Dpin:22 A:00101111 B:00111111 C:10111100 D:11111111 E: 00000111
Pins 19-3 = 127 Dpin:23 A:00101111 B:00111111 C:01111100 D:11111111 E: 00000111
Pins 20-4 = 127 Dpin:24 A:00101111 B:00111111 C:11111100 D:11111110 E:00000111
Pins 21-5 = 127 Dpin:25 A:00101111 B:00111111 C:11111100 D:11111101 E:00000111
Pins 22-6 = 127 Dpin:26 A:00101111 B:00111111 C:11111100 D:11111011 E:00000111
Pins 23-7 = 127 Dpin:27 A:00101111 B:00111111 C:11111100 D:11110111 E:00000111
Pins 24-8 = 127 Dpin:28 A:00101111 B:00111111 C:11111100 D:11101111 E:00000111
Pins 25-9 = 127 Dpin:29 A:00101111 B:00111111 C:11111100 D:11011111 E:00000111
Pins 26-10 = 127 Dpin:30 A:00101111 B:00111111 C:11111100 D:10111111 E:00000111
Pins 27-11 = 127 Dpin:31 A:00101111 B:00111111 C:11111100 D:01111111 E:00000111
I also made a test routing which does the same test except it only tests one port at a time (example: Turns on Analog pins AN20 thru AN27 (portD) and only tests them. It works correctly. I also have an all digital routine which tests all the same pins against each other digitally and that also works correctly. The problem seems to be only when all Analog pins are active at the same time, except for the testing pin).
One more note: The value of 127 is actually a hard short. I use the following code to limit the analog reading between 0-127.
ADCIN idx, Pinin
If Pinin <128 then ' Sets analog range 0-127
Pinin = 128
Pinin = pinin -128
I have the weak pull-ups disabled. Am I missing anything important to do with ADC conversions on the 46k22 device?
Thanks for any ideas,