Hi,
For my project, I need to connect my CONTROLLINO MAXI (PLC based on ATmega1602 & ethernet shield W5100) to a PLC using the modbus TCP protocol.
Link of CONTROLLINO : http://controllino.biz/controllino/maxi/
I've got some issue trying to connect to the PLC with "client.connect(ipofPLC,502);". It worked fine few month ago but I switched on another project before coming back to this..
I'm sure of the ip's configuration. I'm able to ping the PLC too.
It looks like I can't connect using that port because I've put my PC on the same network and did a webclient or telnet and It worked fine.
The code for testing the connection (based on telnet client example as you can see) :
#include <Ethernet.h>
#include <SPI.h>
#include <Controllino.h>
byte mac[]={0x00,0x24,0x77,0x09,0x22,0x38};
IPAddress ip(10,16,25,101);
IPAddress gateway(10,16,25,1);
IPAddress subnet(255,255,255,0);
IPAddress server(10,16,25,25);
EthernetClient client;
void setup() {
Serial.begin(9600);
Ethernet.begin(mac, ip,gateway,subnet);
delay(6000);
Serial.println("connecting...");
if (client.connect(server, 502)) {
Serial.println("connected");
} else {
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
}
void loop(){
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
while (true);
}
}
I get "connection failed".
My mind is stucked. So, if you have any idea about the source of this problem, let me know. I'm waiting for the IT crew to have more information about the network part.
Thank you for your consideration on that matter.