We sell hundreds of Arduinos every month, and from time to time we get one returned as faulty. As technical support & product design for Proto-PIC.co.uk , I decided to make a shield for testing them. Thinking about how to do this, I thought about building 2 shields, one for input and one for output. But decided as the Arduino can control the pin status for input and output, I could pair them up, and test the pins in pairs. This would show a fault in 2 pins at test time, but this is not an issue as a failed pin would cause the whole board to fail the test. I could then look at replacing the ATMEGA 328 if needed, or at least give me a starting point to fault find.
Step 1: Sketching Out the Idea
While the shield is not a difficult one to design and assemble, I still made a sketch on paper of the connections I wanted, and also made a 'Pin Map' to help understand this later.
My Pin Map starts with a list :
I then write next to the pin number where/what it is connecting to, along with notes for things to remember.
I need to test the Input and Output of each pin, so I connect the digital pins together :
6 - 7
5 - 8
4 - 9
3 - 10
2 - 11
0 & 1 are not connected as they are used for uploading the sketch.
A0 goes to a GREEN LED (Test Passed)
A1 goes to a RED LED (Test Failed)
5V goes to a RED LED (Power)
3.3V goes to a YELLOW LED (3.3V Power)
All LEDs have a 330 Ohm Resistor in Series.
Step 2: Wire It Up
Wiring up the test shield, I used our breadboard shield : https://proto-pic.co.uk/breadboard-shield-for-ard... with header pins. After soldering the header pins into place I used jumper wires to jump between the pairs of pins, and soldered the Resistors & LEDs in place, then it was time to test the board.
This was tested with a multi-meter, testing from the pin that should be connected, and the pins to either side, this tested for continuity and for shorts with neighboring pins. And also used a 5V Power supply to test the LEDs. This is all tested with the shield unmounted.
Step 3: Firmware
The firmware was designed to set a pin under test as an INPUT, with its partner as an OUTPUT & HIGH, then check the input pin to see if it read the high voltage. If the voltage is read correctly, then the pin passes and a counter is incremented. We test the 3.3V, using an analog input connected to it - we allow a pass between 3.2V and 3.4V.
The pseudo code is :
set Counter to 0
Is pin 16 reading high? (Yes) - do Blink (Saves uploading multiple pieces of code)
Output a welcome message through SERIAL
Turn on Pass & Fail LEDs for 1/2 Second and turn Off (So we can see they work)
Set pins 2 - 6 as Input
Set pins 7 - 11 as OUTPUT, and set them HIGH
Read pins 2 - 6, and increment Counter and output pin number to SERIAL if HIGH
Set 7 - 12 LOW and INPUT
Set 2 - 6 & 17 (A3) as OUTPUT & set them HIGH
Read pins 7 - 12 and increment Counter and output pin number to SERIAL if HIGH
Read Analog 2 and covert it to a voltage
if the number of pins that read HIGH are 11 and voltage is between 3.2V and 3.4V then pass
if not then fail
on pass we light the GREEN pass LED
on fail we flash the RED fail LED
This shield has been updated so the pairs of IO pins are connected by 10K resistors. This is to prevent a dead short if the test shield is mounted to an Arduino with the specific pair of pins both set as OUTPUT, with one HIGH and one LOW.