Write binary data to SD card
This FP instruction reads binary data from a memory area specified by s_Start and n_Words and writes it into a binary format file specified by d_FIleNumber on the SD card. The directory name is \data, and the file name is dtxxx.bin where "xxx" is the file number.
Input
Starting address
Number of words
Output
File number (0–999)
Please also refer to precautions for SD card access.
The SD memory access active flag (sys_bIsSDMemoryAccessActive) turns to TRUE after the trigger EN of the SD card instruction has turned to TRUE and remains TRUE until execution has completed. During this time, other SD card instructions cannot be executed.
Make sure that sys_bIsSDMemoryAccessDone is FALSE.
The SD memory access done flag (sys_blsSDMemoryAccessDone) is FALSE when the instruction is executed and turns to TRUE and remains TRUE when the instruction is completed.
If the specified folder does not exist, a new folder is created.
If the file already exists, it will be overwritten.
FALSE: when the instruction has completed without error
TRUE: when the instruction has completed with an error
Use sys_iSDMemoryAccessErrorCode to evaluate the error code.
if the area specified using the index modifier exceeds the limit.
if the area specified using the index modifier exceeds the limit.
With a Data Unit Type (DUT) you can define a data unit type that is composed of other data types. A DUT is first defined in the DUT pool and then processed like the standard data types (BOOL, INT, etc.) in the list of global variables or the POU header.
All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.
VAR
bStart: BOOL:=FALSE;
(*activates the instruction*)
dutValuesWrite: DUT_VALUES:=iValue := -32768,uiValue := 65535,diValue := -2157492,udiValue := 2333422234,rValue := 27.02,arrValue := [16#0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],sStringValue := 'Test String 25 characters';
iFileNumberDut: INT:=2;
END_VAR
When the variable bStart changes from FALSE to TRUE and the system variable sys_bIsSDMemoryAccessActive is not TRUE, the function is carried out.
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 11 ;
NETWORK_BODY
B(B_CONTACT,,sys_bIsSDMemoryAccessActive,10,2,12,4,N);
B(B_CONTACT,,bStart,2,2,4,4,R);
B(B_F,FP_SD_WRITE_BIN!,,16,3,27,8,,?DEN?Ds_Start?Dn_Words?AENO?Cd_FileNumber);
B(B_VAROUT,,iFileNumberDut,27,5,29,7,);
B(B_F,Adr_Of_Var_I!,,9,5,16,7,,?D?C);
B(B_VARIN,,dutValuesWrite,7,5,9,7,);
B(B_F,Size_Of_Var!,,9,6,16,8,,?D?C);
L(9,6,9,7);
L(1,3,2,3);
L(4,3,10,3);
L(12,3,12,5);
L(12,5,16,5);
L(1,0,1,11);
END_NETWORK_BODY
END_NET_WORK
END_BODY
IF DF(bStart)AND not sys_bIsSDMemoryAccessActive then
FP_SD_WRITE_BIN(s_Start := Adr_Of_Var(dutValuesWrite),
n_Words := Size_Of_Var(dutValuesWrite),
d_FileNumber => iFileNumberDut);
END_IF;