Ethernet 100Mbit vs 1000Mbit

As mentioned in my previous entry I started with 100Mbit, considered 1000Mbit and reversed to 100Mbit. The reasons to stick to a more conservative 100Mbit are many:

  • Cost for 100Mbit is ca 1/4th of cost for 1000Mbit.
  • Very few PLC type systems support 1000Mbit on daisy chain designs.
  • And the hard fact is that a 10Mbit system is sufficient for the signaling used in most configurations.
  • Complexity on routing increased dramatically.

All in all I concluded that the benefits of having 1000Mbit was to small to justify the extra cost and risk.

AI Messed Up

I use AI a lot in both electronic design and coding and it mostly provides very good assistance. But, it sometimes messes up completely. This is something you must be aware of.

I started by selecting KSZ8863 as a 3-port Ethernet switch. Talking to AI I ended up with a more modern 1000Mbit version, but after a discussion I reverted to a 100Mbit version and tried LAN9354. I noticed that KiCAD symbols was difficult to find so managed to get AI to code one for me and so far so good – except that the symbols I got was first for a RJ45 and secondly for a different chip – utterly waste of time. I wasted far more time trying to get AI to do the job than it took me manually.

And then I cleared the thread and asked for the most used and reliable option and ended back with KZS8863 – AI admitted it had very little source on LAN9354 so it was less reliable.

The AI’s are getting better, but you need to remember that they are a mirror of what is available on the net and can only precent info available – and they currently mess up on regular basis. I will still recommend using them to speed things up asking them to provide information, but you need to use your own head to double-check and make decitions. This is not the first time I waste time with an AI. A good practice is to start new, blank threads and ask similar questions – you might get different answers simply because it is different solutions and if it start messing up you need to investigate it’s sources.

Profinet Circle

The ilustration below focus of how you daisy chain Profinet (or Ethercat) using a dual ethernet device and optionally create a fully redundant circle.

This design has some popularity in classic PLC designs, but it comes with some pros and cons:

Pros

  • It is easy to connect device to device at 100Mbit and even 1Gbit speed.
  • Low collision rate even with a high number off devices.
  • Fully redundant as it will still function if a cable or device break.
  • No extra SW except config on the device.
  • Supported by “plug & play” components.
  • No need for a Ethernet Switch.

Cons

  • More expensive Ethernet interface per node.
  • Latency increase with number of nodes in the chain.

As each node act as a switch it typically take 25us to forward a message, so with 10 nodes chained you get 250u latency end to end. Profinet RT uses layer 2 MAC protocol to be faster than TCP/UDP, but it is only in the local net and still suffer this latency issue.

If you have any experience communicating with aPLC you will know that it typically iterate on 1ms and slows down the loop as more code is added, so any signals with less than 1ms latency is basically a 1 ms latency. And 1ms is actually very fast in a good design, so this extra low latency numbers are most often of no value. Higher bandwidth compared to CAN is of value assuming you need it + it is easier to (less work) to code a Ethernet system.

Dual Ethernet cost ca 5.- USD extra and save you the Switch, meaning it save some space. More important is actually the option to interract in a Profinet network if you want to communicate with a Siemens PLC or similar + the nodes can offer full redundancy through various schemes.

Code for a minimal Profinet RT modul is less than 100 lines of C code.

Dual 10/100/1000 Mbit Ethernet Main

This is an early draft of the Dual 10/100/1000 Mbits Ethernet Main. I decided to use a 1Gbit switch and the reference schematic don’t have many passive components so this should be ok. From a SW perspective we still have the same board as ECUMain. I will look into providing an alternative for the M12-5 used as PSU connector maybe. I am not sure I can manage a M12-4 version for Ethrnet due to the extra components needed thought. We will see. I think this board will be awesome as you can attach 5 custom IO ports and link the boards with a simple Ethernet cable to get a larger, distributed system. And this supports full redundancy designs as well.

2 x Ethernet

This is an old mock-up for a dual Ethernet module. The design is simple as it is a 3-port Ethernet Switch with 2 external PHY’s and one internal RMII port, so the MCU just run lwIP using a RMII port as before and it is in effect a switch so you can connect modules in a chain on Ethernet.

