Hello colleagues, please, is it possible that the selection of the upper and lower byte in the word is incorrectly translated?
When I enter .B0, the upper byte is selected.
Thanks, Roman
Hello colleagues, please, is it possible that the selection of the upper and lower byte in the word is incorrectly translated?
When I enter .B0, the upper byte is selected.
Thanks, Roman
Hi Roman, If the value in the variable M11_M12_16DI is 16#0001, then this behaviour is correct - 16#01 is the lower-order (least significant) byte. ~ Martin.
From that printscreen it’s not entirely clear, if you have a DO16 card, so try to write 1 in the word .X0 and you will see which bit lights up. .on my card lit up X8.
Hi As far as i remember, the byte order is different in Axioline compared to Inline…
I had some similar experience with the byte order. You can try use the SWAP function on the WORD. - Emil
Thanks, Emil, but why is it different? It’s a little confusing. Roman
Hi Roman, I/O data is mapped in the Motorola format. The result will be so if you mapped all 16 bits to a word.
Hi Roman, (EDIT: Posted at the same time as Acke, sorry!) The issue here is the “endianness” of the I/O module, which the PLC cannot change. In the data sheet for I/O modules, you should find a statement something like this:
The Motorola format is big-endian. The architecture of the AXC F 2152 (for example) is little-endian - which is why the bytes are swapped - but you don’t need to know this. To make your code platform-agnostic, so that it can run on either big-endian or little-endian PLCs, you should use the “TO_BIG_ENDIAN” function when writing to Outputs that are mapped in Motorola format, and “FROM_BIG_ENDIAN” when reading inputs that are mapped in Motorola format. Similar for I/O modules that map I/O in Intel (little-endian) format. By using these functions, the I/O will be converted to/from the format of the PLC without you needing to know what that format is. Here is an example from an AXC F 2152:
Because the AXC F 2152 uses little-endian format, the TO_LITTLE_ENDIAN function does nothing, while the TO_BIG_ENDIAN function swaps the bytes. This behaviour would be reversed on a PLC that uses big-endian format. So, in summary: Check the format that the I/O module supports, and always use the corresponding TO/FROM_*_ENDIAN functions where appropriate. Hope this helps. ~ Martin.