hisun
New Member
Posts: 33
|
Post by hisun on Nov 12, 2018 16:54:57 GMT
I want to use an Ethernet shield with an Wiznet w5500 that uses SPI pin configuration
MISO = Digital_Pin 50
MOSI = Digital_Pin 51
SCK = Digital_Pin 52
SS = Digital_Pin 10.
Is there a modified libary available, because the default Ethernet2 libary did not work?
Also can I use or modify the bootloader to use the w5500 chip?
Help is welcome.
Thanks and best regards
Michael
|
|
|
Post by Admin on Nov 12, 2018 17:15:11 GMT
You could try editing the C:\Users\<yourname>\Documents\Arduino\libraries\Ethernet2\src\utility\W5500.h file to change it to the ShieldBuddy SPI channel "BOARD_SOFT_SPI_SS0":
class W5500Class {
public: void init(uint8_t ss_pin = BOARD_SOFT_SPI_SS0); uint8_t readVersion(void);
|
|
hisun
New Member
Posts: 33
|
Post by hisun on Nov 13, 2018 15:32:39 GMT
I tried your suggestion but it did not work. As you perhaps remeber I used your wonderfull shieldbuddy in combination with a Industial Shiel M-DUINO21. unfortunately they discontinued the production of M-DUINO 21 and made a new model M-DUINO 21+ which uses the w5500 chip. With the original Adruino Mega 2560 inside I can use the Ethernet2 libary out of the box. As mentioned in the user guide10.6 Ethernet M-Duino Ethernet port controller is based on w5500 IC, which is the compatible IC compatible with Arduino Ethernet2 Shield libraries. All Ethernet shield Arduino libraries are compatible with the M-Duino. In the M-Duino, W5500 IC communicates to the Mega board via SPI bus (SS Arduino Mega pin 10). M-DUINO 21+ uses the default Ethernet2 settings. Therefore I tried in W5500.h void init(uint8_t ss_pin = BOARD_SOFT_SPI_SS0) for MISO = p50, MOSI = p51 SCK = p52 void init(uint8_t ss_pin = BOARD_SPI_SS0) for 6-Pin Header P201 MISO = P201.1, MOSI = P201.4 SCK = P201.3 Both settings did not work. Perhaps I am overlooking some other settings. Please point me where else I need to change something. Thanks and best regards Michael
|
|
|
Post by Admin on Nov 13, 2018 15:49:46 GMT
The standard Arduino Ethernet2 shield does work with the ShieldBuddy on the default SPI port but we have not tried the new MDUINO21+. The old MDUINO21 with the W5100 on the BOARD_SOFT_SPI_SS0 SPI port works OK.
I think we will need a MDUINO21+ here for testing to find out what is wrong!
|
|
|
Post by Admin on Nov 13, 2018 16:09:16 GMT
To get the MEGA2560 to work, what did you have to do?
|
|
hisun
New Member
Posts: 33
|
Post by hisun on Nov 13, 2018 16:16:22 GMT
I only need to include <Ethernet2.h>
see simple example below.
/*
Copyright (c) 2016 Boot&Work Corp., S.L. All rights reserved
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Include system libraries
#include <SPI.h>
#include <Ethernet2.h>
/*
IMPORTANT: remember to use the modified version of w5100.h header file.
You can grab the w5100.h file from the extras directory of the
Industrial Shields library. You might copy it into the Arduino
Ethernet library: Arduino/libraries/Ethernet/src/utility/w5100.h
*/
// PLC MAC address: DE:AD:BE:EF:FE:ED
byte _macAddress[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
// PLC static IP address: 10.0.0.2
byte _ipAddress[] = {10, 0, 0, 2};
// TCP port to listen
unsigned short _tcpPort = 60601;
// Ethernet server instance
EthernetServer _server(_tcpPort);
////////////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
// Begin serial port
Serial.begin(9600);
// Begin Ethernet
Ethernet.begin(_macAddress, _ipAddress);
// Begin the server
_server.begin();
Serial.println(Ethernet.localIP());
Serial.print("Listening on port ");
Serial.println(_tcpPort);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void loop() {
// Check for a connected client
EthernetClient client = _server.available();
if (client.available()) {
// If a client is available, read data
byte rx = client.read();
// Print it
Serial.print((char) rx);
// And echo it to the client
client.write(rx);
}
}
|
|
|
Post by Admin on Nov 14, 2018 9:39:55 GMT
That is strange as I would expect the default SPI channel to be the one on the 6 pin header on the Mega. This suggests that using pin10 with the SPI pins on pin 50/51/52 should not work. Looking at the Ethernet2 shield library source code, it seems to be using the 6 pin header.
You could also try editing the W5500.cpp in the library to change all the SPI.transfer() commands to include the pin number BOARD_SOFT_SPI_SS0:
e.g.
SPI.transfer( 0x01);
to
SPI.transfer( BOARD_SOFT_SPI_SS0, 0x01 );
The W5100.cpp for the old Ethernet shield was like this.
|
|
hisun
New Member
Posts: 33
|
Post by hisun on Nov 14, 2018 14:30:08 GMT
Thank you for your last advice. Now ethernet works with BOARD_SOFT_SPI_SS0 settings.
Could you also help me also, which source files I need to adjust for the Ethernet BootLoader Flash Programmer?
|
|
hisun
New Member
Posts: 33
|
Post by hisun on Nov 15, 2018 14:01:23 GMT
I think we will need a MDUINO21+ here for testing to find out what is wrong! Hello, sorry i don`t want to press or urge you. Thank you for the solutionj with the setting BOARD_SOFT_SPI_SS0 settings for Ethernet. We still have the problem with the Ethernet BootLoader Flash Programmer. You mentioned to buy a MDUINO21+. Please let me know wether you care about our problem. Thank you very much for your kindness.
|
|