I was wondering if there is any way to read and write data from the PLC tags folder using a custom c# application?
I have tried using Snap7 which is great tool to use and actually got it working, but only reading and writing data blocks and not tags which I am willing to achieve. Would someone please show me an exmaple on how to do so. Is possible using Snap7?
Last edit: Sev 2016-03-01
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Using ReadArea() and WriteArea() you can read/write also Merkers and I/O.
You cannot do it "by name" but only by Index/Address, the same that you would do using a non siemens-integrated OPC.
Please refer to pag.104 of the reference manual and also to pag.34 if you are using S71200/1500.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you for answering! It would be alright if I just could read the address. Not interested in names. Would you please explain what Merkers are? I can't find it anywhere. I have read the manual, but wasn't able to understand how to use it. Sorry I'm new to PLC world :(
Thank you.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Davide, Thanks again for taking time and explaining it. The CLI_ReadArea method takes 6 arguments.
public int ReadArea(int Area, int DBNumber, int Start, int Amount, int WordLen, byte[] Buffer);
So in case of this example (%I1.0) I might do sometihing like this.
res =client.ReadArea(8,1,8,0, s7client.S7WBit, buffer);
Would you please verify it for me, please.
I have spend 3 hours reading through the manules, I believe I have now far beter understanding than before. Some of the concepts are still fresh to me and hard to grasp. Please forgive me if I am asking stuiped questions.
Last edit: Sev 2016-03-10
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I gave this a try, but couldn't get it working. I have tried python snap7, I was able to get it working, but I might have missed a minor thing which I am not gettting it working using C#.
I have also some questions regarding the read/write access to S7 1500.
What happens when writing a bit (Bool in S7), are the other bits from the DWORD masked to avoid thate they are overwritten?
And is there any possibility to access (read) the S7 programmable alarms?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you use WriteArea with S7Client.S7WLBit parameter, only that bit si affected, the other (into the same byte/word/dword) are untouched.
no way for alarms, you have to first move them into a DB.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all,
I was wondering if there is any way to read and write data from the PLC tags folder using a custom c# application?

I have tried using Snap7 which is great tool to use and actually got it working, but only reading and writing data blocks and not tags which I am willing to achieve. Would someone please show me an exmaple on how to do so. Is possible using Snap7?
Last edit: Sev 2016-03-01
Any Idea's regarding this subject? I read in order to do this, I might need to setup OPC server which extracts values (I/O) en set and get as well.
I greatly appreciate any help and assistance, and sorry if I've missed any obvious guides that cover this subject.
Using ReadArea() and WriteArea() you can read/write also Merkers and I/O.
You cannot do it "by name" but only by Index/Address, the same that you would do using a non siemens-integrated OPC.
Please refer to pag.104 of the reference manual and also to pag.34 if you are using S71200/1500.
Thank you for answering! It would be alright if I just could read the address. Not interested in names. Would you please explain what Merkers are? I can't find it anywhere. I have read the manual, but wasn't able to understand how to use it. Sorry I'm new to PLC world :(
Thank you.
I have managed to understand what merkers are. But what about reading & writing Input and outputs? such as those.
Last edit: Sev 2016-03-08
%M0.3 is a Merker Bit whose address (index) is 3
%M4.3 index is 35 (48+3)
%I1.0 is a digital input whose index is 8 (18+0)
To read bits you need ReadArea passing S7WLBit as wordlength and their index as address (the bits are indexed).
To read analog inputs you need to address their word image into the IPI (process images).
Please read the manuals.
Davide, Thanks again for taking time and explaining it. The CLI_ReadArea method takes 6 arguments.
public int ReadArea(int Area, int DBNumber, int Start, int Amount, int WordLen, byte[] Buffer);
So in case of this example (%I1.0) I might do sometihing like this.
res =client.ReadArea(8,1,8,0, s7client.S7WBit, buffer);
Would you please verify it for me, please.
I have spend 3 hours reading through the manules, I believe I have now far beter understanding than before. Some of the concepts are still fresh to me and hard to grasp. Please forgive me if I am asking stuiped questions.
Last edit: Sev 2016-03-10
res =client.ReadArea(S7client.S7AreaPE,0,8,1, S7client.S7WBit, buffer);
Davide, Thanks again for helping out.
I gave this a try, but couldn't get it working. I have tried python snap7, I was able to get it working, but I might have missed a minor thing which I am not gettting it working using C#.

Any idea's?
Last edit: Sev 2016-03-16
If you want to write a variable into the PLC you should first write something into it :D
As far I see buffer is unassigned and can contain everything.
Oeps :| Thanks a lot Davide. I got it working :-)
I have also some questions regarding the read/write access to S7 1500.
What happens when writing a bit (Bool in S7), are the other bits from the DWORD masked to avoid thate they are overwritten?
And is there any possibility to access (read) the S7 programmable alarms?
If you use WriteArea with S7Client.S7WLBit parameter, only that bit si affected, the other (into the same byte/word/dword) are untouched.
no way for alarms, you have to first move them into a DB.
Thanks for the information.
Is it possible to get a list with all DataBlocks from a S7 1500 (a list of S7BlockInfo structures) ?
No, it belogns to extended protocol, not covered by snap7, see:
http://snap7.sourceforge.net/snap7_client.html#target_compatibility