What I consider is to upgrade my 3xCAN (below) with a variant that has 2 x RJ45 Ethernet ports. That way I get a fast Ethernet link between boxes. These switches are also Profinet/Ethercat capable so we could have a lot of fun. The second change I consider is to replace the 3 x CAN ports with more generic IO ports. I already have a separate CAN module, RS485 module and can easely add a RS232 module. STM32H5xx has the same FDCAN as H723. But, the daisy chained Ethernet basically need a 3 port switch to work – yes I can daisy chain in SW, but that add latency. Another observation is that LAN8742 below have a lot of passive components making the Ethernet Phy occupy a lot of space. The 3 port switches require far less space in total.

To achieve this I will need to move SD-Card and SPI-Flash to make space for 2 x RJ45. I probably can move the MCU a bit right specially as I am about to drop the 3 x CAN ports. I would like to keep SD-Card at left, but that will require some trickery.

The objective of this change is to be able to daisy chain PLC boxes using Ethernet without an Ethernet switch + it opens for better Profinet/Ethercat support. The second objective is to open for more generic usage by freeing fixed CAN ports. And then do the same on the more generic ECU Mainboard.

New ECU Main

It is a while since I designed this ECU Main board and to my shame I admit that I did not even assemble the first version because the solutions and SW is the same as for the 3 x CAN board. I am considering requesting new PCB’s now as soon as I am finished with the 3 x CAN. The first version have received a few upgrades and corrections, but I will review the design one more time.

I instantly spot a few mechanical concerns:

  • The SWD is a bit tight to the pin header so it might be difficult to mount. This also reminds me that I need an optimized adapter to replace the old ones. They have worked great, but I want to optimize the space they use. e I need to move the SWD a bit down.
  • The second is if it is room for a M12 on the right-top corner after I moved the DC/DC. I think I have checked that before, but I will re-check it.
  • The last I see is the density of the four leds if I am to lead light to surface.

This new version have a NMEA2000 CAN/Power connector at top-left. PSU voltage is 8-36V so it cover both 12V and 24V and have 6(7) expansion ports free. The connector that is a bit troublesome here is the USB connector, but that is for development primarely.

Another learning lesson is that I should focus on one board at the time. I often order a bunch of boards to save P&P, but end up not even assembling all of them due to lack of time. That will change as I get my PnP machine going and get some experience using stensils – or simply get a factory to assemble boards.

At precent I need to get Ethernet and SD-Card working on 3 x Main before I order new boards.

 

 

 

3 x CAN GW v1.1

