Tuesday, February 23, 2016

Using Arduino to Test Network Cables.

Using 2 network connectors that normally snap into wall plates and accept network cables I built a network cable tester using an Arduino Pro Mini, a breadboard, a couple of inches of network cable and 8 1M Ohm resistors. The code I used is at the end of the page.  And off course, if you wire things differently, your pinout order might have to change.

I wired up one of the network cable connectors to just turn the data around.  I looked at A mode and just hooked green up to green white, orange up to orange white, blue up to blue white, and brown up to brown white.  The two punch downs on the side closest to where the wire connects just loop around, and the two on the back side connect strait across.

The other end I wired up to the A mode as well, using a 3 inch piece of network cable.  I followed the same color code on this side, the A mode, and matched the color of the cable to the little block of color on the side of the connector to the color of the wire.  I stripped the ends of the wires and pushed them into the breadboard so they lined up with pins 2 through 9.

Then I connected one end of a cable to the turn around plug and the other end into the connector attached to the Arduino.  At this point I thought I was pretty much done.  So I wrote the program and immediately just began to get random data from the pins.  Seems that if they are set to input they will float and hold a voltage like a capacitor for many minutes after they had been charged up. And even waving your hand near them is enough to make them read high. So I had to add 8 high value resistors from each pin to ground to bleed off this voltage, and the once nice and neat breadboard looks very messy.  What I need is a high value resistor pack that will just plug in to all those pins and to ground. This allowed excess voltage to bleed off over about 10 milliseconds time and let me read the voltage correctly.

The code was pretty strait forward.  I just needed to set all the pins into input mode and then one at a time set a pin to output mode HIGH and then read all the other pins to make sure I get a voltage on one and only one pin, and that it is the correct pin.   Then set that pin back to LOW and make it an input again, and select the next pin and do the same thing.  If everything is good, light an LED green.

The Arduino is able to easily perform these checks 4 times a second, giving me the opportunity to move the cables around and see of there are any intermittent contacts on either end or breaks in the wire.

I found the correct pin order by reading a known good cable.  It was an A cable, then I read a B cable and it returned the exact same pin order.  So I thought that a cross over cable must be different, but it returned the exact same pin order as A and B modes.  So that made that easy. Still don't understand why a cross over cable works the same as A and B. I tested it on several cables to make sure the cables I had were correct.

The code is as follows:

//Uncomment the following line to see output on the serial terminal.
//#define SERIALDEBUG 1

int good[8]= { 3, 2, 5, 4, 7, 6, 9, 8};

void setup() {                
  //Serial.println("Checking pins.");
  // initialize the digital pin as an output.
  pinMode(12, OUTPUT);

void loop() {
  int x, y, z;
  // Set all the pins low.
  for (x=2; x<10; x++) {
    digitalWrite(x, LOW); 
    pinMode     (x, INPUT);
  // Go through each pin, one at a time.
  // find where pin was routed to
  for (x=2; x<10; x++) {
    // setup current pin
    pinMode(x, OUTPUT);
    digitalWrite(x, HIGH); 

    // Find matching pin.
    for (y=2; y<10; y++) {

       if (x==y) continue;
       if (digitalRead(y) == HIGH) {
         if (good[x-2] == y)
#ifdef SERIALDEBUG            
         Serial.print("good ");
         Serial.print(" Z ");
         Serial.print(" Pin ");
         Serial.print(" is wired to pin ");
    // Set current pin back to the rest
    digitalWrite(x, LOW);
    pinMode     (x, INPUT);
  if (z == 8)
      digitalWrite(12, HIGH);
    digitalWrite(12, LOW);


Rasberry PI cluster in a Stackable Tube.

update 12 June 2017 I am finally building it!
Check out the thingiverse page:
Getting down a bunch of ideas I have been having about building a raspberry pi cluster. I got this idea from reading how cray computers used to be built in a circle to reduce the length of the wires that connected the individual computers together. Evidently this resulted in significant measurable speed ups in message passing latency.

Picture 12 raspberry pi computers in a circle with their GPIO pins on the inside, their hdmi slots facing out, and their memory cards facing up. very short wires from each board going to every other board. Serial networking protocols running on those serial TTL connections, eliminating the need for more hardware and reducing latency to very small values.   Disadvantage would be low bandwidth on any one network segment.

One of the Pi computers acts as the master and connects to local network with a standard network cable and routes to the rest of the computer
s in the cluster.  Alternatively you could run network connections to every computer and use this for high latency, high bandwidth data.

Doing the low latency network connections would speed up the cluster if it was processing many tiny messages that need processed as quickly as possible, such as financial data, or medical HL7 events.

A single brick power supply sends power directly into the GPIO of each board, bypassing all the safety measures on the boards, so the power supply would have to be a good one. This eliminates the need for running a usb cable to each individual board for power.

Right now I am working on printing out tube segments that will fit on top of each other and hold the PIs. These tubes would be passively cooled, the tube acting like a chimney. So it would have to be on a base that allowed air flow from underneath. But also design them to be stacked with a connecting segment on each one with the middle clear so you can drop power and network cables down the middle. This connecting segment would pull in air from the front, let it go up the tube above it, while letting the air from the tube below it go behind the stack of tubes. If need be a small fan on the back of each stacking segment could pull air up through each segment.

Alternatively the tubes could stack on top of each other and a single 120mm fan on the bottom rapidly blows air up through all the tubes.

A topper segment neatly closes the top off from view, while allowing air to blow up easily. The base could accept legs or screw down to a board for better stability. Or the whole thing could hang from a ceiling beam.

With Pi Zeros the cluster would only draw about 7 watts max. With Raspi 2s it could draw up to 25 watts and be 3 times more expensive, but it would be almost an order of magnitude more capable. Power data comes from here. Nodes can power down unused parts of their board for more savings.

A clear plastic tube over them proudly showing the details and directing cooling air flow. This could be done by cutting the tubing and pressure fitting them into 3D printed fixtures at the top and bottom. A 3D printed frame fits into the clear tube and the tube goes into rings top and bottom to make it look finished.