Ta strona wykorzystuje cookies. Dalsze korzystanie z serwisu oznacza zgodę na ich wykorzystanie Zamknij Więcej informacji

Support PLC Engine Collect Tablice Logiczne

Support PLC Engine Collect Tablice Logiczne

Tani PLC Engine Collect Tablice Logiczne

Za pomocą kreatorów konfiguracji można utworzyć wiele funkcji logicznych. W tym miejscu wprowadza się tylko te rzeczy, które nie są dostępne z powodu ich Prostota lub specjalność nie mają asystenta lub potrzebują zbyt wielu wejść. Jeśli chcesz zaimplementować większe zadania specjalne, WizardScript udostępnia rozszerzalny kreator.

Overview: Liczniki, numbers and times, multiple trigger, Procedury, pliku CSV, CSV file read, create structure , create structure array, decode structure array, sequence chains, program call, multiple database results, simple statistic.

Licznik czasu działa raz na sekundę i powoduje odczytanie wartości zmiennej o nazwie "Counter", następnie dodana zostaje wartość 1, a wynik jest wpisywany z powrotem do tej samej zmiennej.

Tani PLC Engine Collect simple counter
Pobierz przykład: Counter.table.

Often parts only from a number are needed.

Digits before or after the dot are created with the round element. The common rules from mathematics will be used.
Parts of numbers are results from divisions. The portent can be removed with the absolute element.
The parts of a number under 100 in a big number are removed by a divison with 100, after this multiply the result with 100.
Mostly it is the wrong way using parts of a number after calling the reinterpret for a translation into a byte array. This is possible from the technical side but complex.

Tani PLC Engine Collect number crunching
Download the example: Numbers.table.

The timestamp is delivered from the system time. This time contains date and time up to milliseconds.
This example converts the time into a string. After this with the help of the large text formatting functions: Day, month and hour will be extracted. The result will be converted into a number again. The number can be used later for other things (this simple example does not doing so).
Additionally the name of the time zone will be presented. Note that the text of the time zone is obtained from the operating system, it can vary from system to system. The system language may affect the result also.
The next value is the difference in seconds of the time zone. If you are in a time zone which knows summertime (this is true in Germany) then the difference in summer is 3600 (one hour). In winter time it becomes zero.
The offset to the Universal Time Zone UTC is the next element. In summer it is 7200s = two hours, in winter 3600s = one hour.
If yo need a consecutively time - a documentation can not have two entries with the same time - please use UTC. Otherwise in the night in fall with the time switched back will result in two times logging the same between 2 am and 3 am.

Tani PLC Engine Collect parts from the time
Download the example: DateTime.table.

Sometimes a value need to be handled if it will change, but if it does not change in a specified period it need to be handled also. This logic table is using two triggers: The value change trigger and the time trigger. The value will be handled if it is changing or after the timeout. The trigger reset will initialize the time trigger also.

Tani PLC Engine Collect multiple trigger
Download the example: ChangeOrTime.table.

Procedura (subroutine) zawiera funkcje logiczne, które mogą zostać wielokrotnie wykorzystane w tabelach logicznych.

Tani PLC Engine Collect simple counter Tani PLC Engine Collect simple counter Pobierz przykład: Subroutine.table, SubroutineUsage.table.

CSV (ang. comma-separated values, wartości rozdzielone przecinkiem) jest formatem przechowywania danych w plikach tekstowych. Plik taki posiada w wierszach wiele przylegajacych do siebie wartości rozdzielanych odpowiednim separatorem, a każdy wiersz jest zakończony znakiem końca linii.
Podgląd i edycja plików CSV przez użytkownika jest stosunkowo prosta dzięki oprogramowaniu Microsoft Excel, OpenOffice Calc, czy prostych edytorów tekstowych.

Przykładowy plik dodaje linię po każdej zmianie wartości 1/s dodając stempel czasu.
W tym przykładzie wykorzystano średnik jako separator i znak końca linii.

Tani PLC Engine Collect simple counter
Pobierz przykład: WriteCSV.table.

This example checks for new files beginning with the name prefix of "Datafile*.*". If this becomes true the file content will be read.
It will be assumed that the file content is in csv file style and will contain three numbers. The numbers are read from the file content and will be written into the plant. On success the file will be removed.
On case of a PLC writing error an error bit will be set.
If all of this will be programmed in one big logoc table it will work - but it is not easily to read and understand.

Tani PLC Engine Collect CSV read
Download the example: ReadCSV.table.

Such logic can be better realized in a sequence chain. This will require some local variables, but it is much easier to start up in the plant.
One step checks for the new file with the correct name prefix. The name will be written in a variable, other files are ignored.
The next step reads the file, decodes its content and writes the data into the plant. The file name is taken from the local vaiable.
The last step will remove the file if no error did occur.
Any error management can be realized in more steps. Possibly it will be waited here for an user reaction. The file name can be displayed to the user. In this example the error steps are mostly empty, they only are switching to the next step.

