0% found this document useful (0 votes)
57 views

NJ Data Log Function Block

This document describes an NJ Data Logging function block that logs data to .csv files on an SD card. It provides two function blocks, one for logging each data sample and one for logging arrays of data. The function block logs a single line of text at a time in a .csv format file. It has inputs for execute trigger, filename, column names, and array size. Outputs provide status, errors, and error descriptions. Hardware requirements are an NJ CPU and SD card.

Uploaded by

ma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

NJ Data Log Function Block

This document describes an NJ Data Logging function block that logs data to .csv files on an SD card. It provides two function blocks, one for logging each data sample and one for logging arrays of data. The function block logs a single line of text at a time in a .csv format file. It has inputs for execute trigger, filename, column names, and array size. Outputs provide status, errors, and error descriptions. Hardware requirements are an NJ CPU and SD card.

Uploaded by

ma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

PNSPO!

NJ Data Logging Function Block

Version 1.0

1/19/2016
Section 1. Overview
The NJ Data Logging function block is designed to allow for easy creation of data log files in
.csv format, using data collected by the NJ CPU. This could be production data, machine fault
data, downtime data, etc. Column names are automatically written at the top of each column
when a new file is created. The data is logged to the SD card in the NJ CPU.

There are 2 different function blocks for 2 different logging scenarios.

1. Logging of data to the SD card each time it is collected. This is useful when data
collection rate is slow (more than 1 second between data samples).
2. Logging of data stored in an array. This is useful when data is collected at a rate that
is faster than the NJ can log the data. In this case, the data is stored in an array, and
then the entire array is written to the SD card after all the data is collected.

After the data is logged to the SD card, there are several methods of retrieving the data:

1. Use the built in FTP Server functionality of the NJ to retrieve the data using an FTP
client.
2. Use the FTP Client Function Block in the NJ to push the file to an FTP Server.
3. Remove the SD card from the NJ and access from a PC.
4. Use Sysmac Studio to transfer the data from the SD card.

The function block logs a single line of text at a time to make the .csv formatted file. The
number of characters of text written includes the data from all the members of the Data Type
used to log data, along with a comma separator between each member. The total length of a
single line of text as written by the function block can be no more than 1,983 characters. Make
certain that the length of data to log in a single record does not exceed this length.

Section 2. Hardware Requirements


1. Any NJ CPU with power supply
2. An Omron HMC-SD291 or HMC-SC491 SD Card

Section 3. Additional Reference Materials


1. W501 – NJ NX Series CPU Unit Software Manual
Section 4. Adding the Data Logging Function Block to a project
1. Open the provided sample Sysmac Studio project, and navigate to the Programming /
Function Blocks section. Right click on Log_CSV_Data or Log_CSV_Data_Array, and
select Copy.

2. Open the target project in Sysmac Studio, navigate to the Programming / Function Block
section, right click, and select Paste.

3. Repeat the process for the Data Types named ‘LogDataStructure’ and
‘LogDataColumnNamesStructure’.
4. The Data Logging function block will now be part of the project, and is ready to
instantiate in the project.
Section 5. Configuring the Data to Log
The data to be logged is stored in a variable that is of type LogDataStructure. The user will
need to modify the data type LogDataStructure to meet the needs of the application. A sample
with members DateandTime, OperatorID, LogData1,LogData2, LogData3, and LogData4 was
created as an example. Any data type can be used, but in this logging application, arrays within
the LogdataStructure are not supported. All members of LogDataStructure must be simple data
types such as String, Int, Real, Boolean, Byte, etc.

There is a second data type that is used hold the column header titles. This is the
‘LogDataColumnNamesStructure’. The user must modify this to have as many members as the
LogDataStructure has members, so that each column gets a unique name.

Once the Data Types are modified, the user needs to create the 2 variables for logging. In the
example provided, the data that will be logged is named ‘DataToLog’, and is of type
‘LogDataStructure’. The column header names are stored in a variable named ‘ColumnNames’,
and is of type ‘LogDataColumnNamesStructure’. Note: the column header names can easily
be added using the Initial Value field for the ColumnNames variable.
Section 6. Using the Data Logging function block

The function block uses the following parameters:

Inputs:
Execute – Rising edge trigger to log data
Filename – a constant or variable of type String to be used as the filename, including
the entire path if folders are used. ‘Test.csv’, or ‘/MyFolder/MyFile’ are examples of the
filename. If ‘.csv’ is omitted from the end of the filename, the function block will add it
automatically. Note: the function block will write files to folders that already exist, but
will not create folders automatically.
ColumnNames – The variable containing the names of the column headers to be used
when creating a new file.
Maximum_Array_Index: When using the Array function block, this is the highest array
index number to log. 0 is always the starting array index.

Outputs:
ENO – Enable Output. Always On.
Done – On when the function block has successfully logged data.
Busy – On when function block is actively logging data.
Error – On when the function block has ended with an error.
Error_ID – numeric value of error code.
ErrorMSG – Text description of the error.

Section 7. Error Codes


Error_ID
50: Function Block Busy
120: SD Card Protected, Busy, or Not Ready
380: Error creating string to write. String may be too long.
1400: SD Card Access Failure
1401: SD Card Write Protected
1403: File Does Not Exist
1405: File Already in Use
140A: SD Card Write Access Denied. File could be write protected.

You might also like