Ethernet board development!!! - Page 1
Forum section: electronics / general

author: pub2024
author_rank: Contributor
timestamp: January 20, 2024, 05:33:00 pm
content: Hi everyone,This is my first post in this forum. Here is my problem: I would like to develop a 10/100 ethernet card with the help of which I can send some output states (ON/OFF) on some pins of microcontrolers (which will actuate some relays). I have a little introduction to Atmel and ARM STM32 microcontrollers and I don't know how I can build such a PCB as simply as possible!!!I was thinking of using an ARM STM32F103 with 48 pins together with a LAN8720A to be able to connect the Rj-45 connector and implicitly the ethernet connection. Do you think I could make this simple ethernet board with this STM32 and LAN8720A? Or would it be even simpler to try with an Atmel microcontroller + LAN8720A? And if so, what type of Atmel microcontroller would you recommend?Of course, any other simpler solution is welcome. I wouldn't necessarily want to use the LAN8720A!!! However, I would like something on Atmel or STM32 microcontrollers!.Please.

author: kripton2035
author_rank: Super Contributor
timestamp: January 20, 2024, 05:42:03 pm
content: some existing (cheap) boards that will ease the process for you ...https://www.olimex.com/Products/IoT/ESP32/ESP32-POE/open-source-hardwarehttps://www.aliexpress.com/item/1005002530007688.html

author: pub2024
author_rank: Contributor
timestamp: January 20, 2024, 06:02:19 pm
content: Thanks for the answer, but could I connect two such cards from your example via ethernet cable and pair them client-server, so that when I give an impulse on an input of one card, the other card responds, on a specific output pin?

author: fchk
author_rank: Frequent Contributor
timestamp: January 20, 2024, 06:07:59 pm
content: The simplest hardware solution would be a PIC18F67J60. This is a 64 pin chip containing 8 bit processor, flash, RAM, UART/I2C, SPI, Ethernet MAC and Ethernet PHY. The only thing you need to add is 3.3V power, 25 MHz crystal, some passives, and a magjack.https://www.microchip.com/en-us/product/pic18f67j60From a software perspective the easiest way is a Wiznet 6100 chip connected via SPI to your preferred microcontroller. This chip has got the basic Internet protocols hardwired, so you don't need any software for this.https://www.wiznet.io/product-item/w6100/STM32F103 is old, and you risk getting fakes. Use something newer and better. STM32F302 for example.https://www.st.com/en/microcontrollers-microprocessors/stm32f302.htmlIf you want Microchip (ex-Atmel), then use the newer AVR128D* instead of the old Atmega series.

author: pub2024
author_rank: Contributor
timestamp: January 20, 2024, 07:16:29 pm
content: Thanks for the reply.I will analyze your solutions.

author: pcprogrammer
author_rank: Super Contributor
timestamp: January 20, 2024, 08:05:05 pm
content: Quote from: pub2024 on January 20, 2024, 05:33:00 pmThis is not going to work. The LAN8720A is a PHY that needs a RMII connection to an ethernet MAC. The STM32F103 does not have this interface.It could be done with a STM32F407 or one of the other STM devices that have an ethernet MAC integrated as peripheral.If it is only about switching some output pins from a server, then a solution with an already mentioned Wiznet chip like the W5500 and an AVR chip like on the Arduino nano can do the trick.I would recommend to first buy a couple of modules and slap them together to get your software working and see if your concept works and then think of designing a PCB for it.Sorry for links to the Dutch Aliexpress site, but the item id will be the same in what ever country/language you need them.For instance a W5500 module example herehttps://nl.aliexpress.com/item/32832354059.htmland a STM32F103 module example herehttps://nl.aliexpress.com/item/1005005764647193.html.Or a LAN8720 module example herehttps://nl.aliexpress.com/item/32485939954.htmland a STM32F407 module example herehttps://nl.aliexpress.com/item/4000602517153.htmlThere are many different solutions of course and my point was to make you aware of looking at the specifications of the devices you are looking at to make sure they match with each other.

author: kripton2035
author_rank: Super Contributor
timestamp: January 20, 2024, 08:21:01 pm
content: Quote from: pub2024 on January 20, 2024, 06:02:19 pmyes you can do that with these cards. you need to program the esp32 one as a client and one as a server. it can be done using arduino ide for these boards.