This is revision 1.1 of the 3 x CAN Main board. The main difference to 1.0 is that most IO is tested and updated. This is one of 3 main boards in my system and this version is designed to be located on a desktop or in a cabinet with more “normal” connectors. The other two main boards are (1) M12 design with 8 sub-modules and a (2) motor controller eith sub-modules.

 

  1. STM32H723VE with 500Mhz clock speed and loads os RAM/Flash. I have currently used ca 200Kb of 512Kb Flash and even less of SRAM. I reduced speed from 550Mhz to 500Mhz to get a CAN clock that was 25Mhz since that can be reproduced on STM32H7xx MCU’s. I have considered downgrading H723 to H573 to save a few bucks, but I have so far decided against this on all main boards.
  2. Upgraded PSU with capacitors that handle 50V and have a proper EMI filter. Input PSU is either USB through jumper or 8-36V isolated on the connector. An elegant DC/DC module convert to 5V/4A, while the last stage is a 3.3V/500mA converter. This board/MCU uses a bit of current so “as is ” we are up in ca 300mA, but CAN ports and modules are powered through 5V that handles 4A.
  3. 3 x FDCAN ports through a cable connector that connect to a DSUB9 on front panel. Two of these boards can fit in the same box if you want 6 CAN ports. CAN ports can in theory handle 12Mbps, isolated to 5KV and with SW controlled 120Ohm resistor. I just tested these ports, but I have not tested FD-CAN speeds yet. My experience with CAN tells me multiple devices connected on higher speeds will be an issue, but lets see. CAN is in general much faster and more capable that people expect if SW design is intelligent. I have worked on systems with 12 nodes on the network, but some standards insist on using CAN 1:1 as well.
  4. 3 x Module ports allowing sub-modules to be connected though a very fast serial port. Part of the design is that cables can be connected 1:1 and that sub-modules can download FW and restart etc from main board. I will need to add a bootloader for the mainboard itself, but sub-modules uses the build-in bootloader on STMH5xx MCU’s. I am currently using STM32H503 and STM32H523 on sub-modules.
  5. 1 x Link port designed to connect between main boards. This is the same as the module ports, so it can be used for a 4th module. Planned speed on these are 8Mbps full duplex, but this can be adapted. In theory we can use 12Mbps, but again – these speeds are not tested yet.
  6. 10/100Mbps Ethernet port. This is only partly tested and fixing this is next on my task-list. I also have two Ethernet modules (1) with W5500 and another dual Ethernet module, so I am undecided as to what I want with this Ethernet. I have considered removing it and only use sub-modules several times, but I can as well just leave it and not populate the PCB unless I need the extra pins/space.
  7. 1 x SPI Flash. I equip all boards/modules with a 2 Mbyte Flash as minimum. This is divided into 500Mbyte for variables and 3 images for code.
  8. 1 x SPI FRAM/PSRAM position. It uses the same interface as a SPI Flash, but a more narrow ship.
  9. 32 Gb TF Card – this is the second content that is not tested yet.
  10. Standard USB-C port – this is what I use to power the board and to test with. This is not isolated, but it will work straight up as a serial port on any PC and makes this board a CAN/USB GW for my laptops.

Considerations:

  • A WIFI/BLE or Lora module would be nice, but this can easely be added as a module.
  • More module ports would be nice, but I would need to remove Ethernet for that. The issue with the sub-modules is that you add the IO you need so this becomes a customized system in a box. My M12 design is better on this, but I am considering modules with different connector options as well.
  • I currently use 3 expensive CAN tranceivers and consider saving in the region 15USD by swapping them out with cheaper variants that lower isolation to 3KV and speed to 5Mbps – lets see.

Extensions:

  • LCD/TFT Display. It is possible to attach a LCD/TFT display through one of the 4 serial ports. You can use a 3rd party solution as well. We can easely have screen from 2″ to 10″ as needed by some systems. One option is to use a RPI with a TFT screend just connect on the UART. I have both 5″, 7″ and 10″ screens around as well as larger screens. We could even use a RPI Zero that cost 5USD if you only want a screen or any RPI if you want to use Wifi/BLE that way. The main challenge with RPI is the PSU, but I will test a solution for that as well soon. I have a RPI5 project with a 256Gb M.2 disk + a 10 inch TFT and I need to fix the PSU on that anyway.

Production:

The plan is to start a small production line either by assembling these in China or assembling in-house. I will probably test both.

BOM cost – I think an optimized BOM should be < 50.- USD – I need to work on that.

 

3 x CAN

Finally got around to test FDCAN on this board and I got Ch2 and 3 running, but found an annoying bug on ch3. This took me a while because setting up FD CAN is not straight forward, but with good help from CharGPT it finally worked.

What is remaining on this board is to modify Ethernet + wrap up SD-Card – after that I will order a new PCB and try a small production batch because this board is very handy to use.

 

NMEA2000/USB Adapter

I am lagging a bit behind on my projects these days, but good news is that another embedded engineer now will join + I am finally moving on the P&P machine because assembling these for hand is a bit limiting. The adapter below has only minor changes on the N2K power side from what you have seen before.

NMEA2000 is 12V and this design can handle 12V from the M12-5 side as an option. The regulator can handle up to 16V, but it is a SO23 package and a linear regulator more suited for 5V – it will get warm if feeded 12V I think –  it also lack isolation on the 12V side so it is not really intended to be connected on 12V – it was just an option I added. The more important feature is the added USB because that enables it to be connected to a Rasberry PI or x86 based PC. I did see someone offering a NMEA2000 computer costing closer to 2000.- USD consisting of a small i3 PC + a NMEA2000/USB adapter – that is a lot considering that these industrial PC’s only cost ca 300.- USD + the cost on the module above is < 30.- USD.

