2-813
2 Instruction Descriptions
NJ-series Instructions Reference Manual (W502)
SD Memory Card Instructions
2
FileRead
The FileRead instruction reads the data from position of the file position indicator in the file specified by
file ID FileID in the SD Memory Card. It then stores the data in read buffer ReadBuf[]. The file position
indicator is set at the desired location in advance with the FileSeek instruction. The amount of data that
is read is the size of the data type of ReadBuf[] times Size. You can specify an array of enumerations or
structures for ReadBuf[]. The actual number of elements that were read is stored in ReadSize. Nor-
mally, Size and ReadSize will have the same values. If the amount of data from the file position indicator
to the end of the file is smaller than Size, an error will not occur and the data to the end of the file is
stored in ReadBuf[]. If that occurs, the value of ReadSize will be smaller than the value of Size. If data is
read to the end of the file, end of file EOF changes to TRUE. Otherwise, the value of EOF will be
FALSE.
The following figure shows a programming example. If the read buffer def[] is a BYTE array, 100 bytes
of data is read from the file.
Function
Related System-defined Variables
Name Meaning Data type Description
_Card1Ready SD Memory Card
Ready Flag
BOOL This flag indicates if the SD Memory Card is
physically inserted and is mounted normally, i.e.,
if it can be accessed by instructions and commu-
nications commands.
TRUE: Can be used.
FALSE: Cannot be used.
_Card1Protect SD Memory Card Write
Protected Flag
BOOL This flag indicates if the SD Memory Card is write
protected when it is inserted and ready to use.
TRUE: Write protected.
FALSE: Not write protected.
_Card1Err SD Memory Card Error
Flag
BOOL This flag indicates if an unspecified SD Memory
Card (e.g., an SDHC card) is mounted or if the
format is incorrect (i.e., not FAT16 or corrupted).
TRUE: Error.
FALSE: No error.
_Card1Access SD Memory Card
Access Flag
BOOL This flag indicates if the SD Memory Card is cur-
rently being accessed.
TRUE: Being accessed.
FALSE: Not being accessed.
FileRead_instance(A, abc, def[0], UINT#100,
ghi, jkl, mno, pqr, stu, vwx);
LD
ST
abc
def[0]
def[0]
ghi
jkl
mno
pqr
stu
vwx
UINT#100
A
FileRead
Execute Done
FileID Busy
ReadBuf
Size Error
ErrorID
ReadSize
EOF
FileRead_instance