Function Blocks for Storing/Reading User Data to/from the SD Memory Card

The following function blocks from the SysInt_AC500_Vxx.lib library are used to write and read user data from the CPU program to/from the SD memory card:

The SysInt_AC500_Vxx.lib library and the SysExt_AC500_Vxx.lib library are loaded automatically when creating a project for an AC500 CPU.

Storage folder: ..\Data Storage\SD memory card.

Inputs and outputs of SD_WRITE
Name Type Assignment
Inputs
EN BOOL The FALSE->TRUE edge starts the write process
ATTRIB BYTE

Write attribute of the function block:

1 - Delete file

2 - Write append

3 - Write sector label

FILENO BYTE Consecutive file number 0 <=xx<=99 (USRDATxx.DAT)
SEG POINTER TO STRING Pointer to sector label string (via ADR operator)
FORMAT BYTE

Data format:

00 hex - 0 - BYTE

01 hex - 1 - CHAR

10 hex - 16 - WORD

11 hex - 17 - INT

20 hex - 32 - DWORD

21 hex - 33 - DINT

NVAR WORD Number of variables to be written
ADRVAR DWORD Address of the first variable, starting from which the data are available in the CPU (via ADR operator)
Outputs
DONE BOOL Function completed
ERR BOOL Error: FALSE=no error, TRUE=error
ERNO INT Error number
Inputs and outputs of SD_READ
Name Type Assignment
Inputs
EN BOOL The FALSE->TRUE edge starts the read process
ATTRIB BYTE

Read attribute of the function block:

1 - Open file, seek sector, read data set

2 - Open file, read data set

3 - Open and read next data set

4 - Read data set, close file

5 - Close file

FILENO BYTE Consecutive file number 0 <=xx<=99 (USRDATxx.DAT)
SEG POINTER TO STRING Pointer to sector label string (via ADR operator)
FORMAT BYTE

Data format:

00 hex - 0 - BYTE

01 hex - 1 - CHAR

10 hex - 16 - WORD

11 hex - 17 - INT

20 hex - 32 - DWORD

21 hex - 33 - DINT

NVAR WORD Number of variables to be read
ADRVAR DWORD Address of the first variable, starting from which the data are stored to the CPU (via ADR operator)
Outputs
DONE BOOL Function completed
ERR BOOL Error: FALSE=no error, TRUE=error
ERNO INT Error number