Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Modbus RTU serial issues with Codesys V3 RTE

2015-08-14
2016-01-26
  • patrickduis - 2015-08-14

    I have a few issues with modbus RTU communication that is running on codesys V3 RTE.
    Via a USB->RS485 convertor (mapped to COM8 in Win7 32bit, 38k4bps N81) I am able to communicate with various temperature controllers as modbus slaves. This works fine with a SCADA package (in this case: SpecView) so the hardware is running ok and also with other equipment that I use like Pro-face touchpanels.

    Yesterday I was able to get the Modbus communication going in Codesys V3 RTE, I still have issues with it that prevents me from proceeding with further evaluation of CodeSys V3.

    Issue 1:
    I noticed that when the modbus RTU communication to the slave is running (modbus COM, modbus MASTER and modbus SLAVE all 3 green) and I disconnect the RS485 cable, the system detects a timeout and puts the slave in error state (red).
    When I re-connect the cable the slave communication does not start automatically, normally it always starts again with modbus serial. I need to restart the RTE (softplc) to get the modbus slave communication going again.
    -> Am I doing something wrong here? Is there a setting not ok? Normally speaking modbus serial communication must always restore itself automatically.

    Issue 2:
    In the attachment you can see a screendump of the modbus slave that I'm communicating with. It is an RKC TIO 4 channel temperature controller. The first 4 modbus addresses that can be read 0x0000, 0x0001, 0x0002 and 0x0003 are the actual temperatures. The current values however are always 0 with running communication. And I'm sure I'm reading real temperature values because this works fine in my other scada package.
    I am using the same IO mapping as the one I used last year at a customer in Germany with (I think) Codesys V2.x running in a Beyer touchpanel..........Same function code, cyc trigger, same read offset etc. etc. etc.....so that must be ok.
    But no matter what I do, I always read 0 iso a temperature from the slave. I also tested with other slaves: same result: modbus IO running, flashing lights on the controllers, but always I get 0 back as a result. Remember that it is not the slave and/or hardware because this works fine in another SCADA package.
    -> Am I doing something wrong here? Or has it something to do with the fact that I don't have a license? I also tested directly after laptop boot, but same result: always 0 in the current value.

    Many thanks in advance for your help.

    IMG: codesys7.png

     
  • patrickduis - 2015-08-14

    After plowing through many settings of the DEVICE. In my case: the Codesys Control RTE). I found that my IO was not updated!
    After enabling/changing the following settings of the DEVICE/PLC settings I was able to read values from my modbus slaves:
    - change "always update variables" from disabled to enabled 2
    - change bus cycle task from "unspecified" to maintask
    I also enabled the "enable diagnosis for devices" but need to investigate that further.

    IMG: codesys9.png

    IMG: codesys8.png

     
  • TimvH

    TimvH - 2015-08-21

    CODESYS doesn't update I/O variables which are not used in the application. If you had used them in e.g. PLC_PRG it would have worked, but by activating your settings as you described it will also update them, even if they are not used.

    The automatic reconnection can be enabled in the Modbus Master settings.
    Enable the option "auto-restart communication".

    Another method to control this is by monitoring the state of the Modbus Slave with the variable:
    <modbus_slave_name>.xError
    In your application you can check this state and if it is TRUE you can write you own code to determine when to reset the device and reconnect again:
    Set <modbus_slave_name>.xReset to TRUE.</modbus_slave_name></modbus_slave_name>

    The device diagnosis is part of the "Application Composer" modules. This provides functionality to automatically create diagnostic information of all you devices in the device tree when you start the Application Composer Generator. See the CODESYS help for further information.

    If required, we can further help or train you, because we are also situated in the Netherlands. Please contact Extend Smart Coding ( w www.extendsmartcoding.nl w ) if you are interested in this.

     
  • patrickduis - 2015-08-21

    Thanks for the info. I was very busy with another project this week. Need to go back next monday but next week I will continue with the CodeSys testing. Talked to some experienced S7 PLC programmers this week on the project (all use TIA portal)......most of them are not too happy with CodeSys.....but that is always with something that is new....
    In my opinion CodeSys is the right way to go for the future because it is hardware independent and you can re-use the code.

     
  • frankdunn - 2015-12-11

    good day

    I am also having problems with auto restart communication . I am using modbus rtu (rpi is master ) and it works fine until I unplug the slave . The only way to restart communication is to do a reset or reset Modbus_Slave_COM_Port.xError bit. Is there any other solution ?

    Thank You
    Frank Dunn

     
  • patrickduis - 2015-12-11

    I have the same problem, and this is a really big issue because we must be able to make an "on the fly" repair with a restart.......

     
  • frankdunn - 2015-12-11

    Hi

    Try to untick auto restart communication and then monitor the slave error bit . when bit goes high you can set the reset bit , this does not work for me when auto restart is enabled , but works fine when i untick auto restart communication . I am not sure if it is the same problem on rte , I am testing on raspberry .

     
  • eschwellinger

    eschwellinger - 2015-12-12

    Hi,
    this was a bug and it is solved with 3.5SP8 release now.

    BR
    Edwin

     
  • Anonymous - 2016-01-13

    Originally created by: andreas.sauerwein2

    Hi,

    I just checked it with version 3.5SP8.
    auto restart communication has no effect in my programm but

    <modbus_slave>.xReset := <modbus_slave>.xError
    

    works. Regardless of ticking "auto restart communication".

    BR
    Andreas

     
  • eschwellinger

    eschwellinger - 2016-01-26

    Hi,

    are you sure the new library version is active (you need to update the modbus devices in the device tree by update device)

    BR
    Edwin

     

Log in to post a comment.