kortenbach
Hi All,
 
I'm trying to use Kincony KC868-A6 as a Modbus slave over Modbus RTU.
I've got Modbus TCP working, but Modbus RTU not (yet).
This is what I did:
[203128%2F9264122%2Fmceclip0]
 
This is the result:
[203128%2F9264126%2Fmceclip0]
 
I'm not sure what pin number to select :
The RS485 pin is 12 but it's also GPIO27. So, should I enter 12 or 27?
 
And I'm not sure what what UART to select.
UART's can be assigned to any IO pin, what UART is actually connected to these pins?
kortenbach
Hi Andreas,
Did you get the RS485 port working on the KC868-A6?
Reply 0 0
kortenbach
From the KC868.cpp file:
[203128%2F9264191%2Fmceclip0]
 
[203128%2F9264218%2Fmceclip0]
 
[203128%2F9264219%2Fmceclip0]
 
The RS485 tx pin is probably meant to switch between send and receive, but is not needed for the KC868 board. So:
[203128%2F9264220%2Fmceclip0]
 
But still no answer from the RS485 port
Reply 0 0
thiagoralves
The RS485 pin is 12 but it's also GPIO27. So, should I enter 12 or 27?
 
Neither of them. The 485TX Pin on OpenPLC dialog is the 485 enable transmit, not the serial TX pin. Since 485 is a half-duplex protocol, it needs a pin to signal when the device is transmitting data. That's what the 485TX pin is for. You need to figure out which pin is used for that. If the board has automatic flow control, then you won't need this pin, and can leave it as -1 on the dialog.
 
The other issue is about serial port pin usage. By default, the interface "Serial" uses pins GPIO1 (TX) and GPIO0 (RX) on the ESP32. If you want to use other pins for your serial data on the ESP32 then you will have to edit the OpenPLC runtime firmware and make the appropriate changes. Check this forum post for more information: https://forum.arduino.cc/t/second-serial-port-on-esp32-wroom-module/1022652/5
Reply 0 0
kortenbach
Hi Thiagor,
 
I edited the settings according to the sourcecode (see my previous post)
I even uncommented a line for debug purposes:
[203128%2F9264222%2Fmceclip0]
 
Instead of a Modbus tool I used PUTTY to listen to the incoming text from this debug line. But I receive nothing...
 
But then I started wondering where the pin definitions #Define RS485_RXD and #Define RS485_TXD where used.
It seems that they where not used anywhere, so I changed @dieter.l 's code at bit to include the pins:
[203128%2F9264262%2Fmceclip0]
Now I receive the debug message in PUTTY, but the data is a bit garbled...
Reply 0 0
kortenbach
I believe the RS485 switching between RX and TX requires some specific timing or something like that.
I tried using the RS232 port instead of the RS485 port but got the same problem.
 
Because the debug message got terminated halfway I decided to add a delay(500) to the KC868.cpp code:
[203128%2F9264373%2Fmceclip0]
 
This worked out pretty well! Not only did the debug message appear without being cut off halway but the Modbus communication started working too!??
I have no idea why a delay in the port initialization would affect the Modbus communication in such a way!
 
Later I changed the delay to delay(50) and it still works fine. Code in the attachment.
Reply 1 0
Reply