Collect process data continuously

Hi there,
for me, working with a FLEXY is new.
I want to collect tags with OPC UA and
read with FTP.
Sending by email would also be of interest.
Which instructions would be relevant for this topic?
The data structure is very deep.Array

greetings
Michael

Hi @mic

For reading tags with OPCUA, you’ll want to take a look here:

Can you explain what you’re trying to do by read with FTP? Are you going to try and grab historical tag info? Instantaneous values? Real-time data?

For sending emails I made a user guide:

Sending Emails with a Flexy.docx (433.3 KB)

Hi @Tim_hms

I want to record process data and product data in a time-controlled way, i.e. 3 values with 60 points in real time. After that, various product data will be added.
The customer should be able to retrieve the data weekly as “.csv” (e.g. via FTP or Email).

I’ve already found something: " HOW TO: Event driven historical logging".
Could I start with this approach?

Greetings Michael

Hi Michael,

You could do it based off of Jordan’s code there, it might be easier just to setup the logging interval based off of this section in the tag setup though:

If you’re looking at historical logging, there are two options available without having to do anything in the BASIC IDE.

  • With Deadband logging, this allows you to set a change threshold to log data. If for example you set your deadband to 2, the value will only be logged if it notices a change of at least 2.

  • If you use Real Time Logging, then this lets you choose how often you want your tickets to log based on a time interval in seconds.

  • If you want to use Real Time Logging, this data is temporarilly stored with a FIFO format. You can choose the amount of recent time you want to be logged as well as the logging interval for that time period. By default you’re set to get 60 logged points over the course of 600 seconds.

The easiest way to send out files as a .csv would be to send out emails with an EBD attachment like this:

https://ewonsupport.biz/ebd/

$dtHL$ftT$fnRecent_Data.csv

This would grab all of your historical data, set the file type to be text and write it as a CSV file. (Note, our CSV files are actually semicolon delimited instead of the standard comma)

Hi @Tim_hms ,
thank you for the suggestions.

I’ve tried it before:

Cyclic Section:

EnableLogging:
//Enable Logging
IF(Trigger@ = 1) THEN
SETSYS TAG, “Load”, “Leistung”
SETSYS TAG, “LogEnabled”,1
SETSYS TAG, “SAVE”
SETSYS TAG, “Load”, “Spannung”
SETSYS TAG, “LogEnabled”,1
SETSYS TAG, “SAVE”
SETSYS TAG, “Load”, “Frequenz”
SETSYS TAG, “LogEnabled”,1
SETSYS TAG, “SAVE”
PRINT “Logging Enabled Successfully”
ENDIF
//Disable Logging
IF(Trigger@ = 0) THEN
SETSYS TAG, “Load”, “Leistung”
SETSYS TAG, “LogEnabled”,0
SETSYS TAG, “SAVE”
SETSYS TAG, “Load”, “Spannung”
SETSYS TAG, “LogEnabled”,0
SETSYS TAG, “SAVE”
SETSYS TAG, “Load”, “Frequenz”
SETSYS TAG, “LogEnabled”,0
SETSYS TAG, “SAVE”
PRINT “Logging Disabled Successfully”
ENDIF

Function write_data()

T$ = TIME$ // grabs the current time
$Date$ = T$ (4 To 5) + “" + T$ (1 TO 2) + "” + T$ (7 TO 10) + “" + T$(12 To 13) + "” + T$(15 To 16) + “" + T$(18 To 19) // puts the time into this format MMDDYYYY HHMMSS
$CustomFileName$ = "Prozess_Log
” + $Date$ //names the file “Historical_Log_” followed by the current time
$FileName$ = “/usr/” + $CustomFileName$ + “.csv” //writes it into the usr directory and writes it as a csv file
$EBD$ = “$dtHL$ftT$st_s120$et_s0” //dtHL is historical logs for all tags, ftT is saying its a text filetype st_m10 means it’s grabbing all the data from 10 minutes ago
// et_m0 means that it’s going from 10 minutes ago to the current time.
// to modify what is being grabbed please visit: https://ewonsupport.biz/ebd/
Print $FileName$ // just says the current name of the file
WriteEBD $EBD$,$FileName$ // writes the csv to the sd card
Print “Historical data written” // just a check to see that it made it to this step and lets you know that it performed the writeebd

Endfn

Init Section:

ONCHANGE “Trigger”, “Goto EnableLogging”
Tset 1,600 //timer set for 600 seconds
Ontimer 1, “@write_data” /

There are no more variable names in the generated “.csv” file.
How can I use the “TagID” before the file creation
replace it with the variable name?

Greetings Michael

with eWon unfortunately you can’t use Array, you must define a single Tag for each array element

Just as a warning, we strongly recommend against coding in the cyclic section if possible. That section of code will run every processor cycle on the device and may cause issues like unexpected reboots.

You should be able to do the same thing with an Onchange function in the Init section for the trigger tag.

Hi @iw3bti1
that I can’t use an array, I’ve already been told. Thanks for the tip.

Greetings Michael

Hi @Tim_hms
I have now copied the code into the “Init section”.
Now it will run more stable.
On my previous question:
Where are the “tag IDs” assigned and can they be replaced by the variable names?

Greetings Michael

Hi @mic

tag IDs are assigned when a tag is first created and cannot be changed. You can see what your tag IDs are in the Var_lst.txt or Var_lst.csv files hosted on the flexy. It will be the first column in the semicolon delimited file. Unfortunately you cannot change a tag ID easily.

image

As an example in the image above we have the tag str with the tag ID of 1. If we were to delete the tag str, this does not mean that tag ID 1 is open. Even if we were to add back the exact same tag information after deleting the str tag, it will show up with a new tag id.

image

What are you trying to do with these tag IDs?

Hi @Tim_hsc

I just want to use the variable names to get the end customer a “finished” CSV file. Nothing more.

Thank you for your help so far.

Today I can’t test anything anymore.

Greetings Michael

You could create a custom CSV file if there’s a specific format you’re looking for. Here’s an example of one that was done in the past:

custom_historical_log_example.txt (2.4 KB)

Hello Tim_hms,

We were able to use your example as a template.
How can I read out a string variable?
I can’t find a command or an example right?
I would like to integrate my part number into the file name, but reading out the variable I created as a string leads to errors.

Greetings Michael

I think you should be able to include a string by removing the STR$ before your string.

Hi @Tim_hms
Thank you
it worked :laughing:

1 Like

Hi Michael,

Glad to hear you got it working!