author: tellurium
author_rank: Frequent Contributor
timestamp: January 20, 2024, 10:09:40 pm
content: A possible solution: (almost) any micro + W5500 (MAC + PHY).Example board: W5500-EVB-Pico, which is RP2040 + W5500https://docs.wiznet.io/Product/iEthernet/W5500/w5500-evb-picoThey share schematic, etc.If you want TCP/IP to fly via your Ethernet connection, you'd better choose a micro with more RAM - and rp2040 there is a good choice for this regard.Another solution is ch32v307, which has MAC + PHY onboard - and it has been discussed on this forum extensively.

author: nctnico
author_rank: Super Contributor
timestamp: January 20, 2024, 10:54:39 pm
content: I second the solution for using a Wiznet chip. The easiest solution by far and nowadays they also have IPv6 versions available.

author: pub2024
author_rank: Contributor
timestamp: January 21, 2024, 07:17:25 pm
content: Thank you all for the answers.I especially appreciate the response of the user @pcprogrammer who said, I quote: "This is not going to work. The LAN8720A is a PHY that needs a RMII connection to an ethernet MAC. The STM32F103 does not have this interface".I will continue to analyze the solutions proposed by you. Thank you very much everyone.

author: tilblackout
author_rank: Contributor
timestamp: January 22, 2024, 03:50:55 am
content: Basically, every product in my company uses Ethernet with RGMII interface. According to my experience, only high-end chips support this interface. For example, chips that support Cortex-A cores and can run Linux such as STM32 MP series, as well as high-end MCU chips such as I.MX RT series from NXP.

author: pcprogrammer
author_rank: Super Contributor
timestamp: January 22, 2024, 07:42:41 am
content: Quote from: tilblackout on January 22, 2024, 03:50:55 amGood for your company, but the OP specifically mentioned 10/100Mbit ethernet, so no need for high end chips that support 1Gbit ethernet. Even a simple AVR with a W5500 can do the trick. There are examples around in the Arduino world where this combination allows controlling pins from another computer. This seems to be all the OP is after.

author: elektryk
author_rank: Regular Contributor
timestamp: January 22, 2024, 09:00:59 am
content: QuoteEasy solution to do that is ENC28J60 with AVR. For toggling some pins 10Mbps should be sufficient.http://tuxgraphics.org/electronics/200905/embedded-tcp-ip-stack.shtml

author: peter-h
author_rank: Super Contributor
timestamp: January 22, 2024, 10:01:07 am
content: The hardware for this is trivial. Just buy some development board which has- an RJ45 connector with integrated magnetics (Hanrun is a big name)- a PHY chip (e.g. LAN8742)- a CPU which can talk to the PHY chip, and has some GPIO pins which can drive whatever...But that is about 1% of the job. The other 99% is software to make it all work. You need a TCP/IP stack on the CPU; I use LWIP which, like most high-profile open source software, does work but needs a lot of, shall we say, "integration work"and there is no support anywhere. Then you need an application running on the CPU which interfaces to the TCP/IP module (with LWIP you can use BSD sockets or Netconn APIs). Then you need to spend months or years googling for patches to make it all reliable. Then to get a properly finished product you need to write a user interface for configuration, via USB (VCP and/or MSC and a config file) or via an HTTP server running on your box. You can find HTTP server code all over the place, most of it horribly bloated; I started with one such and after some weeks binned it and wrote my own very simple HTTP server in a week or two.I've done all this (with a colleague, over past 5 years) and really would not want to do it again, ever. I used a STM32F417 and one could not do it with much less by the time you have a "fully finished" product with the above mentioned user interface etc. If you read the many threads I have started here over the last few years you will get the ideaNow of course it is all "easy", but I am not going to post a useless statement like that hereYes my box does all the above and much more. So if you had a commercial requirement I could easily knock up a daughter board for it (it has an SPI expansion port) with a bunch of MOSFETs or relays. It powers up, gets an IP via DHCP (or fixed IP) and then you could just send it packets. Or you could buy my box (under $200) and design your own expansion board. It also has four serial ports so you could squirt out strings via those.STM have various "DISCO" boards and you can use CUBE IDE to generate most of the code, and it may even more or less work at a basic level. I think most micro vendors do a similar thing. But these are just to get you started - beyond flashing an LED they are hard work.Another much simpler approach which was popular in the early 1990s was to forget TCP/IP and just make a box which receives UDP packets and extracts some bits from them and uses these to drive I/O signals. I used to sell such a thing back then (it was German made). The data was not routable of course, the box had no IP address, just a MAC address which was partly set up on dipswitches. That could probably be done with just the RJ45 and some PHY chip and a simple micro which can talk to the PHY chip using the standard "64 bit UART" interface etc. Or maybe there are PHY chips which are even simpler... This approach might work for you but you could not sell it generally because today everybody wants a TCP/IP product, with all the mod cons like DHCP... it would be a support nightmare because everybody thinks RJ45 = TCP/IP