Tani PLC Engine Collect CSV read step wait file
Tani PLC Engine Collect CSV read step read file
Tani PLC Engine Collect CSV read step error entry
Tani PLC Engine Collect CSV read step error management
Tani PLC Engine Collect CSV read step remove file
Download the example: ReadCSVChain.table.

If the implementation uses subroutines it increases the view of sight. So the file content decoding and the delivering of the results can be realized in a subroutine. The logic can be used in multiple logic tables

The ProducedPieces counter is read. If its value will change the new value is given into the structure Plant statistics. Additionally the current timestamp is added. Additionally the good pieces value is calculated and written into the structure. The created structure is stored.

Tani PLC Engine Collect structure creation
Beispiel Logiktabelle herunterladen: StructureCreate.table.
Download the example: StructureCreate.table.

The opposite function for the structure creation exists also, it separates the single values back from a structure.
If stacked structures are used the structure creation or structure decode need to be used more than once.

Structures can be more complex. This example fills a structure containing a list of plant stati. The result will be stored in a variable
Tani PLC Engine Collect structure array create
Download the example: StructureArrayCreate.table.

This example gets some values back from the structure creation array example above.
Tani PLC Engine Collect structure array decode
Download the example: StructureArrayDecode.table.

Sequence chains are simplifying processes. In a sequence chain one step is active only.
This example uses the bit trigger vor handling the result of comparisons.
All steps of a sequence chain need to me in the same group. Other groups con contain more sequence chains.

The initial step, mostly this is the first step. The prerequisites of the sequence chain are initialized here.
Tani PLC Engine Collect sequence chain init
Here it will be waited for the machine becoming ready.
Tani PLC Engine Collect sequence chain wait ready
Now the machine does its job and handles the product. This example waits for the machine status becoming success only. Normally here and in further steps the machine is handled.
Tani PLC Engine Collect sequence chain work
The last step combines all paths together again. Sometomes the counter of produced pieces is incremented here.
Tani PLC Engine Collect sequence chain last step
It can be usefully havong an error step. This exampe does nothing special for errors.
Download the example: SimpleSequenceChain.table.

In the logic tables external programs can be called. Mostly this are scripts (called "Batch" under Windows). The external programs are called at system level.
Parameters can be given to the called program. On standard no return data can be handled. So this example uses a file for returning data from the called program. But other mechanism can be used also: Sockets, OPC UA and more.
A simple script is called. Two parameters are handled - a text and a filename. The script writes something into the file. After the program returns the logic table reads the content of the file.
In this logic test table the given filename is for a Linux example. On Windows the file name example is c:\users\public\documents\tani\scriptreturndata.txt
Put the script file to a location which can be reaced by PLC Engine Collect. On Linux this is /etc/Tani, under Windows c:\users\public\documents\tani\

Tani PLC Engine Collect script call
Download the example: ScriptCall.table.
Download the scripts for Windows and Linux.

A database select can return more than one result. This example is showing a handling of two results. The number of results is checked, so the table will continue if no or one result only are returned.
On handle multiple results it may be more handy using sequence chains. Within this the saved result counter will be counted down. The result counter can be used as an array index also.
The error handling can be done in a specific step.

Tani PLC Engine Collect multiple database results
Download the example: MultipleDatabaseResults.table.

A test logic table generates some test data and puts them into a database. This is realized with a minute counter which counts from 0 to 40.
The real statistic calculation uses a bigger database call. This call is something more complex, it need to be entered as the true database call.
INSERT INTO `hour_values` (`timestamp`, `value_avg`, `value_min`, `value_max`) SELECT DATE_SUB(DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"), INTERVAL 1 HOUR), AVG(`value`), MIN(`value`), MAX(`value`) FROM `minute_values` WHERE `timestamp` >= DATE_SUB(DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"), INTERVAL 1 HOUR) AND `timestamp` < DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00");
Such more complex database things can be realized as a stored procedure in the database also. This example calls the database call directly.
The database call will be called in the first minute after a new hour. This is done by reading the system time, convert it into a string. Then the minute value will be cutted out. Compared to 01 the trigger is made.
The call will read the values from the collecting database table from the last hour. Then the minimal, maximal and average value will be calculated. The result will be written in another database table. Databases are offering many functions for calculations.
If more statistics are needed as week or month overviews more logic tables can generate them. This can be done directly in this database call also. But for saving calculation time this schould be done further logic tables are the better solution.

First the dummy for the generation of test statistic data.
Tani PLC Engine Collect simple statistic generate test data
Now the logic table which will calculate the statistics. This example is made for MySql/Mariadb.
Tani PLC Engine Collect simple statistic calculation
Download the example: CollectDataOverTime.table.