Logging a counter value to a batch name in siemens TIA Portal

989 Views Asked by At

I need to create a program for 1214 PLC in TIA Portal and a Comfort HMI that counts several products using a count up and stores that value to a specific batch name.

For every new batch, the operator would enter a new batch name, and the counter will count the products for that specific batch.

The count needs to be displayed on the HMI screen along with the history of batches and the associated final count number.

So basically, I need a way to attach a name (batch_id) to a final count and log that pair for later reference.

Can someone give me some advice as to how I would do that?

To clarify, I need help with storing and displaying the counter value and batch names, not with the counting itself.

I appreciate any help you can provide.

1

There are 1 best solutions below

0
Cliff Pennalligen On

There are a few ways to do this (yes, you can use PLC data logs and no they don't have to create a separate file for each batch), but I am posting here what I would do, because it's convenient for data backups, I have taken this approach before, and know it works.

Write the count value (generated in the PLC), the batch value and the timestamp to a CSV file on a USB drive inserted into the Comfort HMI, using VBScripts on the HMI.
Split the files regularly - e.g. daily, weekly or monthly, to minimize the risk of any single file becoming corrupt and you losing the data. More detail follows.

Data Storage:

  1. Count is calculated in the PLC. Batch ID and timestamp can be stored in the PLC (if you want it to be retentive after a power cut), or in the HMI.
  2. You will have Comfort HMI tags representing each of these three values. Once a batch is complete, call a VB script that writes the values of these values to CSV file. There are application examples and forum entries on SIOS about this.

Data display as a table:

  1. Read the CSV file values according to your filter criteria (day, time range, batch ID, batch ID range, etc) using a VB script. Write to internal HMI tags.
  2. Display these internal HMI tags as IO fields on a Comfort panel screen. This is your custom-built table and yes it's the only way to do it unless you want to create a custom control and install it on the panel.

Backing up:

  1. Disable logging and check USB is not in use using a script, e.g. this: https://support.industry.siemens.com/cs/document/89855157
  2. Remove the USB, copy the files, re-insert it and activate logging again. (you implement the 'disable' and 'activate' logging features, e.g. using an internal BOOL tag that prevents a script from executing).

There is a lot of info on SIOS about these topics, as Application Examples, FAQs and forum entries. support.industry.siemens.com

The PLC log method works, but data backup and especially display can become a pain.