CODESYS v3+ WAGO PFC200+ MODBUS RTU

ZKh
2016-06-10
2017-11-03
  • ZKh - 2016-06-10

    Hi
    I am new to CODESYS and Wago PFC200. I downloaded CODESYS 3.5.8 and PFC200 package manager. I also updated PFC200 package manager.

    I want to read and write some values(Start Add:40001, Register Size:2, Type: Float) between PFC200 and my slave device (ELSTER EK220)through Modbus RTU (RS485).

    I added all Modbus Libraries and PFC200 Libraries to my project.
    I inserted Modbus_com, Modbus_Master_COM_Port and Modbus_Slave_COM_Port into Devices tree.
    I changed serial mode to RS485.
    I set the PLC settings as follows:
    -Always update variables: Enabled2(Always in bus cycle task)
    -Bus cycle task: Main task

    But when I login and start CPU, Modbus_Slave_COM_Port does not running.
    I also checked COM_Port, and there was no error!!
    what else should I do?

    I will attach screenshots.
    Thanks in advance

    IMG: ModbusRTU.png

     
  • eschwellinger

    eschwellinger - 2016-06-11

    Hi,
    are you sure this offsets are correct?
    I probably do not have the correct documentation for this device but the one which I found with google does
    not have these 40000 Offsets.
    Could you check this and read for example just to try if the slave respond on that with other Offsets.
    BR
    Edwin

     
  • ZKh - 2016-06-12

    Hi

    I read my slave's manuals and datasheets. There was nothing about offsets, when configuring modbus.
    I connected slave to SIEMENS S7-1200 through modbus RS485 and read data. There was a pre-arranged column for offsets (0.0; 4.0; 8.0; 12.0; ...)

    I used these values in CODESYS as offsets. Still I've got the same results. Slave is not running.

    Is it possible that there is something wrong with my 'CODESYSControl.CFG'?
    I attached my CODESYSControl.CFG as pdf.

    thanks in advance.

    CODESYSControl.pdf [25.99 KiB]

     
  • eschwellinger

    eschwellinger - 2016-06-12

    Hi,
    this CODESYSControl.cfg is from /GatewayPLC Directory from your PC right?
    This has nothing to do with the PFC200.
    BR
    Edwin

     
  • ZKh - 2016-06-13

    Hi Edwin

    Thanks a lot for your response and help.

    yes CODESYSControl.cfg is from GatewayPLC Directory.
    I tried every thing to fix this problem but my slave status is still 'not running'.
    I don't know whats wrong!!!

    Is there anything else I have to consider?

    Thanks in advance

     
  • eschwellinger

    eschwellinger - 2016-06-13

    Hi,
    I would just read one function code without offset.
    If this give a result add others...
    Which functioncode does the modbus slave support to read?

    BR
    Edwin

     
  • ZKh - 2016-06-13

    Hi Edwin

    Thanks a lot for helping me.

    I reset all settings:
    1- Factory Resetting PFC200-750-8202/025-002
    2- adding all Modbus Libraries and PFC200 Libraries to the project
    3- inserting Modbus_com, Modbus_Master_COM_Port and Modbus_Slave_COM_Port into Devices tree
    4- Changing serial interface to RS485
    3- set the PLC settings as follows:
    Always update variables: Enabled2(Always in bus cycle task)
    Bus cycle task: Main task

    4- Modbus slave channel setting:
    Modbus slave supports Function code 3 (read holding registers).
    Access type: FC3
    Offset: 0
    Length: 1

    Modbus slave status is 'not running' again.

    some questions:
    1- How is it that when slave is connected or not, I got the same results? nothing will change.
    2- The data type I am trying to read from slave is Real. The setting in CODESYS defines data of type word in Modbus slave I/O mapping. How can I change it to Real?
    3- Is it helpful to Change Master or Slave response timeout and time between frames?

    IMG: SlaveChannel.png

    IMG: Modbus.png

     
  • eschwellinger

    eschwellinger - 2016-06-13

    Hi,
    if the slave does not respond on that simple project,
    this maybe is a wiring problem?

    BR
    Edwin

    IMG: RS485connector.jpg

     
  • ZKh - 2016-06-14

    Hi Edwin

    Thanks a lot for your consideration.
    Wiring was the first thing I checked. I don't have wiring problem.

    To solve the problem; I did something different:
    I did the same setting in CODESYS v2.3.9.47.
    Still I can't read data from Modbus slave.
    The program has no error (MBCFG_ERROR= MBCFG_NO_ERROR) but there is an error number generated by 'sercomm.lib' (MBCFG_SERCOM_ERROR= 2).
    I've found 'sercomm.lib' from WAGO. If I'm not mistaken the error says: "0x02: COM port outside of the valid area". But the valid area is 2-65!!!!
    This time I changed the slave and used 'ADAM-4561'; and I am sure of the COM Port 4; because I changed the port setting in device manager.

    Why this happens? How can I fix it?
    Is it possible that the x3:RS232/485 port of PFC200-750-8202 doesn't work properly?

    I attached the screenshot.
    Thanks in advance.

    IMG: Codesysv2.png

     
  • ZKh - 2016-07-03

    Hi
    Good news
    Finally I established a Modbus RTU (RS485) connection and I can read data from slave.
    I need data to update online but the problem is that, slave's data updates slowly
    I defined timeout responses as 1 second. Still not enough.
    Unfortunately adding data length makes updating slower.

    Is there any way to boost the update operation?

    Thanks in advance

     
  • ZKh - 2016-08-30

    Hi every one

    I established a Modbus RTU (RS485) connection between CODESYS and PFC200; and I can read data from slave.

    The problem is that slave's responses are very slow and erratic.
    -I tried to fix this by changing timeouts but didn't workout.
    -I am sure about authenticity of slave device, because it works fine with other PLCs.

    Is there any way to boost and organize the update operation?

    Thanks in advance

     
  • annD

    annD - 2017-09-18

    Hi,

    how did you establish your connection in this case? What was the solution?
    I am struggling with a similar topic.

    Best regards,
    annD

     
  • eschwellinger

    eschwellinger - 2017-09-18

    Hi,
    are you using a PFC200 mit Modbus RTU?
    BR
    Edwin

     
  • johnlee - 2017-11-03

    ZKh hat geschrieben:
    Hi every one
    I established a Modbus RTU (RS485) connection between CODESYS and PFC200; and I can read data from slave.
    The problem is that slave's responses are very slow and erratic.
    -I tried to fix this by changing timeouts but didn't workout.
    -I am sure about authenticity of slave device, because it works fine with other PLCs.
    Is there any way to boost and organize the update operation?
    Thanks in advance

    Hi ZKH,

    The interest of the Modbus RTU is this communication protocol very easy to implementation due to it do not need any high speed communication chipset.
    So for your case the issue is more on the slave site, if the slave it take longer time to process data then you can't do anything to boost up the respond time.
    What you can try to do is shorter the distance of the wiring and using faster baud rate.

    Thank you
    John Lee

     

Log in to post a comment.