Using a PC/Raspberry PI as a NMEA2000 signal Hub + display controller is a great idea assuming you have SW for it. You need to watch out for several bottlenecks:

  • How is the PC/RPI Powered? The issue here is that you will mount the PC inside a boat hidden in wall, rooth, floor or maybe behind a screen on the dashboard. Power feed must be galvanic isolated and handle at lease 5A in peaks, maybe more. It is no way I can do that through the connector above. Also you want the option to switch the PC on/off and that requires a remote on/off switch that can be mounted on the dash-board on a boat. I will get back to that one later.
  • What SW is you using? A PC/RPI is fine, but what SW will you use for the dashboard displays and NMEA2000 GW? Do you want one display or several displays? Do you want only NMEA2000 motor gadgets or do you want map system, sonar or even radar integrated? If your a boat owner you are probably aware that many solutions here can cost 50,000.- USD or more. My investigation into existing SW is that it is either DIY or very expensive.
  • How will your PC interface with the USB in this case? NMEA2000 do not cover this part thought there are som de-facto standards that can be used.

Returning to the 2000.- USD PC it was not 100% water-/air-tight and only included some simple demo SW available as open source C#. A friend looking into buying that would have been very disapointed! And water-/air- tight is an absolute must unless you plan to replace the system with ca 2 years intervals. Humid sea-air is a killer for any electronics.

Moving on a bit I have started to use Linux as a desktop and HMI platform – Ubuntu (for now) on a PC and obviously Rasbian on RPI5. I added a M.2 Hat to a RPI5 and is very happy with this one on a 4K scree, but it was a bit slow on 2 x 4K screens.  Adding M.2 SSD and removing the SD card really changes the RPI experience. That said some of the industrial PC’s I find on Aliexpress are probably a better choise and they don’t cost more if you include SSD. Also a i3 or i5 is x86 based while RPI is ARM based – you will find that a lot of SW is not available for ARM yet. But, RPI is a great choice for a Display Controller if you want multiple screens – in this case you connect RPI to Ethernet and use that as network to your NMEA2000, Radar, GPS/Map, Sonar etc. And this is basically what I want to do.

I attempted to use a 10.1 inch screen from a Chinese vendor and that was an absolute disaster – paying 100.- USD for a screen that was dead and a seller that just wasted my time. This is one of the few times I have been let down buying something through Aliexpress – been declined to send it back or getting a refund and left with a screen that don’t work. I spent almost a week working on this myself and following config advices from their site before I gave up – it is not worth my time. So I still have a job to do to find screens from small 7″ to larger 27″ versions that can be used. The idea is to box in a display controller on each screen connected to a wired Ethernet network. I will not prevent people from using Wifi, but I am not recomending radio usage on control systems because they can drop out in noisy situations and a few Ethernet cables and a Switch is plug & play, safe and low cost to cable up.

As for HMI software I will make my own package based on RPI as a display controller. I have not decided what to use as SDK, but I have a few options:

  • Qt/QML is an option. It is on my skillset since I worked with it for years.
  • Qt/Python is another option.
  • Lazaruz (Pascal) is an option – I have coded in this as well and it was very straight forward.
  • I am ruling out C# on RPI – to slow I think. I can give it a test, but that will be AvaloniaUI so lets see.
  • wxWidgets is an option.
  • A new C++ SDK based on Vulkan will be considered.

My favorite choise would be to wrap up a clean C++ Vulkan SDK and go from there – I have already put some testing into that, but Qt/QML is probably less work and this is still “kind-off” C++. The drawback with Qt is that I either have to work with a GPL license or pay 5000.- USD a year in license cost. But, Qt is a great start for a control system HMI if you don’t want to jump into making your own C++ SDK. That said – QT don’t have many ready made HMI gadgets so it is still a bit work, but I have a large library myself I can brush the dust off – lets see. I think I want to do a demo test with Vulkan and see how fast ChatGPT can assist me on the basics like drawing high performance precentation graphics etc – and then decide from there. I will be back on this.