author: kripton2035
author_rank: Super Contributor
timestamp: January 22, 2024, 11:29:18 am
content: really, using the board(s) I gave you above, and two arduino scripts one for the server, one for the clientthese scripts are in the arduino IDE examplesit is a quite simple task...with other controllers it can be more "professional" but really more difficult to achieve...

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: January 22, 2024, 11:57:27 am
content: +1 for Wiznet W5500 + any cheap MCU (e.g.CH32V003)

author: pub2024
author_rank: Contributor
timestamp: January 22, 2024, 08:39:02 pm
content: Thanks again for the answers.Today a friend brought me a NUCLEO-G474RE board and I would like to know if I can connect another Ethernet board with ENC28J60 to that board

author: bingo600
author_rank: Super Contributor
timestamp: January 22, 2024, 08:47:16 pm
content: Some of the early ENC28J60 boards had a MDIX error, meaning that they couldn't do "Auto crossover".So you had to use a "Crossed ethernet cable".My suggestion would be to connect both boards to an ethernet switch, and let the switch handle the crossover, and speed/duplex negotiation.Then it ought to work./Bingo

author: pub2024
author_rank: Contributor
timestamp: February 03, 2024, 07:08:23 am
content: Quote from: fchk on January 20, 2024, 06:07:59 pmWe are just analyzing a solution with AVR128D* microcontroller, but I can't find a USB programming board for this series of microcontrollers on the net! Can you help me with an example?I have boards for programming the old AVR series, but it is not possible to program the AVR128D series that appeared a few years ago!

author: elektryk
author_rank: Regular Contributor
timestamp: February 03, 2024, 09:48:35 am
content: There are some dev boards for AVR128, for examplehttps://www.microchip.com/en-us/development-tool/dm164151If you need programmer only, then check MPLAB Snap.

author: pub2024
author_rank: Contributor
timestamp: February 03, 2024, 10:09:39 am
content: I have seen MPLAB® SNAP at various online stores, but the user manual is quite shallow.For example, in the case of programming some AVR microcontrollers, not exactly all types of microcontrollers supported by this PCB programmer are mentioned and the output connector (see the image below) does not show how to connect it to an AVR or Atmega microcontroller, where we have MISO, MOSI, SCK etc pins???

author: elektryk
author_rank: Regular Contributor
timestamp: February 03, 2024, 03:05:48 pm
content: Look at the page 38https://ww1.microchip.com/downloads/en/DeviceDoc/50002787C.pdf

author: pub2024
author_rank: Contributor
timestamp: February 04, 2024, 07:40:05 am
content: Thanks.

author: elektryk
author_rank: Regular Contributor
timestamp: February 05, 2024, 05:31:30 am
content: I'm not sure if they improved it in newer revisions but I had to add pullup in mine to work with UPDI (just added pullup without removing pull down).https://ww1.microchip.com/downloads/en/DeviceDoc/ETN36_MPLAB%20Snap%20AVR%20Interface%20Modification.pdf

author: Siwastaja
author_rank: Super Contributor
timestamp: February 05, 2024, 11:50:52 am
content: Quote from: nctnico on January 20, 2024, 10:54:39 pmYeah. I have to add though that even this isn't completely problem free solution, though it bypasses a large part of peter-h's complaints, but not everything. The chip implements ARP, TCP and IP on-chip, but not only you have to interface with this chip, you also need DHCP and DNS software implementations, and the code supplied by Wiznet is broken (e.g., overindexing memory) so you need to either fix it or find working implementations which still need integration work. But sure, DNS and DHCP are both very simple protocols. And if you need TLS, integration work for something like mbedTLS is needed too.But sure, bypassing monstrosity like lwip helps, and time-to-market with Wiznet is probably faster. One extra word of caution: this chip comes with weird compatibility issues with some routers, on the lowest physical level, which require workarounds like forcing the link to 10Mbit mode. This is well documented by many once you Google it ("wiznet" "tp-link"). Just something to watch out for.

author: radiolistener
author_rank: Super Contributor
timestamp: February 07, 2024, 08:44:44 am
content: You can use some FPGA chip wih about 6k LE to implement UDP stack connect to PHY chip with GMII or MII.In many cases there is even no need for MCU, you can do all things in hardware on FPGA.In case of needs you can even implement your own MCU core on FPGA...

