Data File with Sectors

  1. Insert the SD memory card.

  2. Seek a sector label and read a data set by calling the function block SD_READ: SD_READ

    EN := TRUE (* FALSE/TRUE edge starts writing *)
    ATTRIB := 1 (* open / seek / read *)
    FILENO := 0…99 (* number of the file which is to be read *)
    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 into which data are to be written
    The read process is successfully completed when output DONE:=TRUE and output ERR:=FALSE. A seek error is indicated by ERR:=TRUE and ERNO<>0
  3. Further data sets can be read with the following settings after the completion message is indicated (output DONE=TRUE). This process is started with a FALSE/TRUE edge at input EN:

    EN := TRUE (* FALSE/TRUE edge starts reading *)
    ATTRIB := 3 (* continue read *)
    FILENO := 0…99 (* number of the file which is to be read*)
    SEG := Address of the variable of the sector label (*any*)
    FORMAT := Data format
    NVAR := Number of values in data set
    ADRVAR := Address of the first variable into which data are to be written
    If an unexpected sector label or the end of file (EOF) is detected when reading, a corresponding error message is generated.
  4. If you want to read further sectors / data sets, close the file and repeat the steps 2 and 3.

  5. To read a further data set and to close the file afterwards, call the function block SD_READ with the following settings after the completion message (output DONE=TRUE) and start the process with a FALSE/TRUE edge at input EN:

    EN := TRUE (* FALSE/TRUE edge starts reading *)
    ATTRIB := 4 (* read / close *)
    FILENO := 0…99 (* number of the file which is to be read*)
    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 into which data are to be written
    If an unexpected sector label or the end of file (EOF) is detected when reading, a corresponding error message is generated.
  6. To close the file, call the function block SD_READ with the following settings after the completion message (output DONE=TRUE) and start the process with a FALSE/TRUE edge at input EN:

    EN := TRUE (* FALSE/TRUE edge starts reading *)
    ATTRIB := 4 (* close *)
    FILENO := 0…99 (* number of the file which is to be read*)
    SEG := Address of the variable of the sector label
    FORMAT := Data format
    NVAR := Number of values in data set (*any*)
    ADRVAR := Address of the first variable (*any*)