Words in S7 and Modicon

Johnny T

Member
Join Date
Jul 2003
Location
Fife, Scotland
Posts
642
I was recently telling an engineer about bits/bytes/words and double words in S7.

I drew the following diagram to represent a Marker Word in S7.


_______MW10________
| |
0000 0000 0000 0000
| | | |
---MB10-- ---MB11--



With M11.0 being the bit furthest on the right and M10.7 being the bit furthest on the left. I also explained about how to work out in binary the value of the word, with the Least Significant Bit being on the right and the Most Significant Bit being on the left.

He had some Modicon experience (which I don't) and said that the diagram was the same as Modicon except that in Modicon the MSB is on the right and the LSB is on the left...

Can anyone with Modicon experience confirm this? It doesn't sound right to me?

Puzzled from the UK...
 
Hello Johnny T;

This is a Big Endian/Little endian problem: byte ordering is processor dependant. For example, Intel chips are Big Endian (the order you show in your post) , Motorolla is little Endian (reversed).

Say you have a 16-bit register in your microprocessor in which you have copied the hex value F4DE:
-in an Intel chip, you will see F4DE
-in a Motorola chip, you will see DEF4
Both representing the same value, and doing calculations correctly.

the term comes from Swift's Travels of Gulliver:
Big-Endian / Little-Endian


two factions within Lilliputian society: Big-Endians break their eggs at the larger end ("the primitive way"), while the Emperor commanded all his subjects to break the smaller end. Resistance by traditionalists and their subsequent suppression by the government had resulted in civil unrest. The Big-Endian faction had the support of neighboring Blefuscu, a further source of friction between the traditional enemies. Thus Swift satirizes the suppression of Catholics that had racked England and subject nations from the reign of Henry VIII to Swift's own time.
the Emperor ... published an Edict, commanding all his Subjects, upon great Penaltys, to break the smaller End of their Eggs. The People so highly resented this Law, that our Historys tell us there have been six Rebellions raised on that account; wherein one Emperor lost his Life, and another his Crown. (I:4;4)


Consequences
for us programmers: when you exchange between a s7 CPu and a Modbus slave, you will probably have to swap the byte order of the values you recieve, so that the Siemens CPu can make sense of the slave's messages.


Google on Big Endian or Byte swap to see more details.

Hope this helsp,
Daniel Chartier
 
Just a comment

Hi,

I'm not experienced with Modicon but I have some with Telemecanique
With Telemecanique (same Schneider group with Modicon), Byte and Word order are reversed when compared with Siemens.
(This was my problem when I converted Telemecanique_premium program to S7 400)

Bit order in Byte is same
Byte and Word order are reversed:

S7: Byte1 Byte2 Byte3 Byte4

is same value in the following Telemecanique order:

Telemecanique: Byte4 Byte3 Byte2 Byte1

I hope (!) Modicon and Telemecanique are same

Duy
 
Thanks for the informative and entertaining replies... love that story about Gullivers travels!! :)


Well, that's cleared that up. I'm a Big Endian man in my thinking, but, as an understanding and compassionate person, I shall bear the Little Endian philosophy in mind in the future!

Thanks again

:)
 
Senior Technical Support Engineer

In the Modicon PLC, there are two type of programming language, one is "984 Ladder Logic Programming" and the other is "IEC 1131-3 Programming Language".
The old way of programming is the 984LL (984 Ladder Logic) which is correct, MSB bit 16 is on the right and the LSB bit 1 is on the left. Programming software used are Modsoft (DOS based) and PROWORX 32 (Window 2000/XP).
With the IEC 1131-3 standard, you will following the IEC standard with LSB bit 0 on the right and MSB bit 7 on the left. Programming software used are IEC Concept Programming Software (Windows 2000/XP) and Unity Pro (Windows 2000/XP).
S7 is following the IEC standard and most PLCs in the market are going towards IEC 61131-3 programming standard.

Johnny T said:
I was recently telling an engineer about bits/bytes/words and double words in S7.

I drew the following diagram to represent a Marker Word in S7.


_______MW10________
| |
0000 0000 0000 0000
| | | |
---MB10-- ---MB11--



With M11.0 being the bit furthest on the right and M10.7 being the bit furthest on the left. I also explained about how to work out in binary the value of the word, with the Least Significant Bit being on the right and the Most Significant Bit being on the left.

He had some Modicon experience (which I don't) and said that the diagram was the same as Modicon except that in Modicon the MSB is on the right and the LSB is on the left...

Can anyone with Modicon experience confirm this? It doesn't sound right to me?

Puzzled from the UK...
 
>This is a Big Endian/Little endian problem: byte ordering is processor
>dependant. For example, Intel chips are Big Endian (the order you show in
>your post) , Motorolla is little Endian (reversed).

Actually, Intel is Little Endian and Motorola is Big Endian.
 
Modicon LSB is on the right as stated in the first post but bites 1 through 8 are the low byte not the high byte. MODBUS and MODBUS PLUS send the high byte first.

32 bit numbers are all screwed up in modicon since it was added as an after thought. 4x1 is the least significant word and 4x2 is the most significant word. This means the bytes get sent 4x1_HI, 4x1_LO, 4x2_HI and 4x2_Lo. The true test of compatibilty is to be able to read and write 32 bit values from a Modicon PLC.
 

Similar Topics

Hi I am being given several fault words (as a DINT) from a Drive that I am receiving into a Compactlogix L33ER controller. I have a small...
Replies
12
Views
1,100
So I need to be able to give 10 people passwords to the machine and I need to make a log of when they are used. It's a Rockwell l71 processor and...
Replies
3
Views
865
The topic of reading or writing floating-point values via Modbus seems to come up regularly, and it is to my mind not that difficult. That said...
Replies
0
Views
1,352
I have a customer that has a GT1575-VNBA and I think they are using GT Designer. They have the software and program for both the HMI and the PLC...
Replies
3
Views
2,215
Hello, I am using Machine expert - basic with an M221 PLC. I have two 16 bit modbus registers coming in and I want to convert to a 32bit real...
Replies
8
Views
3,765
Back
Top Bottom