address manipulation in STEP7

Pandiani

Lifetime Supporting Member
Join Date
Apr 2005
Location
Tz
Posts
718
Hello guys,
I always used memory address like this:
MW1, MW3, MW5...
since MW1 occupies 2 bytes I thought that next free is MW3. Now I found and opened one plc program and there I saw MW1 nad MW2. I suspect this means overlap. Can you confirm this?
Thanks
 
sure.... mw is word, that mean two bytes ... MW2 just saying Word starting at adress 2.0
 
byte order in accu

| MBO | MB1 | MB2 | MB3...
|----MW0----|----MW2----|
| MB0 |----MW1----|

| DBB0 | DBB1 | DBB2 | DBB3 | DBB4..
|-----------DBD0------------|

Is it going so that DBX0.7 is most left in The DBD0 ?
 
OK guys, thaks for replies, I want to be sure about one thing:
Is using addresses MW1 and MW2 good or not? I suspect that using MW1 and MW2 will cause overlap that might cause unpredictible behavior. If I use MW1, next that is free in MW3 not MW2 since MW1 occupies two bytes 1.0 and 2.0, so next available is 3.0. Am I right?
 
Accessing a word on an odd boundary requires two fetches so the fetching of data is twice as slow.

Hi Peter, Is this why the LAD/FBD/STL editor always starts the next address after a STRUCT / WORD / DWORD in a Datablock on an even address?

This makes interesting reading for someone like me

Thanks
STL
 
Further to Peter's comment above, it's worth getting used to starting data of word width or greater at the word boundaries as this is how the data block editor in STEP 7 will allocate them.

(OOPS...cross-posted with STL)
 
STL??? said:
Hi Peter, Is this why the LAD/FBD/STL editor always starts the next address after a STRUCT / WORD / DWORD in a Datablock on an even address?
Most likely. However, I don't pretend to know someone else's thought process.

When programming in C one must always be careful how data in structures are organized. Every once in a while Microsoft uses a PACKED structure which means the data is crammed together without thought of word or dword alignment.

Communication protocols are also a problem. Protocols such a Modbus RTU did not make sure all the word fields are on even addresses. This makes processing the packets harder.

All of this is harder yet when you are using a DSP. Our DSP has only 32 bit data. It can not fetch anything but 32 bits at a time. Bytes, words, dwords are all 32 bits. The C sizeof function always return 1 for sizeof(BYTE), sizeof(WORD) and sizeof(DWORD). Now imagine talking to a byte oriented machine using protocol such as DF1 or Modbus. It is a nightmare shifting bytes around and getting fields lined up.

I did an 8086 project back in the 80's. I had the data base all laid out on even word boundaries. The program ran well. Just for kicks I added 1 dummy byte to the beginning of the data base so the rest of the data base was aligned on odd byte boundaries. The program did not work at all once it was in operatons The system was too slow to processes the interrpts faster than what they came in. It was educational. I removed the dummy byte at the head of the data base and recompiled and downloaded. Everything ran smoothly again. It is good to have some time to experiment.
 
Peter Nachtwey said:
2. Accessing a word on an odd boundary requires two fetches so the fetching of data is twice as slow.
Does that mean that MW0 is faster than MW1 or what?
 

Similar Topics

Hi, I wanted to ask is there a way to have a visibility expression use the IP address of the HMI (Dynics, not PV) to show certain elements? The...
Replies
3
Views
166
Hello. I have a few machines that use Kinetix 300 (each machine has two drives). Both drives on one of the machine keep losing IP address. They...
Replies
2
Views
92
Hi Guys, Is it okay to have Redundancy ControlLogix Processor IP address set to DHCP? I had Static IP address on it but removed it via RSLinx...
Replies
3
Views
224
Hi everybody, I have DELTA PLC DVP-32ES and I have make a simple project in WPLSoft. using the input X0 to switch ON the output Y0 and using the...
Replies
0
Views
154
Kindly, I am trying to do some Modbus Rtu communication between a 1214C Siemens plc and the following slaves. ( Schneider PM5110 meter , Socomec...
Replies
4
Views
243
Back
Top Bottom