In circuit tester (Pass or Fail Conflict)

Hi Guys
I have some code down below which is being used in a home made in-circuit tester, this code tests all test pins for short circuits against one another and the code is working fairly well, it will print a pass or fail for each pin and at the end of the test i have a list of result

The only problem i have is that some of the pins are shorted through tracks on the PCB board i wish to test, What i now need to introduce into the code is a way of saying the 8 pairs of pins that are shorted are still passes even though they are returning a high reading.

For example
Pins 2-66 are all tested against one another they are taken for a one dimensional array one at a time and tested.
All Pins except (2 and 10) (23 and 44) (24 and 30 ) (29 and 31) (32 and 33) (39 and 41) (42 and 47) and (55 and 60) will return a low and a pass but the above pairs will return a high and a fail,
What i want my code is to acknowledge these high as passes.

I have thought of introducing a 2 dimensional array with these pairs but i am not quiet sure on how to implement it

Let me know what you think

template<class T> inline Print &operator <<(Print &obj, T arg) { obj.print(arg); return obj; }

// Don't use pin 0 & 1 else serial monitor wont work
const byte pinArray[] = {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66};  


//sizeof(pinArray) returns the size of the array in bytes not elements so if your using a byte array it will match the number of elements 
//but if it was an int/long array then the sizeof will be 2x/4x times respectfully the number of elements in the array as int uses 2 bytes to store and long uses 4 bytes. 
//Print the sizeof(pinArray)  value and then change the array type to int/long and print it again and you will see. 
const byte pinArraySize = sizeof(pinArray) / sizeof(pinArray[0]); 

void setup(){
  Serial.begin(9600);
}

void loop(){
  
  for (byte a = 0; a < pinArraySize - 1; a++){    // Loop from start to penultimate entry of array 
    pinMode(pinArray[a],OUTPUT);                  // Set pin to output
    digitalWrite(pinArray[a],LOW);                // Set it low
    Serial << "Pin " << pinArray[a] << " to...\r\n";
    
    
    for (byte b = a + 1; b < pinArraySize; b++){  // Loop from test pin + 1 to end of array
      pinMode(pinArray[b],INPUT_PULLUP);          // Set pin to input with pullup to stop floating pin errors
      Serial << "\tPin " << pinArray[b] << " = ";
      
      
      if (digitalRead(pinArray[b]) == LOW){       // Has the pin been pulled low by a short?
        Serial.println(" ****FAIL****");
      }
      else {
        Serial.println("PASS");
      }
      pinMode(pinArray[b],INPUT);                 // Turn off pullup resistor
    }
    pinMode(pinArray[a],INPUT);                   // Set back to input
  }
  while(1){};                                     // Loop forever
}

I don't have a lot of arduino programming experience so if my suggestion sounds bogus feel free to ignore it.
If I were doing it I would have a boolean flag for each pin and set each flag when that pin passes. At the end of cycling through all the pins I would do a either an IF or a CASE to check if the eight pins all have FAIL flags and if so the FAIL for ONLY those pins and no others would yield a PASS for ALL the FAIL pins IF AND ONLY IF the FAIL PINS ARE THE ONES THAT ARE SHORTED ON THE BOARD.

Does that make sense ? (FAIL = PASS). (Sounds crazy huh ?)

