399
10-5-2 File name and storage location
SD card supports storing ".csv" format files, which must be stored in the root directory of SD
card.
All ".csv" files must be named after "dataxxx.csv", and "xxx" is the index number of the file,
ranging from 001 to 999. When xxx is less than 100, add 0 from the left to supplement. If the
index number of the file is 1, the file is correctly named "data001.csv".
10-5-3 Read/write SD card
The instruction to read and write SD card is in the sequential function block block. Open the
block function interface and insert "read and write SD module". The following is an
introduction to the instructions for reading and writing SD cards.
1) Read SD card
Add an SD card reading instruction in the sequence function block, as shown in the following
figure:
In the above figure, the SD card reading instruction is: READSD D0 D10 D20, and the
function meanings of each parameter are as follows:
D0: file index number / column / line beginning address, D0~D2 refers to file index number,
column number and line number respectively.
As shown in the data monitoring above, D0=1, D1=1, D2=2 ,indicate:
The index number of the file is 1: that is, the file name is data001.csv.
Column number 1: column 1.
Line number is 2: Line 2 (data line 2).
D10: number of words to read data.
As shown in the data monitoring above, D10=1 means reading 1 word data.
D20: the read data is stored in the first address of the PLC body.
As shown in the data monitoring above, the data read in D20 is -32765.
Therefore, the specific meaning of the above program is to read the file name data001 under
the root directory of the SD card CSV, and save the read data in register D20.
If the number of columns is 0, the number of words read from the data indicates the number
of rows read. For example, when D0=1, D1=0, D2=1, D10=5, it means that the data of 5 lines
is read from the first line of the file data001.csv and stored in the register starting from D20.
tudonghoatoancau.com