0

I currently dont have access to the plc that would be implemented and am unable to find much on the internet that covers reading discrete inputs. What im aiming for is something that will detect when a prox switch is turned on which could =true or 1 then to execute a file that runs an automated entry for a workorder. Also for it to perpetually scan and read the status what would be implemented to do so? I'm essentailly brand new to python and managed to figure out selenium but without having a plc to play with its difficult to just figure it out. Thanks in advance!

from pymodbus.client.sync import ModbusTcpClient
import os


host = '100.100.110.104'   
port = 502
client = ModbusTcpClient(host, port)
while True:
    client.connect()

    rr = client.read_discrete_inputs(1000,1,unit=1)

    data= rr.bits[0]    

    if data = 1
        os.system('python AUTOMATED.pyw')

    time.sleep(5)
Peddlur
  • 1
  • 1
  • You could use a Modbus server simulator to test your script, like [ModRSsim2](https://www.support.aceautomation.eu/knowledge-base/modrssim2-modbus-slave-server-rtu-tcp-and-df1-simulator/). – Bosz Jun 28 '23 at 10:59
  • For a quick and dirty test, you could setup and use [Modbus Slave](https://modbustools.com/modbus_slave.html) – Nick S. Jun 28 '23 at 14:35
  • You can also use this online [modsim](https://github.com/gavinying/modsim) at `modsim.topmaker.net:502` if you don't want to set up your own simulator. It works as a remote Modbus-TCP device with different types of registers. – balun Jul 16 '23 at 09:58

0 Answers0