Automated in circuit Tester

Hi
I am currently building a In-circuit tester for a pcb board and i am using a Arduino Mega for the test part.
The main description of the project is that i have 66 test pins that i need to check for short circuits between solder joints on a PCB.
To do this i plan to use the the 54Digital i/o and also the 16 analogue outputs (used as digital i/o)
My main issue is the structure of the code
Because i have to use so many i/o i plan to use a number of arrays to store them in,
I then plan to use different functions to implement the code

So if i take the first test 10 test pins
I plan to write a high to test pin 1 and the read from test pin 2, if value is the same then flag an error,
else
I then write a high to test pin 3 and read from test pin 2 and 4, if value is the same in either of the reads then flag an error
else
i then write a high to test pin 5 and read value from test pin 4 and 6, if value is the same in either of the reads then flag an error
else
i then write a high to test pin 7 and read value from test pin 6 and 8, if value is the same in either of the reads then flag an error
else
return test passed[/color]

As you can see it could be a long code if im going to use arrays.
What my question is if i use an array for the write and an array for the read, then implement the write and read for all the pins at the same time would this work?

I would also like to be able to pin point a fault to an output but if i am using arrays would this be possible?
I am looking for some tips on were to get started and setting out a structure for my code?
Regards James

From your description I assume the pins are all adjacent to each other else you should check all other pins against a single output pin.
You can simplify your idea by just setting each pin in sequence high and checking the next sequence pin instead of going up alternate pins and checking the pins below and above.

for (byte pin = 0; pin < sizeof(array)-1; pin++){
  pinMode(array[pin],OUTPUT);
  pinMode(array[pin+1],INPUT);
  digitalWrite(array[pin],HIGH);
  if (digitalRead(array[pin+1]) == HIGH);
    // Short circuit between array[pin] & array[pin+1]
}

Hi
See the attached schematic for the PCB i intend to test, if we take the middle pins with the blue wire. we can see that test pin 1 and pin 2 will be tested together but then test pin 3 and test pin 2 will need to be tested also and so on
Should i consider putting all the write pins into a single array and then maybe breaking the read pins into a few different arrays which would make it easier to pin point if a short circuit occurs?

My standard of code writing is obviously very low, could you explain to me why you used the -1 in the function,
sizeof(array)-1

Thanks James

ict.doc (236 KB)

Does this PCB have tracks that go all over the place? If so you can't assume anything and should test every pin against every other pin.

In fact why not just do that, it will still only take a poofteenth of a second.

If some are supposed to be connected there won't be many so have an "exceptions" list.


Rob

deanjames:
See the attached schematic for the PCB i intend to test, if we take the middle pins with the blue wire. we can see that test pin 1 and pin 2 will be tested together but then test pin 3 and test pin 2 will need to be tested also and so on
The code I wrote would go through all the pins 1-2, 2-3, 3-4 and so on. It would be testing 2 & 3. In light of the picture you supplied it may be better to test all other pins against a single output pin as it's not a simple DIP design.
My standard of code writing is obviously very low, could you explain to me why you used the -1 in the function,
sizeof(array)-1
My coding skills are not brilliant but say you have an array of 50 pins starting at [0] ending at [49] then the code I wrote tests a pin against the next pin in the array (pin+1) so I need to loop from 0 to 48 (the -1 part of sizeof) and the last test would be [48] to [48+1].

Graynomad:
In fact why not just do that, it will still only take a poofteenth of a second.

I though you made that unit of measurement up but it exists XD

Yes, it's just a tad smaller than two fifths of five eights of naff all.

EDIT: Which I see must be a lot smaller than option 4 on that link :slight_smile:


Rob

Yes i agree testing all pins against all pins makes sense, So if i make pin 1 the main output pin and test all other pins against it, how will that show me a short circuit between pins 5 and 6?

The PCB has tracks that go all over the place, the In circuit tester will be used to test students bad soldering joints, the joints are very close to one another, so the probability of a short circuit between joints

The board that is to be tested has a LCD on it, so i hope to use this clarify if the board passes the test, this is also going to be part of an overall functionality test for the board

how will that show me a short circuit between pins 5 and 6?

You test all pins against pin 1, then move to pin 2, then 3, 4, etc.

EDIT: Oh and remember you have to test for connectivity where pins are supposed to be connected as well.

Another oh. It seems you will be testing a loaded board so you have to be careful not to apply inappropriate voltages to components, for example applying 5v to a data pin on the LCD when it has no power etc. May be an issue maybe not, it depends on the components in question.


Rob

Hi Rob

yes the loaded board will come in to play further down the line and will be an issue but for now i just want to get a basic idea of the code i need to test against short circuits.
If i was to go down the route of testing all 66 solder joints against each other, would it be to"write a high to pin 1 then check all 65 pins values", "then write a high to pin 2 then check the values again". would that mean i need 66 different functions? or is there a way to set the same to pin write and then to read multiply time in the same function

with the initial idea of testing just the pins beside one another, the pin is defined in the different arrays as either a write or a read and then used in the functions

