2-805
2 Instruction Descriptions
NJ-series Instructions Reference Manual (W502)
SD Memory Card Instructions
2
FileOpen
The root directory of the file name is the top level of the SD Memory Card.
• 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.
• This instruction must be executed before any of the following instructions: FileSeek, FileRead, File-
Write, FileGets, and FilePuts.
• You must use the FileClose instruction to close any file that is opened with this instruction after you
finish using it.
• A value is stored in FileID when the instruction is completed. Specifically, it is stored when the value
of Done changes from FALSE to TRUE.
• If a file is open when the operating mode of the CPU Unit is changed to PROGRAM mode or when a
major fault level Controller error occurs, the file is closed by the system. Any read/write operations
that are in progress are completed to the end.
• If a file is open when the power supply it stopped with the power switch, the file is not corrupted. The
file, however, will remain open. Use the FileClose instruction to close the file.
• If a file is open and the SD Memory Card is removed before the power switch is pressed, the contents
of the file will sometimes be corrupted. Always turn OFF the power supply before removing the SD
Memory Card.
• If a file is open and the SD Memory Card is removed before the power switch is pressed, the file will
remain open. Use the FileClose instruction to close the file.
• If a file is open when the power supply is stopped or the SD Memory Card is removed, the file will
remain open, but it will not be possible to read or write the file even if the SD Memory Card is inserted
again. To read/write the file, close the file and then open it again.
• An error occurs in the following cases. Error will change to TRUE.
• The SD Memory Card is not in a usable condition.
• The SD Memory Card is write protected.
• The value of Mode is _READ_EXIST or _RDWR_EXIST and the file specified with FileName does
not exist.
• The value of FileName is not a valid file name.
• The maximum number of files or directories is exceeded.
• The file specified by FileName is being accessed.
• The file specified by FileName is write protected.
• An attempt was made to open more than five files at the same time.
• The value of FileName exceeds the maximum number of bytes allowed in a file name.
• An error that prevents access occurs during SD Memory Card access.
• The value of Mode is outside of the valid range.
Refer to the sample programming for the following instructions: FileRead (page 2-812), FileWrite (page
2-819), FileGets (page 2-826), and FilePuts (page 2-833).
Additional Information
Precautions for Correct Use
Sample Programming