Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A16 Digital Inputs
#1
I'm experimenting with Arduino IDE code (modbus server over TCP) with my A16 rev1.6 and I'm noticing something interesting.

The digital inputs do not latch to a value but constantly switch between 0 and the current value - 0 if they are grounded and 1 if they are not grounded.

Testing bench: I have inputs X01, X02 connected to the ground terminal - the rest are not connected to anything.
Those two inputs contansly stay at a value of 0 in the modbus coil. The rest however constantly hover between value of 0 and 1. I'm attaching a screenshot of a trend generated in the modbus simulator and the arduino code. I'm polling it at 100ms so 10 times a second so the graph is as real time as it gets.

What would be the cause of that? Polling time for the PCF8574 or just the I2C bus is switching between the 4 expanders and looses value while its talking to the rest?

Any tips are greatly appreciated!


Attached Files Image(s)
   

.txt   PCF.txt (Size: 5.11 KB / Downloads: 11)
Reply
#2
here is Arduino demo source code for KC868-A16 PCF8574 digital input and digital output:
https://www.kincony.com/forum/showthread.php?tid=1620
https://www.kincony.com/forum/showthread.php?tid=1619

if you test with our code, if work well ,that means hardware no problem, need check your software code.
You can also download KCS firmware, enable RS485 modbus, have a test.
Reply
#3
I have my code built from your examples with added the modbus tcp server ontop.
The only difference between mine and yours was the delay in the void loop(). Adding the delay to mine code bellow all the digital writes fixed it. Plotting the value for 100 seconds (1000 samples), it never changes from the actual value.

So lesson learned: do not let the cpu poll the IO expander at full speed.

Another question I wanna ask, in the KCS firmware, is it normal to use Modbus-HA for RS485? Lacking the TCP modbus option, I havent used the KCS firmware too much, but when testing with a usb>serial adapter, only Modbus-HA seemed to work.
Reply
#4
KCS RS485 have two option: 1: Modbus-HA 2: Modbud-RTU.
1: Modbus-HA: use for KinCony HAv2 module: https://www.kincony.com/rs485-io-module.html
2: Modbud-RTU: use for modbus RTU standard protocol, protocol document see here: https://www.kincony.com/forum/showthread.php?tid=2528
Reply


Forum Jump:


Users browsing this thread: