FP_SD_GET_FREE_KBYTES

Return the number of free kBytes on the SD card

This FP instruction calculates the free capacity in kilobytes available on the SD card and stores the result in d_kBytes.

Parameters

Output

d_kBytes (UDINT)

Number of free kBytes

Remarks

  • 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.

  • 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.

Error flags

sys_bIsSDMemoryAccessError
  • 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.

Example

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 instrution*)
		udiFreeSdSpace: UDINT:=0;
	END_VAR

POU body

When the variable bStart changes from FALSE to TRUE, the function is carried out. It calculates the number of free kBytes on the SD card and stores the value in d_kBytes.

LD body

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 7 ;
        NETWORK_BODY
B(B_F,FP_SD_GET_FREE_KBYTES!,,18,0,31,4,,?DEN?AENO?Cd_kBytes);
B(B_VAROUT,,udiFreeSdSpace,31,2,33,4,);
B(B_CONTACT,,sys_bIsSDMemoryAccessActive,10,1,12,3,N);
B(B_CONTACT,,bStart,2,1,4,3,);
L(1,2,2,2);
L(4,2,10,2);
L(12,2,18,2);
L(1,0,1,7);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

IF bStart AND not sys_bIsSDMemoryAccessActive then
    FP_SD_GET_FREE_KBYTES(udiFreeSdSpace);
END_IF;

Modified on: 2024-03-06Feedback on this pagePanasonic hotline