author: nctnico
author_rank: Super Contributor
timestamp: February 07, 2024, 05:08:55 pm
content: Quote from: Siwastaja on February 05, 2024, 11:50:52 amInteresting but by the looks of it all these problems are caused by hardware or software errors made by the people trying to integrate it into their design, not the chip itself. If the Wiznet chips where that bad, they would have fixed them by now.

author: Siwastaja
author_rank: Super Contributor
timestamp: February 07, 2024, 05:26:14 pm
content: Quote from: nctnico on February 07, 2024, 05:08:55 pmThe TP-LINK issue is widely documented using Wiznet's own modules, too, so I don't think it's a signal integrity problem - in other words, my own PCB design which works perfectly with 99% of the routers fail with exact same routers others have problems with, too, using Wiznet's own PCB designs. The minimum code to reproduce the problem is absolutely trivial, because the problem appears by the chip not being able to bring the PHY up at all; I have not scoped it to see if it's in autonegotiation logic or something else, but I'm 99% sure it's the "chip itself". I'm not surprised they haven't fixed it. World is full of products and semiconductors with problems that are not getting fixed, especially when there is at least some kind of workaround available (see all STM32 microcontrollers, for example - nothing gets fixed). In fact, I would be surprised if this kind of complex product was flawless.

author: Scrts
author_rank: Frequent Contributor
timestamp: February 07, 2024, 08:28:17 pm
content: Quote from: radiolistener on February 07, 2024, 08:44:44 amOnly for very niche solutions with fixed IP addresses. Otherwise, you want ICMP ping to work, DHCP to pick up address, resolve IP to MAC address using ARP, etc. You will also need a hardware muxer, which would redirect all UDP traffic to FPGA logic and all ARP/ICMP/TCP traffic to softcore.Ask me how I know...

author: radiolistener
author_rank: Super Contributor
timestamp: February 07, 2024, 09:45:55 pm
content: Quote from: Scrts on February 07, 2024, 08:28:17 pmYes, I'm done it, I'm using UDP stack with DHCP, ARP and other things on FPGA, ethernet part eats about 3-4 kLE on Cyclone 4. It automatically requests IP from router with DHCP, it responds on pings and streams realtime high speed data (at 100-500 MBps) between PC and my circuit implemented in the same FPGA... And there is no MCU, all is done on FPGA in verilog

author: Scrts
author_rank: Frequent Contributor
timestamp: February 08, 2024, 02:52:46 am
content: Quote from: radiolistener on February 07, 2024, 09:45:55 pmThat's cool. I was working on high speed data reception over UDP (video streams), which required a packet type based mux in HW. All non-UDP packets were routed to Nios running LwIP for the data handling. UDP packets were handled in FPGA logic. The whole thing utilizing up to 7 video stream reception took 98% of EP3C55...

author: joeqsmith
author_rank: Super Contributor
timestamp: February 08, 2024, 05:06:00 am
content: Quote from: radiolistener on February 07, 2024, 09:45:55 pmAssuming none of that microblaze ... stuff, that's impressive.

author: tellurium
author_rank: Frequent Contributor
timestamp: February 09, 2024, 03:23:06 am
content: Quote from: Siwastaja on February 05, 2024, 11:50:52 amSecond that, and want to add one point:Wiznet chips implement TCP/IP stack internally and provide socket API via SPI.But they also provide a so-called "raw socket", meaning it is possible to fully bypass Wiznet TCP/IP implementation, and use W5500 only as a way to send/receive raw Ethernet frames. Of course in that case the MCU must implement the TCP/IP stack.One might ask - but what's the point. There are two: first, this is a workaround for Wiznet bugs, and second, LWIP is not the only option here. Allow me to mentionhttps://github.com/cesanta/mongoose/once again - it implements W5500 driver, TCP/IP stack, DNS, ARP, DHCP, HTTP/MQTT/Websocket,and TLS 1.3- in a single file. As an example, here is a tutorial for SAMD21 + W5500 on Arduino:https://mongoose.ws/documentation/#xiao-m0--w5500-module

