Data File with Sectors¶
Insert the SD memory card.
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 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. If you want to read further sectors / data sets, close the file and repeat the steps 2 and 3.
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. 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*)