2 Instruction Descriptions
2-814
NJ-series Instructions Reference Manual (W502)
• Execution of this instruction is continued until processing is completed even if the value of Execute
changes to FALSE or the execution time exceeds the task period. The value of Done changes to
TRUE when processing is completed. Use this to confirm normal completion of processing.
• Refer to Using this Section on page 2-2 for a timing chart for Execute, Done, Busy, and Error.
• If the data is read to the end of the file and the size of the data is not evenly divisible by the size of the
data type of ReadBuf[], the data that is insufficient for the data size of ReadBuf[] is discarded. The file
position indicator advances to the end of the file, and the value of EOF changes to TRUE.
• Elements beyond Size times ReadBuf[] (i.e., the elements not overwritten when data is read) will
retain the values from before execution of this instruction.
• You must use the FileOpen instruction to obtain the value for FileID before you execute this instruc-
tion.
• A value is stored in EOF when the instruction is completed. Specifically, it is stored when the value of
Done changes from FALSE to TRUE.
• If ReadBuf[] is an array of structures, adjustment areas between members may be inserted depend-
ing on the composition.
• 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 number of array elements in ReadBuf[] is smaller than the value of Size.
• 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.
In this sample, four bytes of data are read from the second byte from beginning of the file named
'ABC.bin.' The data is written to BYTE array variable InDat[]. The processing procedure is as follows:
1
The FileOpen instruction is used to open the file ‘ABC.bin.’
2
The FileSeek instruction is used to set a file position indicator at the second byte from the begin-
ning of the file.
3
The FileRead instruction is used to read four bytes of data from the position of the file position
indicator and store it in array variable InDat[].
4
The FileClose instruction is used to close the file ‘ABC.bin.’
_Card1PowerFail SD Memory Card
Power Interruption Flag
BOOL This flag indicates if an error occurred in complet-
ing processing when power was interrupted dur-
ing SD Memory Card access. This flag is not
cleared automatically.
TRUE: Error.
FALSE: No error.
Precautions for Correct Use
Sample Programming
Name Meaning Data type Description