Yep, this is a regular problem. As long as your data words are no larger than 8bit, you're fine. But Siemens and KUKA follow different standards (originated in the Microprocessor Wars between Intel and Motorola back in the 1970s) about how the bytes in a 16-bit word are arranged.
In a KUKA, a 16bit word looks like this: Bit16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1
In a Siemens PLC, it looks like this: Bit8,7,6,5,4,3,2,1,16,15,14,13,12,11,10,9
It's nutty, but there you go.
So, how to fix this? There's more than one way. Usually I just use a standard Siemens S7 logic block that converts multi-byte data words to the "correct" order before sending to, or after receiving from, the robot.
It can also be fixed by changing your Profibus config file -- not PFBMS.INI, but the .LDB file created using the Siemens NC software. Or, we could even fix it by adroit manipulation of IOSYS.INI.
But you're trying to do it the "right" way, using the [SWAP] section in PFBMS.INI. My guess is that you have something like this in your program code:
SIGNAL InputWord0 = $IN[161] TO $IN[176]
SIGNAL InputWord1 = $IN[177] TO $IN[192]
I'm trying to remember, but I believe that the offset value in the SWAP assignment is byte, not word. So your SWAP assignment would correct the byte-swapping on InputWord1, but
not on InputWord0. You may need a SWAP assignment that looks like this:
INWORD_SLAVE_127=0,2
or
INWORD_SLAVE_127=0
depending on what you're doing with the other 16 bits.
Ah. I found it. Okay, your problem is that SWAP only works on data words that have been created as
exactly 16bits in size. Your IOSYS.INI assignment creates a single 4-byte 32bit word. You need to do this:
INW20 = 127, 0
INW22 = 127, 2
OUTW20 = 127, 0
OUTW22 = 127, 2
That should do it.