-1

Is there any way to read the DB data from its variable(Name) only in C# ? Consider SIMATIC S7 PLC 1200 E.g. I want to read a data from DB where i don't know the address(offset), i only know the DB number,symbolic name and data type. For reference please see the following picture.

enter image description here

I have already made the working connection via Sharp7(Non-Optimized DB method) but i always need a address. I have also looked for some other solutions like,

  1. "S7connector" by Rothenbacher GmbH
  2. s7.Net | S7netplus

but it doesn't seems to work for me. I also don't know if this is possible , as i heard somewhere that PLC only takes the addresses but not the variable names.

All the comments are highly appriated.

KhanBaba
  • 99
  • 1
  • 1
  • 7
  • You are reading from a communication interface. I've never used an S7, but people have done so where I work. This question is better answered by a Snap7 forum. You are not reading from a database, but a hardware interface. So I'm not sure why you are using a DB method. – jdweng Feb 25 '21 at 17:13
  • According to [Manual](http://snap7.sourceforge.net/sharp7.html) i have to first read all the bytes(Data) from PLC.DB `public int DBGet(int DBNumber, byte[] usrData, ref int Size) ` and then call the native sharp7 method which covert that byte to my Datatype i.e. (int, float and etc) `S7.GetRealAt(Buffer, offsetPosition); ` . I have checked the manual thoroughly and it seems like it is not possible. There is a new update that SIMATIC S7 1200 and 1500 stores variable name in CPU while lower versions only accept the address and data. What is your suggestion to use? – KhanBaba Feb 26 '21 at 07:57
  • Look at WriteArea/ReadArea. – jdweng Feb 26 '21 at 11:22
  • Already, referred to ReadArea/WriteArea but so far no luck. AS all the data packets are strickly depends on PDU, where they only refer to data(S7Consts.S7AreaPE| Process Inputs.) Via sharp7 or another it seems not possible. I might move to OPC UA. – KhanBaba Mar 01 '21 at 17:07
  • The name of the area is in the "S7BlockInfo struct". So you first have to search the "S7BlockInfo struct" – jdweng Mar 01 '21 at 21:47
  • Thanks for reply. `S7BlockInfo` can be read from `GetAgBlockInfo` or `GetPgBlockInfo`. Where `GetAgBlockInfo` will not [work](http://snap7.sourceforge.net/snap7_client.html#target_compatibility) for s71200/1500 and `GetPgBlockInfo` is not implemented in sharp7. Meanwhile i have asked the client to just export a excel file of a db then i will read that and learn my application for offset and Symbolic name. Thanks for your help for exploring idea. – KhanBaba Mar 03 '21 at 11:23

1 Answers1

0

Use OPCUA instead. If you're using s71200 or s71500 then you have limited possibilities. Also, it uses disabled optimized DB so it is not possible to read DB variable via symbolic name.

enter image description here

KhanBaba
  • 99
  • 1
  • 1
  • 7