Data File with Sectors

  1. Insert the SD memory card.

  2. Write the sector label by calling the function block SD_WRITE: SD_WRITE

    EN := TRUE  
    ATTRIB := 3 (* write sector *)
    FILENO := 0…99 (* number of the file to which the data set is to be appended *)
    SEG := Address of the variable of the sector label
    FORMAT := Data format
    NVAR := Number of values in data set
    ADRVAR := Address of the first variable to be written

    If no corresponding file exists, then it is created.

    The sector is successfully completed when output DONE:=TRUE and output ERR:=FALSE. A write error is indicated by ERR:=TRUE and ERNO<>0

  3. Write a data set by calling the function block SD_WRITE with the following settings:

    EN := TRUE (* FALSE/TRUE edge starts writing *)
    ATTRIB := 2 (* write append *)
    FILENO := 0…99 (* number of the file to which the data set is to be appended *)
    SEG := Address of the variable of the sector label
    FORMAT := Data format
    NVAR := Number of values in data set
    ADRVAR := Address of the first variable to be written
    The write process is successfully completed when output DONE:=TRUE and output ERR:=FALSE. A write error is indicated by ERR:=TRUE and ERNO<>0
  4. Further data sets can be written with the same function block settings after the completion message is indicated (output DONE=TRUE). This process is started with a FALSE/TRUE edge at input EN.

  5. If you want to write further sectors and data sets, repeat the steps as of step 2.

Note

The file USRDATxx.DAT is saved as USRDATxx.BAK for each write process. An “Open file / Write file / Close file” procedure is performed.