Can't ping Arduino IP adress

Hi to all,

I am trying to establish communication between Arduino and PLC with Modbus TCP/IP Client/Server. I don’t have any errors in program, just I have problem to ping Arduino IP address. I am using Arduino Uno R3 and Ethernet shield W5100, also IP address of my Ethernet port (on PC) is 192.168.200.5.

I will leav in attachments my program, maybe somebody could me advise what is wrong? I have been follow this video: Siemens S7-1200 PLC to Arduino - YouTube

My program:

#include “EtherCard.h”
#include “Modbus.h”
#include “ModbusIP_ENC28J60.h”

const int SENSOR_IREG = 100;
const int sensorPin=A0;
ModbusIP mb;
long ts;

void setup() {
Serial.begin(9600);
byte mac = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip = { 192, 168, 200, 6};
mb.config(mac,ip);
mb.addIreg(SENSOR_IREG);
ts=millis();
}

void loop() {
mb.task();
if(millis()>ts+2000){
ts=millis();
mb.Ireg(SENSOR_IREG, analogRead(sensorPin));
Serial.println(analogRead(sensorPin));
}
}

Maybe it's busy when you ping it. I see that sometimes it succeeds. Try commenting out everything except mb.task():

void loop() {
mb.task();
/*
if(millis()>ts+2000){
  ts=millis();
  mb.Ireg(SENSOR_IREG, analogRead(sensorPin));
  Serial.println(analogRead(sensorPin));
}
*/
}

Your millis() timing is wrong, it will fail after a few days due to integer overflow. You must make 'ts' an unsigned long type and:

void loop() {
mb.task();

if(millis() - ts >= 2000){
  ts=millis();
  mb.Ireg(SENSOR_IREG, analogRead(sensorPin));
  Serial.println(analogRead(sensorPin));
}

}

Tnx for effort. I try what you described, and it still doesn't work. Did you managed to ping it? Do you have some other suggestion? Tnx.