M340 memory area differences

suppaman

Member
Join Date
Mar 2009
Location
Italy
Posts
18
Hello everyone,

I'm pretty new to the Schneider world.

I'm trying to code on an M340 CPU and i was wondering what's the difference between %M and %MW memory areas.
I thought was something like bit/word but then I discovered that both can be write with dot notation for the bit addressing.

Thanks a lot for your support
 
%M is indeed bit memory - corresponding to classic '0X' coil addresses. Each %M is one bit.

%MW is word memory - corresponding to classic '4X' holding register addresses. Each %MW is 16 bits.

You can put a period followed by a number to with %MW variables to specify a bit. I do not understand what putting that on a %M address would accomplish.

If you are using Modicon's excellent FBD - perhaps to avoid Modicon's less than excellent LD - you may wish to use the WORD_TO_BIT instruction to pick bits out of a %MW variable.

The free PLC class outline at corsairhmi.com has more details on Modbus-compatible addressing.
 
%M is indeed bit memory - corresponding to classic '0X' coil addresses. Each %M is one bit.

%MW is word memory - corresponding to classic '4X' holding register addresses. Each %MW is 16 bits.

You can put a period followed by a number to with %MW variables to specify a bit. I do not understand what putting that on a %M address would accomplish.

If you are using Modicon's excellent FBD - perhaps to avoid Modicon's less than excellent LD - you may wish to use the WORD_TO_BIT instruction to pick bits out of a %MW variable.

The free PLC class outline at corsairhmi.com has more details on Modbus-compatible addressing.

About the %M period notation I just tried, I wasn't sure that %M area was for bit only, now that i know ofc it makes no sense.
So if I addrees MyTag as REAL to %MW10 it will go on %MW10 and %MW11 right?

I was trying to use LD, but seems like quite hard to work with (at least for me moving from Siemens TIA), I've done few test with ST, is pretty good but I couldn't understand why if there's some errore in the code the editor become extremly slow.
I'll definitly try the FBD then.

Thanks for the advices.
 
All %MW memory is single word (16-bit). Because of that your assumption is correct - that a REAL variable takes two consecutive %MW addresses. I think with the M340 the first word must have an even (not odd) %MW address. %MW10 should work for the starting address. %MW11 would not be allowed by the compiler.

This is different from the older Quantum PLCs that allowed evens or odds. I think it is a requirement of the ARM CPU that is used in the M340. The advantage over the Quantum is a great reduction in cost. There is another difference between the CPUs in the translation of %MW addresses to Modbus protocol offsets - no need to discuss that now.

Once you have spent some time with it the FBD works very well. I use it on the M340 for boolean logic work. There is an occasional concern with order of execution on instructions. The outline mentions those considerations. Like any language with any PLC the important thing is to think about the code first. Some time with pen and paper before clicking and typing.

Someone once said that LD is like trying to read a book through a keyhole. FBDs ability to flow any type of data through a connecting 'wire' and see that data in real time is one of its strong points.

LD provides a superior visualization for boolean logic, FBD provides a better visualization for data flow, SFC provides a better visualization for sequencing, and ST is best for looping. The different languages are there for valid reasons. And different manufacturer's have different strengths - consider that a company with a good ladder editor may have a poor ladder language.
 
Avoid LD. There are places in the documentation where it is described as a "legacy language". It's primary use is to allow old 984 programs to be imported. Generally, you'll want to use FBD for logic and ST for complex calculations.

%M and %MW.bit work the same within the program, but they are not the same when being accessed by a Modbus client. %M is a coil (0x). %MW is a holding register (4x). The M340 does not support Modbus bit-masked writes to holding registers. A Modbus client will not be able to write to a %MW.bit.
 
Avoid LD. There are places in the documentation where it is described as a "legacy language". It's primary use is to allow old 984 programs to be imported. Generally, you'll want to use FBD for logic and ST for complex calculations.
Thanks again, ST for function calling and math works fine, as said I'll try FBD even if I'm not familiar with that "style"

The M340 does not support Modbus bit-masked writes to holding registers. A Modbus client will not be able to write to a %MW.bit.
Interesting, I have a Siemens HMI that should be communicate via Modbus TCP.
So how I'm suppose to write/read bit on holding register from HMI at this point? o_O
 
You can always read a holding register (%MW) and extract the bits. You can always write an entire holding register with whatever bit settings you want. You cannot write individual bits to a holding register apart the whole register. If your Siemens HMI is the only device (including the M340) that writes to a holding register with bits then you are OK, but not if there are other writer's to the same holding register.
 
One interesting thing I encountered was that %M2.x and %MW2 do not seem to reference the same memory range.

Definitely blew my mind a little bit at first encounter having never worked with schneider/modicon stuff before.
 
One interesting thing I encountered was that %M2.x and %MW2 do not seem to reference the same memory range.

Definitely blew my mind a little bit at first encounter having never worked with schneider/modicon stuff before.

Same thing here... :unsure:
 
You can always read a holding register (%MW) and extract the bits. You can always write an entire holding register with whatever bit settings you want. You cannot write individual bits to a holding register apart the whole register. If your Siemens HMI is the only device (including the M340) that writes to a holding register with bits then you are OK, but not if there are other writer's to the same holding register.

The HMI is the only device, on the Modbus TCP network.
There are some Altivar on Canopen but i think that's different stuff right?
Even if I still have to manage how to communicate, but that's another issue.
 
I thought the IEC convention was %MX for bits & %MW for words
& %MD For doubles or floats.
I think that some IDE's seem to have interpreted the standards a little different.
The above makes a little more sense as the BIT var is distinguished from the word.
 
I'm not ready to agree that masked writes don't work on m340. But I'm working with the port on the 342020 cpu. Not sure about the noe and noc option cards.
 
At least it was before that you could only use FC15 and FC16 modbus writes. Not tested if it has changed to support FC22 masked write on firware upgrades.
 
So now I go one step further.
I've created an array of user defined tag and tried to address it, but I cannot understand where the system goes like the image attacched

Why the bits are not addressed with dot notation and instead two bits occupy one entire word ? Am I missing something?

UserDefineTAG.png
 
Bools in UDTs are stored as bytes.

In your program just use it as it is. UvalvoleDigitali[0].bConsensoAuto is all you need.

UDT bools are not Modbus friendly. I just put filler in my UDTs between each writeable bool and set the %MW to either 1 or 0. The read-only bools can be addressed by bits 0 and 8 within the %MW.

If you are not accessing this UDT from an external Modbus client there is no need to assign an address to it.
 

Similar Topics

Why are these things anywhere from $150 - 250? A unix bit by bit copy of the card doesn't work. Anyone smart enough to reverse engineer the...
Replies
4
Views
3,177
Hi everyone, i have another question about Modicon/Schneider PLC M340. I have a lot of motor configuration variables (with no particular address...
Replies
0
Views
1,458
I need to backup some %MWi varibales in an M340 program without stopping the PLC. Any ideas? Also what is the Save Variable attribute used for...
Replies
1
Views
2,416
Please help! The memory card was formatted by windows, PLC indicates "card err", how to restore it? Somebody has an image of a card?
Replies
1
Views
2,664
Hi Everyone, i was hoping for a little help with this module. i have data that needs to be read from a different plc through the Modbus plus...
Replies
11
Views
233
Back
Top Bottom