Two Modbus instances on one controller solves device incompatibility!



  • I'm learning that one of the biggest issues with Modbus is that many of the sensors and effectors have different baud rates, parity settings, and stop bit settings. I have two sensors that have settable baud rates and stop bit counts, but the settings cannot be made to be the same! So I need two buses. Fortunately the interface card I'm using with my Raspberry Pi has two channels on it, which show up as two serial devices. Implementing these in Rexygen is not hard, but there are some things to watch out for.

    Creating two modbus instances is as simple as adding two modbus drivers to the exec file by chaining them to the "Drivers" output of the EXEC block.

    The Modbus driver in Rexygen uses a configuration file. So, creating two instances of the driver MBM0 and MBM1 will not work if you just add one and then copy it and give it a new name as I first tried to do. Each time I edited a device for MBM1, the one for MBM0 showed up in the driver configuration dialog. Even worse, if I then changed the serial settings, it changed them for the other bus! However by giving each driver instance its own separate configuration file, the problem is solved.

    There is no way to move a device setup "item" from one config file to another inside the Rexygen Studio. However, I successfully moved one by copying the text for the item (Everything from "Item {" to the matching "}" from one file to another.

    myproject_exec.mdl - REXYGEN Studio - [io_task _] .png
    Block properties 2020-05-05 01.01.49.png
    Block properties 2020-05-05 01.01.12.png
    Modbus MASTER over Serial Port 2020-05-05 01.02.57.png
    Modbus MASTER over Serial Port 2020-05-05 01.02.27.png



  • Hello,
    thanks for sharing your experience and findings. There's nothing to add, only that from the nearest release the REXYGEN compiler will issue a warning when two drivers use the same configuration .rio file.

    Jaroslav


Log in to reply