Mturk Jobs

Mturk Jobs
Mturk Jobs

Tank

Saturday, April 7, 2018

How to make an Arduino Based Ethernet Cable Tester?

Who didn't use Ethernet RJ45 cables and had to test them at some point of time?



Have you ever dreamed of building your own cable tester?

I remember seeing a network cable tester and I felt that I've seen a piece of super technology. I felt like there must be another civilization that has built such device.

In fact this network cable tester has been my first motive for learning embedded systems programming.

I wanted to build my own cable tester. And I actually started using different hardware and approaches. I'll show you them later on this blog.

But today let me show you this Arduino based network cable tester.

As you know that Arduino has made embedded systems a very easy and popular subject since it has been launched back in 2005.

Here is how to make an Arduino Based Ethernet Cable Tester?

Project idea is very simple. You test one pin on one cable terminal against all pins on the other terminal. Then you repeat this process on all pins sequentially.

The circuit uses Serial to Parallel shift register to increase Arduino inputs and outputs.




Code


//Librerie


 #include 

// inizializzo e assegno porte LCD

LiquidCrystal lcd( 4, 5, 6, 7, 8, 9);

// abilito pin per pilotare IC74HC595

int latchPin = 12;  

int clockPin = 11;  

int dataPin = 13; 

byte pinOut = 0;    // da modificare

int uscita = 0;  // da modificare

int Lo1 = 0;

int Lo2 = 0;

int Lo3 = 0;

int Lo4 = 0;

int Lo5 = 0;

int Lo6 = 0;

int Lo7 = 0;

int Lo8 = 0;

int cavo = 0;

int eth1 = 0;

int eth2 = 0;

int eth3 = 0;

int eth4 = 0;

int eth5 = 0;

int eth6 = 0;

int eth7 = 0;

int eth8 = 0;

int testeth1 = 0;

int verifi1 = 0;


 
 //Assegno variabili alle porte

int ethIn1 = 14;

int ethIn2 = 15;

int ethIn3 = 16;

int ethIn4 = 17;

int ethIn5 = 18;

int ethIn6 = 19;

int ethIn7 = 2;