author: peter-h
author_rank: Super Contributor
timestamp: February 09, 2024, 05:17:08 pm
content: QuoteThe above is a windup, surely.How many man-years?Come on guys, try to help the OP by not suggesting such totally esoteric approaches.The reality is that this stuffisa lot of work. There is no way around it. I see my name has been referenced in the usual placesso yeah the main difference between me and most others is that I- post questions with a lot of detail so somebody smart can actually help me (most people just post "help me" questions)- post the solution afterwards (99% of people never do that, sometimes for company policy reasons (leeching is allowed) and mostly because why should they?)

author: Red Squirrel
author_rank: Super Contributor
timestamp: February 09, 2024, 08:59:04 pm
content: I'm looking at doing similar stuff as OP and been doing some research myself so this this is NOT expert recommendation, but I found thePIC18F97J60which looks like an interesting chip.It's a MCU but also has an ethernet MAC and the PHY built in, which a lot of chips only have one and not the other so you would need extra components but this chip has it all and you only need the magnetics (two small transformers which isolate the ethernet signal). From my understanding the MAC is basically the software implementation of Ethernet (ex: OSI layer 2) which is often found on MCUs and the PHY is the layer 1 section which drives the actual Ethernet signal, which often is it's own chip.You also need transformers (referred to as magnetics) and of course the jack itself. Some jacks have it built in but it ends up more expensive per unit but if you're only making a few it's a way to go. If you want to do POE you need a separate chip to control that too. Make sure you get magnetics that have split transformers as the middle is used for the POE signal.Once you have that going you essentially have a device that can talk over an ethernet network at layer 2. Ex: send ethernet frames. If you want TCP or UDP you'd have to implement it in your code and that's rather involved. DHCP, ACK, DNS, etc.... Me personally I will probably just work with raw frames as my device is not technically designed to go on a computer network, I just chose to use ethernet because it can make use of existing infrastructure such as patch panels, jacks, switches etc.At least that's the jist of what I've figured out so far, someone correct me if I'm off on something.

author: radiolistener
author_rank: Super Contributor
timestamp: February 10, 2024, 03:53:20 am
content: Quote from: joeqsmith on February 08, 2024, 05:06:00 amI don't use soft processor, ARP, DHCP and ICMP protocols are implemented as hardware state machine in plain verilog.

author: radiolistener
author_rank: Super Contributor
timestamp: February 10, 2024, 03:59:53 am
content: Quote from: peter-h on February 09, 2024, 05:17:08 pmusing open-source verilog code from github, UDP + ARP can be setup for your FPGA within several hours.Adding state machine with DHCP and ICMP can take longer time, but you can also find examples on github.Look at this implementation:https://github.com/alexforencich/verilog-ethernetIt works very stable and supports 10M/100M/1G/10G/25G link.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: February 10, 2024, 10:52:31 am
content: Quote from: Red Squirrel on February 09, 2024, 08:59:04 pmUnless you need the higher-power flavours of PoE (at/bt), the receive side can be very simple and doesn't need a chip to control - all you need is a couple of rectifiers, a resistor (25K if I recall correctly), and a voltage detector+MOSFET so you don't draw any current until the supply comes up to ~48V

author: nctnico
author_rank: Super Contributor
timestamp: February 10, 2024, 02:20:01 pm
content: Quote from: mikeselectricstuff on February 10, 2024, 10:52:31 amThat is it in a nutshell but gettting the softstart to reset in time due to a short interruption is the tricky part. A good idea is to use a power supervisor (reset) chip to take care of that. The softstart is important to prevent large surges to blow up the ethernet chip and/or damage the contacts on the connector. All in all, you'll end up with a bit of circuitry and using a chip made for POE is just easier.

author: kripton2035
author_rank: Super Contributor
timestamp: February 10, 2024, 02:27:45 pm
content: https://www.aliexpress.com/item/4001134936204.html

author: Red Squirrel
author_rank: Super Contributor
timestamp: February 11, 2024, 01:10:51 am
content: Quote from: mikeselectricstuff on February 10, 2024, 10:52:31 amHmm that's a good point. I kinda forgot about this while going down the rabbit hole myself. Of course you will want some form of SMPS and transformer if you want to isolate the power out since it will not be isolated. But if you're only using it to power relays or the MCU itself and the power never leaves the device I don't think isolation is needed.

author: peter-h
author_rank: Super Contributor
timestamp: February 12, 2024, 02:54:51 pm
content: QuoteSure, but without TCP and the rest like DHCP you do not have a marketable "ethernet" product.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: February 12, 2024, 04:13:33 pm
content: Quote from: peter-h on February 12, 2024, 02:54:51 pmThat depends on your product. Artnet for example only needs UDP and ARP.