Configure Neuron S103x as Modbus Slave

  • Hi,
    I need to configure my Raspberry Pi, that handle valves and controls, as a TCP Modbus Slave.
    The problem is that the application is a porting of another application and for compatibility I need to leave the same Modbus registers.
    I need to configure an array of 600 elements of DINT contiguous, another area configured like array of 600 elements of REAL, a 600 bit array area and some other bits distributed in different other areas.

    I have configured the system as the following image illustrates...

    I have the following questions:

    *** the controller can act at the same time as a master and as a client in Modbus TCP?

    *** how can I set the right Modbus area to be available exactly as previous ones?
    For me isn't so clear the area configuration in the left side of the configuration Modbus windows. I checked the "Modbus TCP Slave Device I/O Mapping" but is not clear for me how to proceed to configure addresses I need.

  • Hi Mike,

    It is possible to run CODESYS as both a modbus master and slave at the same time. I have not tried this on the Neuron, but it does work on the Raspberry Pi.

    I can see an initial problem in your application. In CODESYS the EtherNet device represents an EtherNet interface. To Use CODESYS to talk as a Modbus Master to the Neuron, the EtherNet device should be configured to use localhost as per the sample project and documentation.

    If you also wish to have a modbus slave device accessible from outside then you need to add a second EtherNet device and configure it to use the correct EtherNet interface (you could choose the wired or wireless interfaces on the RPi3, or in theory add addiitonal USB EtherNET adapters). Then add your Modbus slave configuration beneath that top level.

    I have not tried this on the Neuron, and there is a chance that there will be a conflict with CODESYS and the Nuron firmware both binding to the same port. If that is the case then you could run the Modbus slave on a different port number.

    I will run some tests over the next few days and get back to you. If you make any progress following the above tips then please get back to me.

    regards David

  • @DavidCozens ok - many thanks. I'll wait for you and if I move through some test I'll inform you.

  • Hi @mikeardy,
    I have run some experiments with configuring a CODESYS master and a Slave on the Neuron, and I can get it to work with one restriction - we have to use a different port, in this example I chose 503 rather than the default 502 normally used for MODBUS TCP.

    The basic configuration looks like this
    0_1523786112750_devices.png , as you can see it is working. The firest Ethernet Device is configured to use localhost (device lo) as the UniPi Neuron for CODESYS datasheet shows.

    Ethernet_1 is another device that I have bound to the cabled ethernet device like this
    On the RPi the device will be 'eth0' for the cabled ethernet. If you have connected to a specific Neuron in CODESYS then you will be able to click the ... button to select from a list of interfaces. I prefer to let the operating system specify the IP address settings, so I don't enter those.

    I then added a ModbusTCP_Slave_Device - for now I have to select a different port number to make things work
    0_1523786535344_slave1.png . You can use the same screen to configure how many registers you want in your slave, the UID etc. Use the mapping tab to then map values from your PLC application into the modbus registers.

    Obviously having used a different port number your Modbus master will need to use a different port number to communicate with the device.

  • Thank you.
    I will try.

Log in to reply