Introduction to SD card instructions

Using SD card instructions with FP-XH Ethernet type PLCs

Tip
  • You can use all SD card instructions with an FP-XH Ethernet PLC even though it has no SD card slot. Instead of using an SD card for reading/writing data, the data is stored internally in the RAM.

    Please note that data is not stored when the PLC is turned off.

  • The memory size is limited to 1MB.

    FP_SD_GET_FREE_KBYTES returns the amount of free space.

Operation of instructions

  • Upon execution of an SD card instruction, the following checks are conducted:

  • Is an SD card present?

  • Is the cover closed?

  • Is the SD card write-protected?

  • During the execution, the SD memory access active flag (sys_bIsSDMemoryAccessActive) is TRUE, and the SD memory access done flag (sys_bIsSDMemoryAccessDone) is FALSE.

  • The execution of an SD card instruction is performed through multiple scans.

  • Upon completion of the execution, the SD memory access error flag (sys_bIsSDMemoryAccessError) turns to TRUE or FALSE, depending on the result. Use this flag to judge whether the SD card instruction has completed normally or abnormally when the SD memory access done flag (sys_bIsSDMemoryAccessDone) turns to TRUE. The error code is stored in a system data register which can be accessed using sys_iSDMemoryAccessErrorCode.

  • Only one type of SD card instruction can be executed at the same time. To execute more than one instruction, use flags such as the SD memory access active flag (sys_bIsSDMemoryAccessActive).

  • Use FP_SET_ERROR to clear error flags.

  • SD card instructions cannot be used in interrupt programs.

Flag operation

  1.  (1) The execution of an SD card instruction is performed through multiple scans.
  2.  (2) All flags (SD memory access active, SD memory access done, SD memory access error) and registers (error code) are set upon execution of the instruction.
  3.  (3) Execution completion is announced at the end of the scan. If an error has occurred, the SD memory access error flag is set to TRUE and the error code is written into a system data register.
NOTE

When one of the following errors is detected, completion is announced immediately and the SD memory access active flag does not turn to TRUE:

  • No SD card
  • Write-protection of SD card enabled
  • File/directory name error

List of error codes

Error code Name of error Cause

Affected instructions

0

Completed without error

1

No SD card

No SD card is installed, or the cover is open.

All SD card instructions at the time of execution.

2

Write-protection of SD card enabled

The SD card is write-protected.

  • FP_SD_WRITE*

  • FP_SD_DELETE*

  • FP_SD_MOVE*

  • FP_SD_COPY*

  • FP_SD_RENAME*

3

File/directory name error

The syntax for specifying the file name and directory is wrong or too many subdirectories were specified.

  • FP_SD_*_FILE

  • FP_SD_*_DIR

4

File not specified

The specified file does not exist.

  • FP_SD_*_FILE

  • FP_SD_*_DIR

5

File exists

The specified file already exists.

  • FP_SD_MOVE*

  • FP_SD_COPY*

  • FP_SD_RENAME*

6

Reading error

All read instructions at the time of execution.

7

Writing error

The specified file is write-protected.

  • FP_SD_WRITE*

  • FP_SD_DELETE*

  • FP_SD_MOVE*

  • FP_SD_COPY*

  • FP_SD_RENAME*

8

Wrong position

The reading or writing position is wrong.

  • FP_SD_WRITE

  • FP_SD_READ

  • FP_SD_READ_LINE

At the time of execution.

9

SD card full

There is not enough free capacity on the SD card.

  • FP_SD_WRITE*

  • FP_SD_DELETE*

  • FP_SD_MOVE*

  • FP_SD_COPY*

  • FP_SD_RENAME*

10

Wrong reading format

Error in the conversion format when reading a file.

  • FP_SD_READ

At the time of execution.

11

File access conflict

The specified file is being logged or is being accessed via FTP.

  • FP_SD_WRITE*

  • FP_SD_DELETE*

  • FP_SD_MOVE*

  • FP_SD_COPY*

  • FP_SD_RENAME*

-1 to -99

Others

All SD card instructions

How to specify directory and file names in an SD card

  • Specify the full path (up to 256 characters).

  • Do not specify the drive name.

  • Specify a file extension, e.g. .txt.

  • To save data in a file called abc.txt in the root directory, enter this: \abc.txt

  • To save data in a file called def.txt in a subdirectory called "sub", enter this: \sub\def.txt

  • To save data in a file called def.txt in a new subdirectory called "new", enter this: \new\def.txt

NOTE
  • A subdirectory can only be created directly under its parent directory with one instruction. For directories in lower hierarchy levels, parent directories must be created first.
  • If two or more files are specified, error 4 "File not specified" occurs.

SD card specifications

SD

SDHC

File system

FAT16

FAT32

Max. length of file name

Supports long file names (VFAT)

Max. capacity

2GB

32GB

Max. file size

2GB

4GB

Max. number of files (8.3 format) in root directory

512

65535

Max. number of files (8.3 format) in sub directory

65534

65534

Max. number of files (long format) in root directory

170

21845

Max. number of files (long format) in sub directory

56634

65534

Item

Description

Long file name

255 bytes (256 bytes including full path)

File name/directory name

ASCII characters (16#20–16#7E)

Modified on: 2019-01-25Feedback on this pagePanasonic hotline