Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 18 of 18

Thread: Teensy 4.1 to MagJack wiring schematic (wanted)

  1. #1
    Junior Member
    Join Date
    Jun 2020
    Posts
    6

    Teensy 4.1 to MagJack wiring schematic (wanted)

    Hi, I just got my DigiKey parts for the ethernet dongle for my Teensy 4.1... but haven't received my OSHPark order yet.

    I wanted to wire up the jack to the cable, but I'm not clear on the connections needed. I searched and searched, but didn't find this clearly defined anywhere, and will need to resort to using GIMP on the few OSHpark images, as well as the MagJack pinout (which uses a different naming convention).

    If there's someone that can quickly provide an existing schematic for my needs, it would save me some time.

    Thanks,
    -Nathan


    Top of PCB view
    https://www.pjrc.com/teensy/beta/k41..._placement.png
    https://644db4de3505c40a0444-327723b...2d913aa1e4.png

    Bottom of PCB view:
    https://644db4de3505c40a0444-327723b...b7fe68119a.png

    Recommended MagJack (RB1-125BAG1A) data sheet:
    https://media.digikey.com/pdf/Data%2...rovalSheet.pdf
    Last edited by nmz787; 06-22-2020 at 09:30 PM. Reason: added links to pics and PDF

  2. #2
    Junior Member
    Join Date
    Jun 2020
    Posts
    6
    Here's what I came up with... please correct me if I've miswired somethingClick image for larger version. 

Name:	ethernet_cable.jpg 
Views:	32 
Size:	140.6 KB 
ID:	20679

  3. #3
    Senior Member
    Join Date
    Mar 2016
    Posts
    123
    Here's the schematic from my CNC Breakout board. The 6 pin header on the left is on the T4.1. The magjack pinout is from the datasheet.

    Click image for larger version. 

Name:	ethernet.png 
Views:	14 
Size:	11.4 KB 
ID:	20681

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,082
    That looks good.

    While probably not strictly necessary, you should probably also connect the connector shield to GND, so that 1000 pF capacitor inside the connector gets connected to GND.

  5. #5
    Junior Member
    Join Date
    Jun 2020
    Posts
    6
    Thanks for the confirmations, and the recommendation on adding another GND connection.
    I got the "web server" demo running after downloading the FNET and NativeEthernet libs by vjmuzik, and swapping the
    Code:
    #include <Ethernet.h>
    line to
    Code:
    #include <NativeEthernet.h>
    . As well as adding the code to grab the Teensy's fused MAC:
    Code:
    /*
      Web Server
     
     A simple web server that shows the value of the analog input pins.
     using an Arduino Wiznet Ethernet shield. 
     
     Circuit:
     * Ethernet shield attached to pins 10, 11, 12, 13
     * Analog inputs attached to pins A0 through A5 (optional)
     
     created 18 Dec 2009
     by David A. Mellis
     modified 9 Apr 2012
     by Tom Igoe
     
     */
    
    
    #include <NativeEthernet.h>
    
    // Enter a MAC address and IP address for your controller below.
    // The IP address will be dependent on your local network:
    //byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
    uint8_t mac[6];
    IPAddress ip(192,168,1,177);
    
    // Initialize the Ethernet server library
    // with the IP address and port you want to use 
    // (port 80 is default for HTTP):
    EthernetServer server(80);
    
    
    static void teensyMAC(uint8_t *mac) {
      uint32_t m1 = HW_OCOTP_MAC1;
      uint32_t m2 = HW_OCOTP_MAC0;
      mac[0] = m1 >> 8;
      mac[1] = m1 >> 0;
      mac[2] = m2 >> 24;
      mac[3] = m2 >> 16;
      mac[4] = m2 >> 8;
      mac[5] = m2 >> 0;
    }
    
    
    void setup() {
      // Open serial communications and wait for port to open:
      Serial.begin(9600);
       while (!Serial) {
        ; // wait for serial port to connect. Needed for Leonardo only
      }
      Serial.println("About to start Ethernet, apparently the cable needs plugged in before it will proceed!");
      teensyMAC(mac);
      static char teensyMacString[23];
      sprintf(teensyMacString, "MAC: %02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
      Serial.println(teensyMacString);
      
      // start the Ethernet connection and the server:
      Ethernet.begin(mac, ip);
      server.begin();
      Serial.print("server is at ");
      Serial.println(Ethernet.localIP());
    }
    
    
    void loop() {
      // listen for incoming clients
      EthernetClient client = server.available();
      if (client) {
        Serial.println("new client");
        // an http request ends with a blank line
        boolean currentLineIsBlank = true;
        while (client.connected()) {
          if (client.available()) {
            char c = client.read();
            Serial.write(c);
            // if you've gotten to the end of the line (received a newline
            // character) and the line is blank, the http request has ended,
            // so you can send a reply
            if (c == '\n' && currentLineIsBlank) {
              // send a standard http response header
              client.println("HTTP/1.1 200 OK");
              client.println("Content-Type: text/html");
              client.println("Connection: close");
              client.println();
              client.println("<!DOCTYPE HTML>");
              client.println("<html>");
              // add a meta refresh tag, so the browser pulls again every 5 seconds:
              client.println("<meta http-equiv=\"refresh\" content=\"5\">");
              // output the value of each analog input pin
              for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
                int sensorReading = analogRead(analogChannel);
                client.print("analog input ");
                client.print(analogChannel);
                client.print(" is ");
                client.print(sensorReading);
                client.println("<br />");       
              }
              client.println("</html>");
              break;
            }
            if (c == '\n') {
              // you're starting a new line
              currentLineIsBlank = true;
            } 
            else if (c != '\r') {
              // you've gotten a character on the current line
              currentLineIsBlank = false;
            }
          }
        }
        // give the web browser time to receive the data
        delay(1);
        // close the connection:
        client.stop();
        Serial.println("client disonnected");
      }
    }

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,082

  7. #7
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,082
    The ethernet kit is now available.

    https://www.pjrc.com/store/ethernet_kit.html

  8. #8
    Awesome! Thanks!
    Just noticed 2 small text errors on the MagJack page.
    Click image for larger version. 

