how to detect short/open network cable?

Discussion in 'Embedded Systems and Microcontrollers' started by speed1, May 5, 2012.

  1. speed1

    Thread Starter New Member

    Mar 9, 2012
    16
    0
    Hi all,
    I'm working for a graduation project as a computer Engineer.
    My project is to make a LCD network cable tester, I have done with the simple simulation to test the cable wither it is OK or not.

    the project construct of two parts:

    first (main part): micro controller PIC16F877 with LCD & RJ-45 socket
    second: a RJ-45 socket

    the idea is to send data from PIC to first cable (pin0) and receive it throw (pin1).

    But the problem is how to detect the fault (short/open) if it does on the LCD?

    Thank you all
    Haridi
     
  2. BillO

    Well-Known Member

    Nov 24, 2008
    985
    136
    I'm a little surprised at your request. If you have made it to the point where you are about to graduate as an engineer, I am in disbelief that you cannot at least make an attempt at this. This is not that tough, especially for someone that should be educated enough to be called an engineer.

    Can you at least take a stab at it and post your best guess here so we can help you with the details?

    On the other hand, send me $10,000 and I'll write your final project for you.:D
     
  3. speed1

    Thread Starter New Member

    Mar 9, 2012
    16
    0
    Thank you BillO :D no I will not pay you 10000 $ :p

    this what i have done :)
    [​IMG]


    Now with this I can check the cable if it is ok or not, but I don't know if there is a problem in the cable or not

    the design is work like you are sending '1' throw pin0 and the socket must connect next wire, so micro controller must receive '1' throw pin1 if the cable is working properly, but if there is a short circuit between wire 1 & 2 it also will receive the same value and this seems the cable is ok for micro controller but in fact it is a short circuit.

    NOTE: in the simulation I use a 8 - LINE connector because i did not found the RJ-45 socket.
     
  4. BillO

    Well-Known Member

    Nov 24, 2008
    985
    136
    Okay, I'll work cheaper.

    It actually seems like you have the right idea.

    Tell me something, are you restricted to just 1 RJ45, or can you use 2 of them? I think you need 2 anyway.

    There is lots of I/O on the 877, so why not have 2 RJ45 connected to it. That way you can set it up so that:

    Code ( (Unknown Language)):
    1.  
    2. RJ45 'A'             RJ45 'B'
    3.   RB0 ---------------- RD0
    4.   RB1 ---------------- RD1
    5.   RB2 ---------------- RD2
    6.   RB3 ---------------- RD3
    7.   RB4 ---------------- RD4
    8.   RB5 ---------------- RD5
    9.   RB6 ---------------- RD6
    10.   RB7 ---------------- RD7
    11.  
    Then assert RB0 through RB7 high, one at a time. As you assert each one, check all of the port D pins.

    So, make RB0 an output and set it high and all other pins on port B inputs, then check RDO to RD7. Only RD0 should be high. If any other pin on port D is high, then you have a short to that line. If RD0 is not high, then that line is open.

    Next , make RB1 an output and set it high and all other pins on port B inputs, then check RDO to RD7. Only RD1 should be high. If any other pin on port D is high, then you have a short to that line. If RD1 is not high, then that line is open.

    And repeat for all pins on port B.
     
    speed1 likes this.
  5. speed1

    Thread Starter New Member

    Mar 9, 2012
    16
    0
    I'm very thankful to you Billo You colored my life and my project :D
    I want just to ask do yo mean by RJ45 'B' the same microcontroller ?
    because I'm using only one microcontroller, Today my project advisor advise me to use a DIP switch and he told me to make micro controller receive the signal comming from DIP switch.

    and regarding the RJ45 socket, yes I'm using two socket (one will be connected to micro controller and the othere will be to another part of the cable.)
     
  6. chrisw1990

    Active Member

    Oct 22, 2011
    543
    41
    hes saying, loop the cable, have one connector.. your RJ45 'A' driving the cable, with your other RJ45 'B' connector receiving, therefore if RJ45 'A' pin 1 is '1' and RJ45'B' pin 6 (?) is 0, theres a break in the cable..
     
  7. BillO

    Well-Known Member

    Nov 24, 2008
    985
    136
    Yes, I am saying put both RJ45s on the same controller. I was saying put one an port B the other on Port D. But I see you are using port B for the LCD and port C for RJ45 'A'. Now just connect RJ45 'B' to port D. This way the microcontroller can handle everything. No dip switches required. You should be able to test the cable in a few milliseconds.
     
  8. strantor

    AAC Fanatic!

    Oct 3, 2010
    4,302
    1,988
    It hasn't been explicitly stated, but I'm getting a feeling that the assignment doesn't allow for the cable to be looped back. Picture an ethernet cable routed through conduit & walls & crawlspaces from one end of a building to the other.

    So what I would do, is solder a ladder of resistors into your RJ45 connector and plug that onto the end of the cable. Apply voltage across the ladder and you should get incrementally less voltage on each return wire. If you have any shorts or opens, it throws off the return voltages and you should register a fault.

    [​IMG]
     
    speed1 likes this.
  9. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,648
    764
    Isn't TDR of any use here?
     
    speed1 likes this.
  10. strantor

    AAC Fanatic!

    Oct 3, 2010
    4,302
    1,988
    Porbably a little overcomplicated for this project. I think he only needs to detect opens and shorts.
     
  11. speed1

    Thread Starter New Member

    Mar 9, 2012
    16
    0
    Yes you are totally correct strantor, this is really what i was try to explain. I want my cable tester to test cables that are connected throw walls from floor to another (as example).

    Billo thanks you my friend for your valuable effort and help.
     
  12. speed1

    Thread Starter New Member

    Mar 9, 2012
    16
    0
    Yes my friend atferrari
    I will use TDR to measure the length of the cable ( so if there is any problem in the testing process techniques can know the length of the cable to replace it). but this feature I will added to the next step of my project.

    Thank you all my dears, I'm very thankful for all your help and support :)
     
  13. speed1

    Thread Starter New Member

    Mar 9, 2012
    16
    0
    Hi strantor,
    Regarding ladder resistor, do i have to use ADC (I'm using pic 16F877) it has only one ADC (10 bit).

    Thank you.

     
  14. speed1

    Thread Starter New Member

    Mar 9, 2012
    16
    0
    Hi guys :D

    I have did the project for detecting short wires and it's work (put if 2 wire are shorted and they are not next to each other it display all the between wires)
    for example: 1 2 3 4 5 6 7 8
    if wire 2 & 4 are shorted >> it show that (2,3),(2,4) and (3,4) are shorted !!!!

    I still have some issues for detecting open wires i don't know how to do it !!!

    this is photo of shorted wires (2,4)

    [​IMG]

    And this is my code

    Code ( (Unknown Language)):
    1. void main() {
    2.     unsigned char i,j,o,shortI[1],shortJ[1];
    3.     double vi,vj,v0,v7,vo;
    4.  
    5.     LCD_init();
    6.     LCD_cmd(_LCD_CLEAR);
    7.     LCD_cmd(_LCD_cursor_off);
    8.  
    9.    
    10.     TRISB=0;
    11.     portB=0;
    12.    
    13.  
    14.  
    15.     while(1)
    16.     {
    17.  
    18.    
    19.        TRISA = 0xFF;              //port A is input
    20.        TRISE = 0xFF;              //port E is input
    21.        
    22.          for(i=0; i<8; i++)
    23.        {
    24.         vi=adc_read(i);
    25.         for(j=i+1; j<8; j++)
    26.         {
    27.  
    28.           vj=adc_read(j);
    29.            
    30.           LCD_cmd(_LCD_CLEAR);
    31.          
    32.            v0=adc_read(0);      // to read AN0
    33.  
    34.            v7=adc_read(7);      // to read AN7
    35.            
    36.  
    37.            
    38.            
    39.           if(((vi-vj)*0.71428)<0.2 && (v0!=0) && (v7==0) )
    40.           {
    41.          
    42.  
    43.            
    44.            
    45.           LCD_out(1,1,"Short at: ");
    46.           ShortI[0]=i+48;
    47.           LCD_out(1,11,shortI);
    48.           LCD_out(1,12,"&");
    49.           ShortJ[0]=j+48;
    50.           LCD_out(1,13,shortJ);
    51.           LCD_out(1,14,"    ");
    52.           delay_ms(500);
    53.           }
    54.  
    55.           }
    56.           }
    57.            for(o=0; o<7; o++)       // cheeck for open wires
    58.            {
    59.                    vo=adc_read(o);
    60.                    if(vo == 0 )
    61.                    LCD_OUT(1,1,"open");
    62.            }
    63.        
    64.         }
    any idea will be helpful, thanks for all :)
     
  15. speed1

    Thread Starter New Member

    Mar 9, 2012
    16
    0
    sorry I forget to mention one thing
    I use in my if statment <0.2

    if(((vi-vj)*0.71428)<0.2 && (v0!=0) && (v7==0) )

    and that is in case the cable was very long as 100m, some of the voltage will be drooped because of wire resistance, so it will not be exactly equals.
     
  16. strantor

    AAC Fanatic!

    Oct 3, 2010
    4,302
    1,988
    That should not matter. All the wires are the same length, so assumed the same resistance, so it should work the same whether using wires 1cm or 1KM.
     
  17. speed1

    Thread Starter New Member

    Mar 9, 2012
    16
    0
    .

    and what about open wires, i think it will be different because position of open is important and will change the resistance.
     
  18. strantor

    AAC Fanatic!

    Oct 3, 2010
    4,302
    1,988
    If there is an open, you won't get any voltage back on the effected conductor. and how would the position of the open change voltage on the other conductors??:confused:
     
  19. speed1

    Thread Starter New Member

    Mar 9, 2012
    16
    0
    that's right :)
    I wrote this code and it's worked :D
    I'm still trying write code to check for right wires map
    as we know pairs must be connected as following pairs
    (1,2)(3,6)(4,5)(7,8)


    Code ( (Unknown Language)):
    1. void main() {
    2.     unsigned char i,j,o,shortI[1],shortJ[1],openz[1];
    3.     unsigned int z,k;
    4.     double vi,vj,v0,v7;
    5.  
    6.     LCD_init();
    7.     LCD_cmd(_LCD_CLEAR);
    8.     LCD_cmd(_LCD_cursor_off);
    9.  
    10.    
    11.     TRISB=0;
    12.     portB=0;
    13.    
    14.  
    15.  
    16.     while(1)
    17.     {
    18.  
    19.    
    20.        TRISA = 0xFF;              //port A is input
    21.        TRISE = 0xFF;              //port E is input
    22.        
    23.         for(z=0; z<7; z++)
    24.         {
    25.          vi=adc_read(z);
    26.          if((vi*0.71428)<=0.1)
    27.          {
    28.          LCD_OUT(1,1,"open");
    29.          openz[0]=z+48;
    30.           LCD_out(1,6,openz);
    31.          delay_ms(500);
    32.          }
    33.          
    34.         }
    35.          for(i=0; i<8; i++)
    36.        {
    37.         vi=adc_read(i);
    38.  
    39.         for(j=i+1; j<8; j++)
    40.         {
    41.  
    42.           vj=adc_read(j);
    43.            
    44.           LCD_cmd(_LCD_CLEAR);
    45.          
    46.            v0=adc_read(0);      // to read AN0
    47.  
    48.            v7=adc_read(7);      // to read AN7
    49.            
    50.            
    51.           if(((vi-vj)*0.71428)<0.2 && (v0!=0) && (v7==0) )
    52.           {
    53.            
    54.            
    55.           LCD_out(1,1,"Short at: ");
    56.           ShortI[0]=i+48;
    57.           LCD_out(1,11,shortI);
    58.           LCD_out(1,12,"&");
    59.           ShortJ[0]=j+48;
    60.           LCD_out(1,13,shortJ);
    61.           LCD_out(1,14,"    ");
    62.           delay_ms(500);
    63.           }
    64.  
    65.           }
    66.           }
    67.          
    68.                for(k=0;k<4;k++)   // check for wire map
    69.                {
    70.                 for(z=0;z<8;z++)
    71.                 {
    72.                
    73.                 TRISA=0b100010;
    74.                 TRISE=0b101;
    75.                
    76.  
    77.                 if(porta.f1 == 1)
    78.                 LCD_OUT(1,1,"wire match");
    79.                 }
    80.                }
    81.  
    82.  
    83.         }
    and here the protus simulation & code
    http://dl.dropbox.com/u/24354621/Ladder serister design-21-5.rar
     
Loading...