Nj-Series Instructions Reference Manual (W502 - Omron NJ501-1500 Reference Manual

Machine automation controller nj-series
Hide thumbs Also See for NJ501-1500:
Table of Contents

Advertisement

2 Instruction Descriptions
• You must use the FileOpen instruction to obtain the value for FileID before you execute this instruc-
tion.
• If the operating mode of the CPU Unit is changed to PROGRAM mode or when a major fault level
Controller error occurs during instruction execution, the file is closed by the system. Any read/write
operations that are in progress are completed to the end.
• An error occurs in the following cases. Error will change to TRUE.
• The SD Memory Card is not in a usable condition.
• The file specified by FileID does not exist.
• The file specified by FileID is being accessed.
• The file specified by FileID was not opened in a reading mode.
• An error that prevents access occurs during SD Memory Card access.
Sample Programming
Here, multiple text strings that are separated by CR codes are stored in a file named 'ABC.csv.' All of
them are text strings of numbers. One line at a time is read from the file, the text strings are converted
to integers, and the results are stored in INT array variable InDat[]. Processing is ended when all of the
data to the end of the file is read.
It is assumed that this sample programming is in a periodic task.
'ABC.csv' file
1234 CR
9876 CR
5678 CR
. . . .
.
. . . .
.
. . . .
.
. . . .
.
. . . .
.
. . . .
.
EOF
The processing procedure is as follows:
1
The FileOpen instruction is used to open the file 'ABC.csv.'
2
The FileGets instruction is used to read one line from the file.
3
The STRING_TO_INT instruction is used to convert the text string that was read to an integer
and store it in InDat[].
4
Steps 2 and 3 are repeated until the EOF (end of file).
5
The FileClose instruction is used to close the file.
2-828
One line read at a time and
converted to a number.
in_data[0] 1234
in_data[1]
in_data[2]
9876
5678
.
.
.
.
.
.
.

NJ-series Instructions Reference Manual (W502)

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Nj501-1300Nj501-1400

Table of Contents