Name:	Untitled.png 
Views:	14 
Size:	373.7 KB 
ID:	20727
    Click image for larger version. 

Name:	Untitled1.png 
Views:	9 
Size:	219.4 KB 
ID:	20728
    Last edited by guzu; 06-25-2020 at 01:59 PM. Reason: Added another image.

  9. #9
    Junior Member
    Join Date
    Jun 2020
    Posts
    1
    Thank you! Saved me a bunch of time.

    My application requires 100FX (LC Fiber) and I have a Cu-Fiber media converter, but it would be nice if I could interface a Fiber transceiver directly to the PHY. I've been looking into this, and it seems like it should work, but the PHY datasheet makes me wonder if the PHY would reject the transceiver due to it's built-in diagnostics. The transceiver I have is the Avago HFBR-5961ALZ, but I would also like to interface an SFP transceiver, if possible. Can it work?

  10. #10
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,743
    Great, I was just going to ask when the kit would be available. Soldering a through hole capacitor is easier than SMT.

    I assume the resistors listed in the original OSH park board aren't needed?

    I personally will be soldering in the longer headers so that I can use my normal stacking headers for the normal outer row pins:


    But it is good to have everything together as a kit. When I'm buying parts at digikey or mouser, I always wonder if I got the right resistor or capacitor, particularly getting the right sized versions that can be soldered in.
    Last edited by MichaelMeissner; 06-25-2020 at 07:37 PM.

  11. #11
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,082
    Quote Originally Posted by MichaelMeissner View Post
    I assume the resistors listed in the original OSH park board aren't needed?
    Those other parts aren't needed.

    For the final kit I tried to keep it as simple and affordable as possible.

  12. #12
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,743
    Quote Originally Posted by PaulStoffregen View Post
    Those other parts aren't needed.

    For the final kit I tried to keep it as simple and affordable as possible.
    Great! Note in the Teensy 4.1 page, you have the link for the ethernet kit up top, but if you scroll down to the ethernet section, it only says the kit will be offered in the future.

    As I understand it, the native ethernet support is not (yet) in 1.53. You might want to add a link for the library until it makes it into an official release.

  13. #13
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    11,764
    Quote Originally Posted by PaulStoffregen View Post
    The ethernet kit is now available.

    https://www.pjrc.com/store/ethernet_kit.html
    Kit and price looks great ... but OSH and Digikey already sent the parts for SMD assembly

  14. #14
    Senior Member
    Join Date
    Mar 2016
    Posts
    123
    That looks like a very good deal. I expect a lot of people will get one.

    I have a question about the MagJack in the kit. It is a different part number from the one specified in the OSHPark version. Are they not interchangeable?

  15. #15
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,082
    Quote Originally Posted by PhilB View Post
    I have a question about the MagJack in the kit. It is a different part number from the one specified in the OSHPark version.
    There are 2 designed shared on OSH Park, each with a different magjack.

    Newer version:
    https://oshpark.com/shared_projects/wUFt1emZ

    Old version:
    https://oshpark.com/shared_projects/5epewE3O


    Are they not interchangeable?
    Sadly, no, these 2 magjacks have different pinouts, even though functionally they are equivalent. That's why a new PCB design was needed.

    I was about to find a vendor with a really good 1000 qty price on the Cetus part. Had we stayed with RB1-125BAG1A, the kit would have come in with a retail price around $5. I wanted to keep the kit affordable and also all simpler through hole soldering, so we delayed the kit by a few weeks and a 2nd board was designed.

  16. #16
    Senior Member
    Join Date
    Apr 2013
    Posts
    151
    Quote Originally Posted by PaulStoffregen View Post
    The ethernet kit is now available.

    https://www.pjrc.com/store/ethernet_kit.html
    Any idea when it will arrive on the reseller, specially europa/germany

  17. #17
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,082
    Quote Originally Posted by Markus_L811 View Post
    Any idea when it will arrive on the reseller, specially europa/germany
    We're hoping EXP Tech will carry them in a couple weeks.

  18. #18
    Senior Member
    Join Date
    Apr 2013
    Posts
    151
    Quote Originally Posted by PaulStoffregen View Post
    We're hoping EXP Tech will carry them in a couple weeks.
    Sounds good, thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •