Siemens s7 driver, reading large block of data

Hello guys,
is there a way to read/write a large block of data using siemens s7 driver?

A costumer is asking me to graphically represent a layout driven by a large block of data.

I did something similar in another project where i could use OPC-UA protocol using documents with great performance, but this time i have to use siemens s7 protocol.

In my previous experience, i remember using s7 protocol in some .net projects, and i was able to read large block of data if not the entire db.

Is there any way to get the same result?

Thanks

Ignition S7 driver will group consecutive adress to minimise number of request.
Otherwise you can write a module and embed
to read block tout want:
http://snap7.sourceforge.net/moka7.html

In one of my project (in Vision 7.9) I’m using system.opc.readValues with siemens s7 driver for reading 4096 real (float) values from DB inside an old SIMATIC S7-300 CPU 315-2 PN/DP (ignition gateway and PLC are on the same local network).
I wrote a script to build the tag paths and it needs around 700 ms to read 4096 values from PLC and around 50 ms to write to a dataset memory tag. And then another 700ms to write these 4096 values to a PostgreSQL DB (which is on the same virtual machine as Ignition gateway).
Screenshot_8

Hi Anton, Thank you for your time.

Just a question for you, the paths you are submitting to the opc.readValues is simply an array of the individual tags path with the Siemens convention, or you are using a different way?

The 4096 tags you are reading are all declared inside the array you are passing to the readValues function?

I was wondering what would happen if using the Siemens convention i would ask for an entire db for example, using the opc.readValues.

Yes, paths are a list of strings. And the tags in the DB are 4096 long array.


And this is the script:

from java.lang.System import nanoTime

nano_startTime = nanoTime()
itemPaths = []
newRows = []
server = "Ignition OPC-UA Server"

#for i in range(0,404,4):	#100 tags
#for i in range(0,2052,4):	#512 tags
#for i in range(0,4100,4):	#1024 tags
#for i in range(0,8196,4):	#2048 tags
for i in range(0,16388,4):	#4096 tags
	path = "[DKC_Bulky]DB10,REAL" + str(i)
	itemPaths.append(path)
 
qualifiedValues = system.opc.readValues(server, itemPaths)
nano_endTime = nanoTime()
#print "Reading 100 tags tooks " + str((nano_endTime - nano_startTime)/1000000) + " miliseconds"
#print "Reading 512 tags tooks " + str((nano_endTime - nano_startTime)/1000000) + " miliseconds"
#print "Reading 1024 tags tooks " + str((nano_endTime - nano_startTime)/1000000) + " miliseconds"
#print "Reading 2048 tags tooks " + str((nano_endTime - nano_startTime)/1000000) + " miliseconds"
print "Reading from PLC 4096 tags took " + str((nano_endTime - nano_startTime)/1000000) + " miliseconds"
print "len(qualifiedValues)= ", len(qualifiedValues) 
nano_startTime = nanoTime()

# Generate the empty DataSet
headers = ["date", "value"]
rows = []
oneRow = [system.date.now(), 0.0]
rows.append(oneRow)
data = system.dataset.toDataSet(headers, rows)
emptydata = system.dataset.clearDataset(data)

for i in range(len(qualifiedValues)-1):
	newRows.append([qualifiedValues[i].getTimestamp(), qualifiedValues[i].getValue()])
	
emptydata = system.dataset.addRows(emptydata, newRows)

system.tag.write("[testS7OPC]data2", emptydata)
nano_endTime = nanoTime()
print "Writing 4096 values to dataset memory tag took " + str((nano_endTime - nano_startTime)/1000000) + " miliseconds"

And this is the dataSet tag Data2:

I was wondering what would happen if using the Siemens convention i would ask for an entire db for example, using the opc.readValues.

That I don’t quite understand… What do you mean “the Siemens convention”…?

Ok i understand.
I was wondering if there was a chance to force a request to a siemens PLC bypassing the Ignition s7 driver, like sending a request like [PLC]DB10 (or something else) to get the entire db as byte array.

I know for sure there the PLC know how to respond to this kind of requests as i used them in the past with s7 protocol, but is not the case.

I will try out what you suggested as performance are not bad, but i will have to check what will happen in production over an already quite busy PLC.

Thank you for your time,
have a grate day

1 Like