int ethIn8 = 3;


 
 void setup() {

    lcd.begin(16,2);

    lcd.setCursor(0,0);

    lcd.print("Progetto Tester");

    lcd.setCursor(4,1);

    lcd.print("Ethernet");

    delay(3000);

    lcd.clear();

    Serial.begin(9600);

  

  //configuro uscita IC

    pinMode(latchPin, OUTPUT);

    pinMode(dataPin, OUTPUT);

    pinMode(clockPin, OUTPUT);


     pinOut = 0;


   //Assegno gli stati alle porte


  pinMode(ethIn1, INPUT);

  pinMode(ethIn2, INPUT);

  pinMode(ethIn3, INPUT);

  pinMode(ethIn4, INPUT);

  pinMode(ethIn5, INPUT);

  pinMode(ethIn6, INPUT);

  pinMode(ethIn7, INPUT);

  pinMode(ethIn8, INPUT);

  


 }


 void loop() {


    Serial.print("---------------INIZIO----------------"); 

    cavo = 0;

    Lo1 = 0;

    Lo2 = 0;

    Lo3 = 0;

    Lo4 = 0;

    Lo5 = 0;

    Lo6 = 0;

    Lo7 = 0;

    Lo8 = 0;

    lcd.clear();

    lcd.print("Processo: ");

    lcd.setCursor(0,1);

    //inserisco ciclo

    for (int uscita=0; uscita<= 7; uscita++){

       

    Serial.println();

    Serial.print("Pin uscita: ");

    Serial.print(uscita);

    

    //lcd.begin(16, 2);

    lcd.print(uscita + 1);

    pinOut = 0;


    bitSet(pinOut, uscita);

    digitalWrite(latchPin, LOW);

    shiftOut(dataPin, clockPin, LSBFIRST, pinOut);

    digitalWrite(latchPin, HIGH);

    


   //leggo stato entrata ethIn1

  int eth1 = digitalRead(ethIn1);

  int eth2 = digitalRead(ethIn2);

  int eth3 = digitalRead(ethIn3);

  int eth4 = digitalRead(ethIn4);

  int eth5 = digitalRead(ethIn5);

  int eth6 = digitalRead(ethIn6);

  int eth7 = digitalRead(ethIn7);

  int eth8 = digitalRead(ethIn8);

  int testeth1 = analogRead(ethIn1);

  

    //inserisco verifica


     if (uscita == 0 && eth1 == 1)

    {

      Lo1 = 1;

    }

    else

    {

      if (uscita == 0 && eth3 == 1) // se incrociato cambia valore

      {Lo1 = 256 ;

      }

    }

       

        

        if (uscita == 1 && eth2 == 1)

    {

      Lo2 = 2 ;

    }

    else

    {

            if (uscita == 1 && eth6 == 1) // se incrociato cambia valore

      {Lo2 = 512 ;

      }

    }

      

      

      if (uscita == 2 && eth3 == 1)

    {

      Lo3 = 4 ;

    }

    else

    {

            if (uscita == 2 && eth1 == 1) // se incrociato cambia valore

      {Lo4 = 1024 ;

      }

    }

        

        

        if (uscita == 3 && eth4 == 1)

    {

      Lo4 = 8 ;

    }

    else

    {

      

    }

        

        

        if (uscita == 4 && eth5 == 1)

    {

      Lo5 = 16; 

    }

    else

    {

      

    }

        

        

        if (uscita == 5 && eth6 == 1)

    {

      Lo6 = 32; 

    }

    else

    {

            if (uscita == 5 && eth2 == 1) // se incrociato cambia valore

      {Lo6 = 2024 ;

      }

    }

      

      

      if (uscita == 6 && eth7 == 1)

    {

      Lo7 = 64; 

    }

    else

    {

      

    }

        

        

        if (uscita == 7 && eth8 == 1)

    {

      Lo8 = 128; 

    }

    else

    {

      

    }

      Serial.println();

      Serial.print("Stato lettura porte: ");

      Serial.print(eth1);    

      Serial.print(eth2);   

      Serial.print(eth3);

      Serial.print(eth4);

      Serial.print(eth5);

      Serial.print(eth6);

      Serial.print(eth7);

      Serial.print(eth8);

      

      

      cavo = Lo1 + Lo2 + Lo3 + Lo4 + Lo5 + Lo6 + Lo7 + Lo8 ;

      Serial.println();

      Serial.print("Somma valori riscontrati: ");

      Serial.print(cavo);

   }

      

      

      

    

      

      

      if ( cavo == 255 )

      {

        lcd.clear();

        lcd.print("cavo dritto   ok");

        delay(2000);

        

      }

        else

    {

            if (cavo == 3008 )

              {

               lcd.clear();

                lcd.print("cavo inc.  ok");

                delay(2000);

              }

              else

              {

              lcd.clear();

              lcd.print("Cavo diverso");

              lcd.setCursor(0,1);

              lcd.print("o difettoso");

              

              delay(1000);

              lcd.clear();

              if ( cavo == 2496 )

              {

                lcd.print("Pin 2 / 6 ");

                delay(2000);

              }

              else

              {

                  

              }


               }

              }

              // insserisco sistema verifica pin per eventuale errore

              //inserisco ciclo


               

              lcd.print("Inizio verifica");

              delay(1000);

              lcd.clear();

              lcd.print("out: ");

              lcd.setCursor(0,1);

              lcd.print("in : ");

             uscita = 0;

    for (int uscita=0; uscita<= 7; uscita++){

    delay(250);

   

    

    pinOut = 0;

    bitSet(pinOut, uscita);

    digitalWrite(latchPin, LOW);

    shiftOut(dataPin, clockPin, LSBFIRST, pinOut);

    digitalWrite(latchPin, HIGH);

  //leggo stato entrata ethIn1

  int eth1 = digitalRead(ethIn1);

  int eth2 = digitalRead(ethIn2);

  int eth3 = digitalRead(ethIn3);

  int eth4 = digitalRead(ethIn4);

  int eth5 = digitalRead(ethIn5);

  int eth6 = digitalRead(ethIn6);

  int eth7 = digitalRead(ethIn7);

  int eth8 = digitalRead(ethIn8);


   //invio info al seriale stato porte

        Serial.println();

      Serial.print("Stato lettura porte verifica finale: ");

      Serial.print(eth1);    

      Serial.print(eth2);   

      Serial.print(eth3);

      Serial.print(eth4);

      Serial.print(eth5);

      Serial.print(eth6);

      Serial.print(eth7);

      Serial.print(eth8);

  

    //inserisco verifica porta1


     if (eth1 == 1)

    {

      verifi1 = 1;

    }

    else

    {

          if (eth2 == 1) 

          {verifi1 = 2;

          }

          else

          {

              if (eth3 == 1) 

              {verifi1 = 3;

              }

              else

              {

                  if (eth4 == 1) 

                   {verifi1 = 4;

                   }

                   else

                   {

                        if (eth5 == 1) 

                        {verifi1 = 5;

                        }

                        else

                        {

                            if (eth6 == 1) 

                            {verifi1 = 6;

                             }

                             else

                             {

                                  if (eth7 == 1) 

                                   {verifi1 = 7;

                                   }

                                   else

                                   {

                                        if (eth8 == 1) 

                                        {verifi1 = 8;

                                        }

                                        else

                                        {

                                        }

                                    }

                               }

                           }

                       }

                     }

                   }                               

                  }

       

              

              

              //lcd.print("Errore: ");

              

              lcd.setCursor(uscita+5,0);

              

              lcd.print(uscita+1);

              lcd.setCursor(uscita+5,1);

              

              lcd.print(verifi1);

              //delay(250);

              verifi1 = 0;

              //fine verifica errori

              }

               delay(2000);

             // }

              //}

    //}

}













Here is the full project on Arduino Website.









No comments:

Tank