FUNCTION_BLOCK PMC_ReadDigitalSignalFromPMC
	IF Enable = TRUE THEN
		(* Statement section IF*)
		(*read xbot ID*)
		IF (DiID > 0) AND (DiID <= 128) THEN
			(* Statement section IF*)
			(* *)
			ByteOffset := LREAL_TO_DINT(floor((DiID - 1) / 8));
			BitOffset := (DiID - 1) - ByteOffset * 8;
			(*read X force from frame*)
			memcpy(pDest := ADR(RegVal),pSrc := ADR(FBin_pointer) + P2H_START + P2H_DI_OFFSET + ByteOffset,length := 1);
			RegVal := RegVal AND SHL(1,BitOffset);(*2**BitOffset;*)
			Level := USINT_TO_BOOL(SHR(RegVal,BitOffset));
			Valid := TRUE;
		ELSE
			Valid := FALSE;
		END_IF;
	    
	ELSE
		Valid := FALSE;
	END_IF;

END_FUNCTION_BLOCK
