I have an Arduino Mega 2560 Rev 3 and an Ethernet Shield 2 that I'm developing into an industrial controller with and HMI (via HTML/AJAX).
The program works just fine when I've got the shield nested on top of the Mega. I'm able to data log and update my HMI even send control commands via the web interface to start/stop the process.
The problem comes when I attach them to the DIN Rail mounts for mounting inside the Panel enclosure of the environment. My SPI or something seems to not work and so the SD card isn't initializing and I can't log or send my webpage over the ethernet.
I am using this for the Mega and this for the shield, as shown below.
OK so now for where I'm confused. Reading the documentation of the Ethernet Shield 2 I see this:
Arduino communicates with both the W5500 and SD card using the SPI bus (through the ICSP header). This is on digital pins 10, 11, 12, and 13 on the Uno and pins 50, 51, and 52 on the Mega. On both boards, pin 10 is used to select the W5500 and pin 4 for the SD card. These pins cannot be used for general I/O. On the Mega, the hardware SS pin, 53, is not used to select either the W5500 or the SD card, but it must be kept as an output or the SPI interface won't work.
So communication is through the ICSP Header. In the picture above, I have the ICSP Header connected via the ribbon cable. Pins 13,12, 11, 10 and 4 connected via the black wires at the bottom but I'm still not able to initialize the SD card when I'm in this configuration. Again, If I pull the boards out of the DIN rail mounts and stack them together the code runs as expected so it's not a firmware problem it's just a hardware connection but I don't see what I'm missing.
So here are my questions:
What pins am I missing to make this work? Aside from connecting all of them and then slowly eliminating one by one I don't see anything else I'm missing.
Does anybody have the ICSP pinout for both of these devices? My best guess is that something isn't lined up correctly on the DIN rail board
Why does the documentation claim that it uses 50,51 and 52 when these are never connected while the shield is nested on the mega?
If I am needing to hook up all of these extra wires then does the Ethernet shield really communicate through the ICSP?
Thanks so much If more information would be helpful let me know I tried to be as thorough as possible.
The SPI signals (MOSI, MISO & SCK) are present in 2 places on the UNO and the MEGA2560. They are on the 6-pin ICSP header on both boards. On the UNO the same signals are on 11, 12 & 13. On the MEGA2560 the same signals are on 50, 51 & 52.
If you are using the ICSP header on the MEGA2560, then you are also connected to pins 50, 51 & 52.
I do. The black and red wires at the top of the shield in the picture are ground and 5V respectively. The Green LED on the DIN mount turns on when I connect the USB to the Mega. Unless I missed something there as well I believe the power should be fine.
I'm assuming that you are referring to the ICSP header. I can double check it but I did test it with and Ohmmeter. I just can't find the ICSP header pinout for both the Sheild and the Mega (i'm probably just blind) but based on how the connectors link together It should be connected correctly.
Yes I have a female connector soldered in that. I just traced the connectivity from the ICSP pins on the Shield to the ICSP pins on the Mega and I have a direct connection to all 6 pins. I thought maybe my homemade ribbon cables had some thing wrong but those are good.
The pin to pin connection on the Shield also lines up to how it would be when it is stacked. I think at this point I will just get some hook up wire and connect every single pin and then slowly remove them to see what when it stops working and then figure out why once I know which is needed.
I would test for continuity from the 5X terminal pin breakouts to the unused ICSP header on the shield mount. I really feel like this is a wiring issue.
The 5X pins connect correctly through my ribbon cable which is connected directly to the ICSP on the Ethernet board.
The unused ICSP on the mount isn't connected to anything because I'm going directly into the connector on the board. Is it possible that this needs to be connected to the ICSP on the board too? That wouldn't make any sense to me since the ICSP is directly connected to the Shield.
This is the only way I can think of that you can verify the wiring while the rails are being used. If the wiring isn't verified I think you're just going to be spinning your wheels.
Just test that pins 5X make it somewhere from the terminals to the shields unused ICSP header with everything installed. If not, trace it backwards piece by piece.
So the 5X pins don't make it to that unpopulated ICSP header. I guess i'm confused why they need to make it to that one if the ICSP header on the board is connected to the 5X pins. If the ICSP is connect at the board does it matter if the mount also has connectivity?
Have you actually tested the continuity between the locations you're showing in your picture, or just telling us what it should be?
Yeah, I just realized that the shield is pins up. I wasn't looking at it right. Still, need to know if you've verified continuity from pin to pin or not.
I'm not sure what else to try because I h a pin for pin connection on both of them. This somehow leads me to think its an ICSP problem but I've traced that out too.
I will be reaching out to Adafruit where I bought the DIN mounts from to see if they are willing to help. I tried talking to Arduino Tech Support and was told to shove off so I'm just stabbing in the dark for now.