Large Data Tables in C# PLC Blocks
Hello
I am trying to write a C# module that will handle a large table within a PLC block. It reads data from a text file (or two) and then needs to do some fairly heavy manipulating/sorting before creating an output text file.
The tables are about 40 columns of floats, ints, and strings of up to 3000 rows.
What is the best way to store this data in internal memory? I wrote my own class to serve as a single row of data but I need a fast collection. I have tried List<>, SortedList<>, arrays, intermediate text files and binary files, and hash tables, but all seem to be too much for the PLC memory to handle. Is there some other way?
Alex Hearn
Comments
Hello Alex,
I would like to help you, but I need additionall information:
AXCF 2152 has 8MB program memory and I assume it is not enough for your application. The possible way is to use the AXCF3152 Controller with 16MB program memory.
Or you can use the DataLogger Library or DataLogger FW Service to handle the data in a Datasink (.csv or SQLite). This solution requires more computing time.
Best Regards
Eduard
Hello Eduard
1. We are using the PLC 2152. We also tried the 3152 and had the same issue.
2. The input data can be static, but there will be intermediate data drawn from that data which will need to be dynamic, and then the final output data, also dynamic, will be drawn from that intermediate data. All the data is in these large, multitype tables. The application focuses on lookups from large tables, and then assembling other large tables from those lookups.
3. The calculation time can be fairly long - certainly in the order of minutes is fine. We don't have a hard requirement.
4. Do you have any detailed information or examples for the Datalogger? It was suggested to us before but it seemed too limited for our requirements.
Regards,
Alex Hearn
Hello Alex,
if you have a static data based on a function or curve, the simplest way to reduce the data, is to create a data reduced enumeration table, then you can implement a algorithm for interpolation between data points and method for data access. For floating values you can use the datatype (U)LINT (e.g. if you have a floating value 1,006 you can use 1006 (U)LINT for calculation).
The other way is to store the data in database and access to this data.
Please see the following DB-Library with example project and documentation:
https://www.plcnextstore.com/919
Or the following C++ Example project can help. The data access within a database takes place within a time window (start and end time).
https://github.com/PLCnext/PLCnext_RT_Datalogger
I would like to recommend you to divide the calculation in FB with defined duration time and execute the application in a cyclic task of 500ms-1s (deterministical and state based execution).
Best Regards
Eduard
Hi Eduard,
I am working with Alex Hearn. When I click on the link above for the DB-Library it always takes me to the PLCNext Store home page. I can't access "/919".
Is that the same as DBFL_SQL? If so, as I understand the DB itself resides somewhere else and the PLC only does access commands? Correct?
Thanks
Hello Alex,
it is not the DBFL_SQL Library, it is the DataLogger Library!
The function blocks for Data Logging are used to collect data of any data types and store into csv or binary files on the PLC.
Please try to download the Lib via following Link:
https://phoenixcontact.sharefile.eu/d-s66ea26eeb62c4cd38e70c19b426d502b
Thanks & Best Regards
Eduard
I had the same problem, and I've seen that with other PLCnext Store links on this forum. Turns out if you put a forward slash after the number, ".../919/", it works.