Beijer ELECTRONICS SER0002 Fast Logging FB CODESYS Library
Function and area of use
- This document explains the CODESYS library for fast logging.
- Target device: X2 / BoX2 control series, with embedded CODESYS runtime.
About this document
This quick start document should not be considered as a complete manual. It is an aid to be able to startup a normal application quickly and easily.
Copyright © Beijer Electronics, 2022
This documentation (below referred to as ‘the material’) is the property of Beijer Electronics. The holder or user has a non-exclusive right to use the material. The holder is not allowed to distribute the material to anyone outside his/her organization except in cases where the material is part of a system that is supplied by the holder to his/her customer. The material may only be used with products or software supplied by Beijer Electronics. Beijer Electronics assumes no responsibility for any defects in the material, or for any consequences that might arise from the use of the material. It is the responsibility of the holder to ensure that any systems, for whatever applications, which is based on or includes the material (whether in its entirety or in parts), meets the expected properties or functional requirements. Beijer Electronics has no obligation to supply the holder with updated versions.
Use the following hardware, software, drivers and utilities in order to obtain a stable application:
- In this document we have used following software and hardware
- BCS Tools 3.34 or CODESYS 3.5 SP13 patch 3
- X2 control and BoX2 control devices
- For further information refer to
- CODESYS online help
- Installation manual X2 control (MAxx202)
- Beijer Electronics knowledge database, HelpOnline
This document and other quick start documents can be obtained from our homepage.
Please use the address support.europe@beijerelectronics.com for feedback.
Datalogging with CODESYS function blocks
- This library is compatible with X2 Control and BoX2 Control devices (DeviceId 0x1024)
- This library simplifies the solution to achive 1ms logging.
- Upto 10 REALs can be logged at a rate as low as 1ms. The library creates a CSV file that can be written to USB, SD or locally (to the FTP area of the X2).
Note!- Recommendation to use SD card instead of the built-in flash memory when extensive data logging is performed. Read more about the X2 and iX Developer 2.40 – Flash memory best practice: click here
- “…iX Developer 2.40 SP5 introduces the capability to use external SDcard on X2 devices with SD card support. An SD card is easy to replace compared to a built-in memory. Beijer Electronics AB recommends you to use SD card instead of the built-in flash memory when extensive data logging is performed. Scripting towards the database can cause an increase inwrite and affect the general sustainability and performance of the database…”
- The filename is dynamic, based on a FB input and the time and date.
- The file will grow indefinitely, but Excel imposes a limit of 2^20 rows, which is about 17 minutes at 1ms. Other text editors (Notepad++ possibly) may allow more.
- Included is the one FB and a quickstart guide.
- The library file (*.compiled-library) can be installed to the CODESYS software on your PC and the FB be accessed as any block, please follow guidelines and description.
Preparing your editor
The following chapter describes important procedures and settings needed for a well functioning system.
Installation of the library to your editor
- The *.compiled-library needs to be made available in your system so it can be included in projects. This is done by accessing the ‘Library Manager’’Library Repository’ then ‘Install’.
- Navigate to the folder where you have put the *.compiled-library. This procedure will need to be repeated if you use a new PC.
- Note, the location of System path may differ depending if using BCS Tools or CODESYS software tool and what version of the software.
Add the library into your project
- The new library is now available for you to include in your specific project (example screenshot):
- The selected library is now visible in the Library Manager. Its public objects and supplementary help is available here
Description of function blocks
fbdLogger
- This FB provides a method to log PLC data to a csv file.
- The FB can be used to log upto 10 REALs data signals at a rate of as low as 1ms.
- The library creates a CSV file that can be written to USB, SD or internally (to the FTP area of the X2). The filename is dynamic, based on a FB input and the time and date.
- The file will grow indefinitely, but Excel imposes a limit of 2^20 rows, which is about 17 minutes at 1ms. Other text editors (Notepad++ possibly) may allow more.
- Provide an instance name for the FB and populate the inputs
- fbdLogger arguments
Input Type Initial Comment DoLog BOOL The logger runs continuously whilst this flag is high FileName STRING ‘Log’ The user-defined filename prefix HowManyPoints USINT 4 The quantity of points to log Headings ARRAY [0..9] OF STRING(20) The user-defined csv file column headers Data ARRAY [0..9] OF REAL The user’s data StorageLocation eStorage eStorage.Local Select where the file is to be created Output Type Initial Comment IncompatibleHardware BOOL Target is not an X2Control or BoX2Control device StatusText STRING Busy BOOL Indicate a successful completion i.e. the termination character has been received
Done BOOL True for one scan after file is closed LoggingRate STRING Provides a text output with the current logging rate. Determined by the task time, but it is measured and that value is presented BufferLength INT Used for diagnosis RowsLogged UDINT Realtime tally of the number of rows logged FileSize UDINT The size (in bytes) of the file being created - Populate the Headings and Data.
This shows the interaction between the Codesys program and the Csv file. - Determine logging rate
Determining the logging rate is done by changing the TaskTime where the FB is hosted. - Starting logging.
The logging operation is carried out for as long as the DoLog FB input is high.
A new file is created each time with the filename being determined by- The string value in FB input FileName +
- yyyy_mm_dd +
- hh_mm_ss +
- .CSV
- File location.
The user can choose 1 of 3 locations to store the file. The choice is made with the FB input StorageLocation which is an ENUM: NB the Usb and SD target need a \Log folder creating beforehand. The Local choice puts the resulting file in the FTP-accessible area of the X2. External memory cards’ quality varies. Using slow Usb’s or Sd cards will cause a buffer overflow (handled exception). - Status.
The FB gives the user its status by:- Flag status
- Busy – true whilst creating the file, collecting data and closing the file;
- Done – true for one-scan when file is closed.
- Plain text. See table:
Text Description Idle Waiting for a request to start Confirming target directory exists The block is checking that the target medium is present (and has a \Log folder) Getting Date Retrieving the OS time and date to form part of the log’s filename Opening file Creating the new *’csv file Writing headings Writing the column headers to the file Collecting data Collecting data Closing file After logging has finished, the file is closed Could not create file. Check filename is valid Usual filename rules are obeyed Number of point must be greater than zero Check the block’s input parameters Number of points must be 10 or less Check the block’s input parameters Could not write new line USB (typically) is too slow. USB/SD removed midway through logging Memory full
Buffer overrun USB (typically) is too slow. External memory needs a “\Log” folder and internal needs “Project Files” folder The target medium need the appropriate sub-folder creating Attempting to close Following an error, the block will try to gracefully close the file - Number of rows logged. Incremented for each row of data logged.
- FileSize. Presents the real-time size of the file in bytes
- Flag status
- Size limitations
Text files have a limit of 1048576 rows, therefore, at 1ms logging interval the file can store just over 17minutes worth of data, however the quantity of files to be stored is limited only by the target’s memory. - Performance limitations
- The logged data is buffered and written to the medium (USB, SD or locally) in lumps to minimise the amount of writes.
- There is still a requirement that the medium is fast enough be written to as this buffered speed and with sometimes large amounts of data. 1ms logging is possible with USB memory with write speeds greater than 12MB/s (measured)
- Tools are available to take real-world USB performance figures. SD cards are inherently faster, any card from a reputable manufacturer will be ok.
Note!- Recommendation to use SD card instead of the built-in flash memory when extensive data logging is performed. Read more about the X2 and iX Developer 2.40 – Flash memory best practice: click here
- “…iX Developer 2.40 SP5 introduces the capability to use external SDcard on X2 devices with SD card support. An SD card is easy to replace compared to a built-in memory. Beijer Electronics AB recommends you to use SD card instead of the built-in flash memory when extensive data logging is performed. Scripting towards the database can cause an increase inwrite and affect the general sustainability and performance of the database…”
About Beijer Electronics
- Beijer Electronics is a multinational, cross-industry innovator that connects people and technologies to optimize processes for business-critical applications. Our offer includes operator communication, automation solutions, digitalization, display solutions and support. As experts in user-friendly software, hardware and services for the Industrial Internet of Things, we empower you to meet your challenges through leading-edge solutions.
- Beijer Electronics is a BEIJER GROUP company. Beijer Group has a sale over 1.6 billion SEK in 2021 and is listed on the Nasdaq Stockholm Main Market under the ticker BELE. www.beijergroup.com
Contact us
Global offices and distributors
Documents / Resources
![]() |
Beijer ELECTRONICS SER0002 Fast Logging FB CODESYS Library [pdf] User Guide SER0002 Fast Logging FB CODESYS Library, SER0002, Fast Logging FB CODESYS Library |