Hello
I am using Codesys control WIN on windows 7.
I have defined the following STRUCT for building up IO communication with an Ethercat slave
TYPEST_InputList:
  STRUCT
    nVal0    :UINT;
    nVal1    :UINT;
    nValD    :UDINT;
    nValF     :REAL;
  END_STRUCTEND_TYPE
and
TYPEST_IOModule:
  STRUCT
    iData   AT%I*     :ST_InputList;
  END_STRUCTEND_TYPE
In my application, I have defined a variable
VAR_GLOBAL
  comModule      :ST_IOModule;END_VARVAR_CONFIG
  GVL.comModule.iData   AT%IW1  :ST_InputList;
  (*VL.comModule.oData  AT %QB0    : ST_OutputList;*)
 Â
END_VAR
I attach the process data of my slave.
The first 4 Bytes builds up a bit register. So my first numerical value start at 5th Byte (32nd bit, that's why you see EtherCAT-1\%IW32 although I agree %IW2 would be more consistent).
I see in the Ethercat I/O mapping that the address is %IW1, I would have expected %IW2 also --> Might there be a problem with ESI file I used to install my slave into codesys ?
as a result :
In my slave, when I set a value for the outputs corresponding to the members nVal0 and nVal1, I see the right value in my Ethercat master (running on codesys control WIN) --> everything Ok so far for UINT value
But, for nValD, when I write the value 1 on the salve side, I see 65536 on the Master side.
I don't understand how Bytes,Word,Dword are arranged.
I would appreciate any help. thank you
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2015-11-25
Originally created by: scott_cunningham
I have seen this before with other hardware. Basically, the data is copied byte by byte starting at the left. So if your data is 16 bit variable and you map it to a 32 bit ethercat register, your variable is copied to the upper word. You should be able to avoid this problem by using data of the same size (variable versus ethercat register). If you cannot change the data size, then you can make special bit shifting to get your data....
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
some PLCs place the bytes into the memory as little endian and others as big endians. You will have to check when this happen and to do the swapping of the words when needed
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello
I am using Codesys control WIN on windows 7.
I have defined the following STRUCT for building up IO communication with an Ethercat slave
and
In my application, I have defined a variable
I attach the process data of my slave.
The first 4 Bytes builds up a bit register. So my first numerical value start at 5th Byte (32nd bit, that's why you see EtherCAT-1\%IW32 although I agree %IW2 would be more consistent).
I see in the Ethercat I/O mapping that the address is %IW1, I would have expected %IW2 also --> Might there be a problem with ESI file I used to install my slave into codesys ?
as a result :
In my slave, when I set a value for the outputs corresponding to the members nVal0 and nVal1, I see the right value in my Ethercat master (running on codesys control WIN) --> everything Ok so far for UINT value
But, for nValD, when I write the value 1 on the salve side, I see 65536 on the Master side.
I don't understand how Bytes,Word,Dword are arranged.
I would appreciate any help. thank you
Originally created by: scott_cunningham
I have seen this before with other hardware. Basically, the data is copied byte by byte starting at the left. So if your data is 16 bit variable and you map it to a 32 bit ethercat register, your variable is copied to the upper word. You should be able to avoid this problem by using data of the same size (variable versus ethercat register). If you cannot change the data size, then you can make special bit shifting to get your data....
some PLCs place the bytes into the memory as little endian and others as big endians. You will have to check when this happen and to do the swapping of the words when needed