I want to view some variables with processing from a PLC in a LAN network,
I came across the modbus library for java while surfing the internet.
Is it possible for me to run the code in the link I added below in processing?
If possible, an example about it would be welcome.
I could not understand how to use this library, the processing is also done.
I would like to thank those who helped me in this matter.
Thanks
Halil
public class run {
public static void main(String args)
{
ModbusClient modbusClient = new ModbusClient(“127.0.0.1”,502);
try
{
modbusClient.Connect();
modbusClient.WriteSingleCoil(0, true);
modbusClient.WriteSingleRegister(0, 1234);
modbusClient.WriteMultipleRegisters(11, ModbusClient.ConvertFloatToTwoRegisters((float) 123.56));
System.out.println(modbusClient.ReadCoils(0, 1)[0]);
System.out.println(modbusClient.ReadHoldingRegisters(0, 1)[0]);
System.out.println(ModbusClient.ConvertRegistersToFloat(modbusClient.ReadHoldingRegisters(11, 2)));
}
catch (Exception e)
{
}
}
}
I ran the program as you described, but I understand that it does not go beyond the “try” line.
At the same time, I am running Modbus master simulator on my computer.
I see that the program cannot send data to the simulator.