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 TCP loosing set values

2016-02-10
2017-12-22
  • pavol.fazik - 2016-02-10

    Hi all, could you please advice me.

    I'm able to write values from php via FC16 into the modbus. I can se that the variables were set:

    but the value is gone in few seconds and set back to 0:

    why is this happening? any idea?

    second question, I'm not able to set the TYPE of the variables in I/O setting?

    Thank you in advance.

    IMG: 2016

    IMG: 2016

     
  • MidwestFAE - 2016-02-10

    I have worked with Modbus TCP a pretty fair amount recently. I there is no "Modbus TCP" setting that would explain this. If you were trying to write to a read only area, you would get faults or unchanged values. I would recommend doublechecking the programming at the slave and master level and make sure that you don't have code overwriting those registers, or resetting them.

    As to the "TYPE" question, WORD and BYTES are pretty much it. Modbus seems to move the binary bit patterns from one place to another with regard to data type. If you need to treat the data as something else, you will need to declare a variable in the global variable list.

    If you needed motor speed 1 to be a double word you would go to the global variable list and do something like

    MB_Motor_1 AT %IW0: DWORD;

    that will take IW0 and IW1 and place the binary bit pattern into the tag MB_MOTOR_1 and treat it as a double word.

     
  • pavol.fazik - 2016-02-10

    Thank you for the reply. It gave me hope for a few minutes but unfortunately the situation is still the same.

    I have no code that would null the modbus variables. Neither in codesys neither in php.
    I have very simple code and this code was working in 2.3 now in 3.5 not.

    Maybe the modbus variables are nulled at the begining of each cycle?

     
  • pavol.fazik - 2016-02-10

    one more point, when I debug the code, the values stay set I have tried to make few cycles...

     
  • learnetk - 2016-02-10

    Hi
    maybe you could have set the Error Handling - Set to Zero instead or Keep last value.

    IMG: ErrorHandling.png

     
  • pavol.fazik - 2016-02-11

    Hi,
    there is no such a setting when having only modbus slave. I found those settings only if you have modbus master

    IMG: 2016

     
  • ndzied1 - 2016-02-12

    The way you have it set up, it looks like your CoDeSys controller is the Modbus slave.

    If you want your CoDeSys to write to another device, you have to install a Modbus master then install the slave(s) under that.

    IMG: CodesysModbus.PNG

     
  • eschwellinger

    eschwellinger - 2016-02-12

    Hi,

    the plc should be a modbus slave and it is solved by increasing the timeout.

    BR
    Edwin

     
  • robz - 2017-12-22

    Same issue, with no result here, but all of a sudden it began working with these settings

    IMG: 2017

     

Log in to post a comment.