C# and PLC (S7-1200) Data Block Reading Error 33028

7.8k Views Asked by At

I am working on the connection between C# and a Siemens PLC (S7-1200). I've created a datablock (a.k.a. database) to which I need to read and eventually write. The connection to the PLC works, but I can't read anything from its datablock. It always give me the following error:

Error 33028 context is not supported. Step7 says: Function not implemented or error in telegram.

The number of the datablock is 311. I am starting at the first byte and I've only given up 1 as length.

I've also disabled Optimize block access, enabling does not solve this problem.

if (0 == lndConnection.connectPLC())
{
  Byte[]   bytes = new Byte[1];
  res = lndConnection.readBytes(libnodave.daveDB ,311,0, 1, bytes);
  if (res == 0)
     MessageBox.Show(lndConnection.getS32().ToString());
  else
  {
      mInt = 0;
      MessageBox.Show("error " + res + " " + libnodave.daveStrerror(res));
  }
} 

I hope somebody can help me out with the problem.

3

There are 3 best solutions below

0
On BEST ANSWER

The answer from Roatin Mart: "S7-1200 has indirect access on by default. Check if Optimised Block access is disabled."

1
On

S7-1500 implements extended communication protocol which is not supported by libnodave. It is possible though to connect and read/write global db blocks using the "old" protocol.

I have communicate successfully with both 1200 and 1500, but some additional setting plc-side are needed.

S7-1200

  1. Only global DBs can be accessed.
  2. The optimized block access must be turned off.

S7-1500

  1. Only global DBs can be accessed.
  2. The optimized block access must be turned off.
  3. The access level must be “full” for the plc.
  4. “connection mechanism” must allow GET/PUT for external partners

Details with screen-shots can be found at: http://snap7.sourceforge.net/snap7_client.html

Hope it helps! Cheers, peter

1
On

Yes, that's right. I used his method and the problem was solved