PLC Web Server Data Read Performance

Hello Second Level,

I am currently working on a customer project where we are using the integrated web server on PLC. The web server reads data from the PLC using the PV_Access.js file along with HTML.

Our requirement is to read a larger amount of data in less time. At the moment, reading 100 data points from an array in the PLC takes more than 15 seconds, which is too slow for our application. We have observed that reducing the data length decreases the response time, indicating that the data volume significantly impacts performance.

Thanks,
Kishan Koriya

I guess there is not that much you can tweak here. Does it make a difference when you put all the data into one array and then only read this one array like buffer?

Just out of curiosity, there are many ways to get data out of the PLC. Why did you choose the web server?

Hi,

I checked th PV_Access.js demo and saw that it uses the goform/ReadWrite asp webservice.
This webservice supports up to 10 variables per call, so could try to read more then one value per webservice request.

To use more then one, you have to use the name and value tags in your request with increasing numbers when building your webservice request. For reading the first 10 array elements of “myVar” with one call, for example the request for reading could be build like this (only an example. not the whole HTML GET/POST request):

redirect=target.html&variable=myVar[0]&value=none&read=1&variable1=myVar[1]&value1=none&read=1&variable2=myVar[2]&value2=none&read=1& … … … … &variable9=myVar[9]&value9=none&read=1

A second possiblity could be wrting a own backend webservice using AsHTTP library. But then you aren’t using goform/ReadWrite anymore but have to build your webservice response on your own inside a task. It’s no “rocket science”, but some work to do of course :wink:
I personally prefer using own webservices, to keep the data that is accessible via webservice under my own control.

Hope that helps a bit,
best regards!

Thanks for reply,

We already done small data handling using Goform for that Customer, so we work on that further.

Thanks You.

Thanks for Reply,

I will check that.

Thank You.

Hi @koriyak,

In my experience, the following procedure gives the best performance:

1.) strictly separate static content and dynamic data. Do not load complete HTML pages.

<!DOCTYPE html>
<html lang="en">

<head>
<title>title</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="script.js"></script>
</head>

<body>
    <h1>Hello, World</h1>
    <div id="row1"></div>
    <div id="row2"></div>    
    <div id="row3"></div>    
    <div id="row4"></div> 
    <div id="row5"></div>
</body>

</html>

2.) create an ASP page with JSON data by usage of ‘ReadPLC’ Tags containing your variablenames. Remove unused blanks etc.

[
	"<%ReadPLC("Program:array[0]");%>",	
	"<%ReadPLC("Program:array[1]");%>",	
	"<%ReadPLC("Program:array[2]");%>",	
       ....
	"<%ReadPLC("Program:array[98]");%>",
	"<%ReadPLC("Program:array[99]");%>"	
]

3.) use plain fetch() to retrieve the data. Afterwards store the dynamic data in the static HMTL


function cyclicFetch(url, interval) {
    function fetchData() {
        fetch(url)
            .then(response => response.json())
            .then(data => {
                let i = 0
                for (let row = 1; row <= 5; row++) {
                    let text = '';
                    for( let col = 0; col < 20; col++ ){
                        text = text + data[i] + ' ';
                        i++;
                    }
                    document.getElementById(`row${row}`).innerHTML = text;
                }
                //content.innerText = data;
                setTimeout(fetchData, interval);
            })
            .catch(error => console.error('Error:', error));
    }

    fetchData();
}

I tried this on a 4PPC30 with 200ms refresh rate and it took < 80ms to get an array of 100 INT on a local network:

web.zip (1.3 KB)

Thanks for Reply,

I will check that.

Thank You.