My code writing is not up to much i can promise you
So are you saying at the end of the code

 if (digitalRead(pinArray[b]) == LOW){       // Has the pin been pulled low by a short?
        Serial.println(" ****FAIL****");
      }
      else {
        Serial.println("PASS");

Maybe a piece of code like this

const byte safeArray[] = {
{2,10},{23,44},{24,30}
}; // This would come at the beginning  of the code
if ( safeArray == High);

switch (byte b)

case 'a':
digitalRead (2, Low)
break;

case 'b':
digitalRead (3, Low)
break;

case 'c':
digitalRead (4, Low)
break;

Somewhere , somehow you need to do a LOGICAL AND of ALL the internally shorted pins so
Let the numbers represent the flags for those pins , then

(2 AND 10) => (PIN-2 LOW AND PIN-10 LOW) => PASS for 2 & 10 ONLY ! (ACTION=> set flags for 2 & 10 to PASS)
(23 AND 44) => (PIN-23 LOW AND PIN-44 LOW) => PASS for 23 & 44 ONLY ! (ACTION=> set flags for 23 & 44 to PASS)
(24 AND 30 )=> (PIN-24 LOW AND PIN-30 LOW) => PASS for 24 & 30 ONLY ! (ACTION=> set flags for 24 & 30 to PASS)
(29 AND 31) etc. =============================================> etc.
(32 AND 33) etc. =============================================> etc.
(39 AND 41) etc. =============================================> etc.
(42 AND 47) etc. =============================================> etc.
(55 AND 60) etc. =============================================> etc.

deanjames:
The only problem i have is that some of the pins are shorted through tracks on the PCB board i wish to test, What i now need to introduce into the code is a way of saying the 8 pairs of pins that are shorted are still passes even though they are returning a high reading.

For example
Pins 2-66 are all tested against one another they are taken for a one dimensional array one at a time and tested.
All Pins except (2 and 10) (23 and 44) (24 and 30 ) (29 and 31) (32 and 33) (39 and 41) (42 and 47) and (55 and 60) will return a low and a pass but the above pairs will return a high and a fail,
What i want my code is to acknowledge these high as passes.

I have thought of introducing a 2 dimensional array with these pairs but i am not quiet sure on how to implement it

Are you really saying that these specific pairs of pins are required to be a short in order for the test to pass? If so, the simplest approach I can see would be to define a 2-d array of booleans which specify whether the expected result (for the corresponding pin pair) is shorted or not shorted. I don't know how many pins you will have in total, but you could consider storing the array in progmem, and using one bit per entry (rather than one byte) to reduce the runtime memory requirements.

It is a common practice in circuit board design to jumper grounds or power on a pcb . In some cases each signal has a corresponding ground, hence multiple grounds. The go the the connector because the twisted pairs connect there.

so if i change the section of the loop to:

if (digitalRead(pinArray**) == LOW && !ShortedOnPcb(a,b)){ // Has the pin been pulled low by a short?**
__ Serial.println(" FAIL");__
** }**
** else {**
** Serial.println("PASS");**
** }**
Then add the ShortedOnPcb() method:
boolean ShortedOnPcb(byte outputPin, byte inputPin) {
** switch(outputPin) {**
** case 2:**
** return (inputPin==10);**
** break;**
** case 23:**
** return (inputPin==44);**
** break;**
** ...**
** }**
** return false;**

  if (digitalRead(pinArray) == LOW && !ShortedOnPcb(a,b)){       // Has the pin been pulled low by a short?
    Serial.println(" ****FAIL****");
  }
  else 
{
    Serial.println("PASS");
  }

Then add the ShortedOnPcb() method:

boolean ShortedOnPcb(byte outputPin, byte inputPin)
 {
  switch(outputPin)
 {
    case 2:
      return (inputPin==10);
      break;
    case 23:
      return (inputPin==44);
      break;
  }
  return false;

I can't follow your code without the declarations. Put those in there explaining what outputpin & inputpin mean. I don't know what the reason for this naming is.

the only problem i have is that some of the pins are shorted through tracks on the PCB board i wish to test, What i now need to introduce into the code is a way of saying the 8 pairs of pins that are shorted are still passes even though they are returning a high reading.

For example
Pins 2-66 are all tested against one another they are taken for a one dimensional array one at a time and tested.
All Pins except (2 and 10) (23 and 44) (24 and 30 ) (29 and 31) (32 and 33) (39 and 41) (42 and 47) and (55 and 60) will return a low and a pass but the above pairs will return a high and a fail,
What i want my code is to acknowledge these high as passes.

What I mean is, like with this,

boolean ShortedOnPcb(byte outputPin, byte inputPin)

(2 and 10 )
(23 and 44)
(24 and 30 )
(29 and 31)
(32 and 33)
(39 and 41)
(42 and 47)
(55 and 60)

Can you tell me which of these are Inputpins and which are outputpins ?

Well the way i was thinking was that the boolean keyword indicates that shortedOnPcb() is a function. Functions always have a return value, in this case either true or false, so it's a boolean function.

shortedOnPcb() will return TRUE if the two pins currently being looked at are supposed to be shorted, FALSE if they're not supposed to be. ! negates the value.

The first number in the pair will always be the output because this is the pin we set as a high, we then read a the second number to see if its high or low

Boolean is NOT a function. It is a variable type. Google it

Ok thanks for your help on this

Try a simple test .Configure one pin as Input and another as Output.
Connect a jumper between the two.
Create a Boolean called PinStatus.. Set it False at the beginning and then turn On the Output.

#define Led=13;
#define Inpin 5;
#define Outpin 6;
Boolean PinStatus;

void setup()
{
   pinMode(Inpin,INPUT);
  pinMode(Outpin,OUTPUT);
 PinStatus=False;
  }
 
  void loop()
   {

digitalWrite(Outpin,HIGH);
PinStatus=True;
   if (PinStatus== True)
{
   digitalWrite(Led,HIGH);
  }
delay(1000);

digitalWrite(Outpin,LOW);
PinStatus=False;
delay(1000);
   if (PinStatus== False)
{
   digitalWrite(Led,LOW);
  }
}