Hello everyone. This is my first post on this forum, so I’d like to say hello.
Sorry for my English, I’m from Poland, and I’m not so good at English, and I’m sorry if I putted this topic in wrong category.
I have a problem. I’m using Arduino Leonardo + SoftwareSerial library, (later it will be Arduino Mega) to talk with HMI panel WECON 102L using Modbus/RS485. A have a MAX485 chip, and I can read what my HMI send to me. I did some simple interface on HMI. Only one bit indicator, which read register number 13.
Frame which I receive on SerialMonitor looks like that:
1 <- slave adress
2 <- function code (2, read registers)
0 <- register adress 0 * 256...
13 <- ... + 13 = 13
0 <- quanity of registers 0 * 256...
1 <- ... + 1 = 1
40 <- CRC
9 <- CRC
255 <- propably a trash
so it looks good. My response should be like that:
1 <- adress
2 <- function
1 <- quanity of data bytes
1 <- data - 1, because it is active
72 <- CRC
96 <- CRC
right?
but, indicator doesn’t want to change on HMI. And shows error to me “No. 1 PLC addr 1_X_000013 COMM timeout!”
so what’s wrong?
I’ve tried to do this much simpler, so now I have only code on my Arduino, which send message without request… I have switched MAX485 on transmit mode, transmit frame, and delay 300ms.
Led on HMI called “COM” is blinking every 300ms, so something is receiving by HMI, but no effect.
I’m using LiveStudioU to create interface on HMI.
Communication:
ModBus RS485
Data bits: 8
Parity: NONE
Stop bits: 2
Baud rate: 19200 (the same on Arduino and HMI ofc.)
long byteReceived;
long sendIt;
// (...)
void loop(){
digitalWrite(TransmitDirection, RS485Transmit);
sendIt = 1;
RS485Serial.write(sendIt);
sendIt = 2;
RS485Serial.write(sendIt);
sendIt = 1;
RS485Serial.write(sendIt);
sendIt = 1;
RS485Serial.write(sendIt);
sendIt = 96;
RS485Serial.write(sendIt);
sendIt = 72;
RS485Serial.write(sendIt);
delay(300);
}
I would be very happy for any help, it is very important to me.
If you can, please - use simple language hehe.
Regards.
//----------------------
edit:
Or do you know some libraries for Arduino Modbus 485, which can communicate with HMI like mine? With description, or examples? Because maybe I would not have to learn this protocol, how it works, etc. Instead of that, I could just use some prepaired functions to talk between Arduino and HMI.