Thanks for your patients with this one
John

Here is some more test code to test a pin against all remaining pins for a short from an array list. You will probably have exceptions where some pins will be expected to short out but that could probably be entered in another 2D array. As Rob states you need to be careful with putting 5V into places it should not be so I am using internal pullup resistors to a low pin to check for shorts but this may still be to much for some devices. You have been warned.

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

const byte pinArray[] = {2,3,4,5,6,7,8,9,10,11};  // Don't use pin 0 & 1 else serial monitor wont work
const byte pinArraySize = sizeof(pinArray) / sizeof(pinArray[0]); //Pre calculate array size in elements

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

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("Short");
      }
      else {
        Serial.println("Open");
      }
      pinMode(pinArray[b],INPUT);                 // Turn off pullup resistor
    }
    pinMode(pinArray[a],INPUT);                   // Set back to input
  }
  while(1){};                                     // Loop forever
}

Hi Riva
Thanks for your time on this, its been a great help so far
I have just one or two question about the below code

Could you just me a quick explanation on the below line of code

Serial << "Pin " << pinArray[a] << " to...\r\n";
and
Serial << "\tPin " << pinArray << " = ";
I suppose my only concern with this method is that when pin 1 is writing will it also be trying to read at the same time, (causing an error)
or is this code saying write to pin 1 then check all other pins next write to pin2 check all other pins and so on
Regards John

deanjames:
Could you just me a quick explanation on the below line of code

Serial << "Pin " << pinArray[a] << " to...\r\n";
and
Serial << "\tPin " << pinArray << " = ";
They are just shorthand versions of doing...
```
**Serial.print("Pin ");
Serial.print(pinArray[a]);
Serial.println(" to...");

Serial.print("\tPin ");
Serial.print(pinArray[b]);
Serial.print(" = ");**

```
I suppose my only concern with this method is that when pin 1 is writing will it also be trying to read at the same time, (causing an error)
or is this code saying write to pin 1 then check all other pins next write to pin2 check all other pins and so on
The latter. It sets an array pin to output and then checks all array pins beyond that for a short. Then sets the next array pin and checks all beyond it etc.
[/quote]

Hi Riva

I am only getting back to this now,

if you don't mind explaining just 2 more lines of your code to me

1st the one at the very top of your code, is this meant to be there?
template inline Print &operator <<(Print &obj, T arg) { obj.print(arg); return obj; }
2nd
const byte pinArraySize = sizeof(pinArray) / sizeof(pinArray[0]);
Which says //Pre calculate array size in elements
Should size of the array not depend on the amount of pins and i/o
your code will hopefully work quiet well but i have 10 pairs of joints that are joined together through tracks on the PCB,
you mentioned a 2D array to highlight these pins as a pass, should i have that array in seperate for function but in the same void loop?

deanjames:
if you don't mind explaining just 2 more lines of your code to me

1st the one at the very top of your code, is this meant to be there?
template inline Print &operator <<(Print &obj, T arg) { obj.print(arg); return obj; }
This is there to allow me to do the print streaming stuff. See here.
2nd
const byte pinArraySize = sizeof(pinArray) / sizeof(pinArray[0]);
Which says //Pre calculate array size in elements
Should size of the array not depend on the amount of pins and i/o
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.
your code will hopefully work quiet well but i have 10 pairs of joints that are joined together through tracks on the PCB,
you mentioned a 2D array to highlight these pins as a pass, should i have that array in seperate for function but in the same void loop?
For just ten pair it might be just as easy to hand code them but the principle is if you find a short circuit then check if pin a to pin b is meant to be shorted and ignore if they should else print 'short circuit'.
[/quote]

It is difficult to read responses that are inserted into the quoted text.

polymorph:
It is difficult to read responses that are inserted into the quoted text.

Are you referring to my post? It would be difficult to read in monochrome but otherwise it reads fine for me as the blue stands out enough.

"It looks good to me"

Hi Riva
I realize its being a while but i am still having trouble with separating a real short circuit with a permanent short, i have entered a 2d Array of all the pins that are suppose to have continuity on the board, my hope is to enter into the below code that when a high is seen in these pins to give a pass sign, is it possible to do this inside the final if statement at the end or would i need to start a new for loop for this.
Any help would be appreciated
Thanks

template 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};

//the pins in the safe array are expected to have a high between these pin when testing
int safeArray = { {10,15,19}, {19,38,40,42}, {34,57}, {49,54} };

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**,INPUT_PULLUP); // Set pin to input with pullup to stop floating pin errors**
__ Serial << "\tPin " << pinArray << " = ";__

__ if (digitalRead(pinArray**) == LOW){ // Has the pin been pulled low by a short?
Serial.println(" FAIL");
}
else {
Serial.println("PASS");
}
pinMode(pinArray,INPUT); // Turn off pullup resistor**

** }
pinMode(pinArray[a],INPUT); // Set back to input**

** }
while(1){}; // Loop forever**

} [/color]__