COP SINT to INT

Hey guys, I am working on a project where I need to copy a SINT into an INT. I have a String that the operator inputs from the HMI. We'll call this My_String. So I have My_String.LEN = 4 and I am using a COP instruction to move My_String.Data[0] into My_Ints[0] with a length of 2. It works but it is backwards. I understand that I can use the SWPB instruction and move it to another Int to rearrange it. What I am wondering is why it gets reversed in the first place. Are bits 0-7 in the INT the high word and 8-15 the low word?

My_String[0] = 'A' which is moved to bits 0 - 7
My_String[1] = 'B' which is moved to bits 8 - 15

So why does it show up BA?
 
W/O knowing some more details I'll throw this out there, primarily because we dealt with something similar when migrating a PLC5 to a ControlLogix processor. After the ControlLogix migration, string data on an older PanelView had characters which were swapped in much the same manner you are describing.

From Wikipeida

Endianness[edit]
An architecture may use "big" or "little" endianness, or both, or be configurable to use either. Little endian processors order bytes in memory with the least significant byte of a multi-byte value in the lowest-numbered memory location. Big endian architectures instead order them with the most significant byte at the lowest-numbered address. The x86 architecture as well as several 8-bit architectures are little endian. Most RISC architectures (SPARC, Power, PowerPC, MIPS, ARM) were originally big endian, but many (including ARM) are now configurable.


In my case, the PLC5 "Edian" was different than the ControlLogix "Edian". I can't recall if the PLC5 was "big"/"little" or if the ControlLogix was "big"/"little", either case they were opposite, which created the byte swap thus character swap on the PanelView.
 
The operator inputs the values into My_string from the HMI. For example: AB12. I copy this into My_Int[0] with a length of 2. So My_Int[0] bits 0-7 = A, My_Int[0] bits 8-15 = B, My_Int[1] bits 0-7 = 1 and My_Ints[1] bits 8-15 = 2. However, if I change the tag from decimal to ASCII, it shows My_Ints[0] = BA and My_Ints[1]=21. So with My_Int[0] = BA, shouldn't the value of My_Int[0] bits 0-7 = B? But that is not what it shows if I monitor the tag
 

Similar Topics

I have an IFM Efector barcode reader that is up and running. The actual code read is showing up at Data[6] via the EIP connection. I am simply...
1
Replies
1,319
Views
Hey all, it's my first post. I've been lurking a while. I've got ControlLogix L83E, Studio 5000 v32, pushing production counts to an old Modbus...
15
Replies
615
Views
A puzzle I am trying to get answers on: Communicating to an IO-Link device using Ethernet_IP running at 20 Hz using an L320ER CompactLogix...
5
Replies
297
Views
I am converting a fairly elaborate program from a SLC to Compactlogix. In the SLC, the OEM logs three process data values every 0.2 seconds during...
5
Replies
872
Views
Hi all! I'm working on an existing system at my job converting a power flex 700 to a 753 on an SLC500 over Remote I/O and have run into an issue...
2
Replies
947
Views
Top