byte Swap

sirhiss2

Member
Join Date
Oct 2003
Posts
109
Hi guys, I'm trying to write a manual for an introductory plc couse. (using S7-315-2dp plc's). Right now I want to explain Byte Swap when using word addresses. I think I got myselef confused. :rolleyes:
Take a look at what I have so far. Any helpful suggestions are appreciated. Maybe you know of a beter way of explaining this.
attached are screen shots of what I have so far:




Thanks for the help.
 
This is not what I was thinking would happen.
How do you post images ie. screen shots?
I've seen it done before so it must be possible.
 
Hello Sirhiss;
Use the "Attach file" section at the bottom of the text box; you can use the "Browse" button to select the attachment.
Hope this helps,
Daniel Chartier
 
I've tried that before.
I want to attach 3 images can this be done?
If not I will reply 3 times with the attachments.
Thanks
 
Well, the endian ordering (byte ordering) of a system is determined by the processor used. Endian ordering of a communications link is usually defined by the protocol. Endian ordering of file data is defined by the storage method.

In all cases I can think of, when displayed via any editor, looking at a byte, the right-most bit is the least significant (though I remember something odd about Simatic/TI 505's).

"Little Endian" notation means that in actual physical memory, the least significant BYTE is first, so for a word:

WORD1
byte 0.......byte 1
msb... lsb msb...lsb

To get the unsigned value for the word above, it is Byte0 + Byte1*256.

"Big Endian" notation means that in actual physical memory, the MOST significant BYTE is first, so for the same word:

WORD1
byte 1.......byte 0
msb... lsb msb...lsb

To get the unsigned value for the word above, it is Byte0*256 + Byte1.

For more, google on "Big Endian", or "Endian notation"

Good Luck.
 
Don't confuse MSB / LSB, which is a strictly defined mathematical concept, with the naming or numbering of bits in a word.

Rdrast's reference to TI505 is a good example of this. In a 16-bit word (TI was never byte-oriented), the names used to reference each of the bits in the word went, reading from left to right, 1, 2, 3, 4, ..., 14, 15, 16. This was seen as 'natural' in the sense that we read left to right.

However, the MSB was still the left-most bit in the word, and the LSB was still the right-most bit in the word. So MSB was 1 and LSB was 16.
If you were only allowed to alter the state of one bit in the word, which one would have the most effect and which one would have the least effect on the value of the word as whole? In other words, which is the most significant bit and which is the least significant bit?

You can name the bits of a word any way you want 1..16, 15..0, 0..15, A..P, but in most numbering systems that doesn't alter the MSB / LSB positions.

Ken.
 
I think I know what you are talking about.
Not to sure about the "Little Endian" Guy your talking about. :unsure:
Without getting to technical, is what I have written OK to put in the manual or do I have to change anything?
I'm trying to develop this training course for Construction Electricians. Not much Industrial Background as far as Motor controls or electronics are concerned. I have to keep it as simple as possible. Do you guys know of a better way of explaining byte swap?

Thanks

Terry
 
This may help. It is the help from an Omron CJ1 for the byte swap command.
 
Sirhiss

I've just looked again at your diagrams 2 and 3 and they don't seem to tie in with my experience of the S7-300 you refer to in the text!

In Siemens S7 I've always seen -

Word 32 consists of byte 32 + byte 33 (in that order)
Word 36 consists of byte 36 + byte 37 (in that order)

So moving Word 32 to Word 36 doesn't do any byte swapping, shifting etc. It just copies the value of one 16-bit pattern to the new location.

You're completely confusing things by drawing
Word 32 consisting of byte 33 + byte 32 in that order.

Regards

Ken
 

Similar Topics

I have a C-More HMI that changes my PLC String from "Machine Status" to "aMhcni etStasu" . There is an option with other objects that have string...
Replies
15
Views
3,464
I am writing software for a system(*) that has the following data flow 4-20mA Sensor => Siemens AI 8xU/I/RTD/TC ST card Siemens AI 8xU/I/RTD/TC...
Replies
16
Views
6,583
Good Morning, I'm using RS Logix 5000 to program an Allen-Bradley 1769-QBFC1B Version 20.12 and want to use the Byte Swap Instruction (SWPB)...
Replies
7
Views
4,950
I ran into a situation where some devices I use display String bytes in a swapped order as they are stored in my PLC (CompactLogix). I thought it...
Replies
3
Views
3,842
Hi guys I'm having some weird data conversion issue over modbus happening. And I found a post here before that is similar to what I'm seeing but...
Replies
6
Views
7,170
Back
Top Bottom