Hello Guys,
I have an Arduino Mega 2560 (W5100 Ethernet shield plugged on it ) and an HMI which is PRO-FACE GP-4301TM.
I want to make an application using them over the Modbus TCP/IP protocol.
At the moment, I provided a connection among them with the following code;
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //ethernet modülün mac adresi
byte ip[] = { 192, 168, 1, 80 }; // yerel ağ içerisinde kullanabileceğiniz ip adresi örneğin ("192.168.1.178")
byte gateway[] = { 192, 168, 1, 1 }; // vereceğiniz ip nin ilk değerinden sonra iki tane 0 ve sona 1 vermeniz yeterli
byte subnet[] = { 255, 255, 255, 0 }; // bu ayarları ip4 üzerinden manuel yapmanız gerektiğine dikkat edin
EthernetServer server(502); //haberleşeceğimiz port adresi
String readString; // tarayıcı üzerinden göndereceğimiz string (dizi) tanımlaması
void setup() {
Ethernet.begin(mac, ip, gateway, subnet); // ethernet başlatıldı
server.begin(); // sunucu başlatıldı
}
void loop() {
EthernetClient client = server.available(); // sunucu mevcutken ethernet kullanıcısı tanımlandı
Serial.print(client.connected());
if (client) {
while (client.connected()) { // kullanıcı bağlıyken
if (client.available()) { // ve de mevcutken
char c = client.read(); // kullanıcı isteğini okuyup karakter c ye eşitleme
Serial.print(c); // isterseniz serial monitörden çift // kaldırarak görüntüleyebilirsiniz
}
client.stop(); // kullanıcı sonlandırma
}
}
}
I corresponded to the communication right now, checked with the ModBul Master program.
However, I am not able to send any command right now because I don't know how to send a specific command over the Modbus TCP/IP protocol.
Do you have any recommends or examples that will provide me to be more familiar with how can I send a command over Modbus TCP IP?
Thanks,
Halit.