[Codesys]常用功能块应用分享-BMOV功能块功能介绍及其使用实例说明
官方说明
功能说明
参数 | 类型 | 功能 |
pbyDataSrc | POINTER TO BYTE | 指向源数组指针 |
uiSize | UINT | 要移动数据的BYTE数 |
pbyDataDes | POINTER TO BYTE | 指向目标数组指针 |
实例应用-ST
IF SYSTEM_CLOCK.AlwaysTrue THEN
CASE iAutoState OF
0: //读写完成信号在下次读写信号的上升沿或复位信号的下降沿清除
ClearRtrig(CLK:=(ReadCmd OR WriteCmd)AND OPMODE.User_Interface_OUT.Reset=FALSE,Q=>TrigClearQ);
IF TrigClearQ THEN
RW_Done:=FALSE;
RFID_ReadCmd_Mid:=FALSE;
RFID_WriteCmd_Mid:=FALSE;
iStartAddrChangebale:=0;
RfidBaseReset:=TRUE;
END_IF
IF RW_Done=FALSE AND iRfidBaseState=10 AND iStartAddrChangebale=0 THEN
RfidBaseReset:=FALSE;
iAutoState:=5;
END_IF
5:
IF ReadCmd=TRUE AND WriteCmd=FALSE AND TagPresent=TRUE AND RWHeadNotConnected=FALSE AND RfidErr=FALSE THEN
RFID_ReadCmd_Mid:=TRUE;
RFID_WriteCmd_Mid:=FALSE;
iAutoState:=10;
ELSIF ReadCmd=FALSE AND WriteCmd=TRUE AND TagPresent=TRUE AND RWHeadNotConnected=FALSE AND RfidErr=FALSE THEN
iAutoState:=100;
ELSIF (ReadCmd=TRUE OR WriteCmd=TRUE) AND TagPresent=FALSE THEN
RFID_ReadCmd_Mid:=FALSE;
RFID_WriteCmd_Mid:=FALSE;
TagNotExitAlarm:=TRUE;
iAutoState:=200;
ELSIF (ReadCmd=TRUE OR WriteCmd=TRUE) AND RWHeadNotConnected=TRUE THEN
RFID_ReadCmd_Mid:=FALSE;
RFID_WriteCmd_Mid:=FALSE;
RfidNotHeaderAlarm:=TRUE;
iAutoState:=200;
END_IF
10://RFID DATA READ CONTROL
IF Done=TRUE AND RfidErr=FALSE THEN
iStartAddrChangebale:=iStartAddr;
BMOV(pbyDataSrc:=pRdSrcMid , uiSize:=128 , pbyDataDes:=pRdOne);
ELSIF RfidErr THEN
GeneralAlarm:=TRUE;
END_IF
IF Done=TRUE AND GeneralAlarm =FALSE THEN
iAutoState:=20;
ELSIF GeneralAlarm=TRUE THEN
iAutoState:=200;
END_IF
20:
IF GeneralAlarm=FALSE AND RFID_ReadCmd_Mid=TRUE AND RFID_WriteCmd_Mid=FALSE THEN
RFID_ReadCmd_Mid :=FALSE;
RFID_WriteCmd_Mid:=FALSE;
ELSIF GeneralAlarm=FALSE AND RFID_ReadCmd_Mid=FALSE AND RFID_WriteCmd_Mid=FALSE THEN
iAutoState:=30;
END_IF
30:
IF AutoRdCmd=TRUE AND AutoWrCmd=FALSE AND TagPresent=TRUE AND RfidErr=FALSE THEN
RFID_ReadCmd_Mid:=TRUE;
RFID_WriteCmd_Mid:=FALSE;
iAutoState:=40;
END_IF
40:
IF Done=TRUE AND RfidErr=FALSE THEN
iStartAddrChangebale:=iStartAddr+128;
BMOV(pbyDataSrc:=pRdSrcMid , uiSize:=128 , pbyDataDes:=pRdTwo);
ELSIF RfidErr THEN
GeneralAlarm:=TRUE;
END_IF
IF Done=TRUE AND GeneralAlarm =FALSE THEN
iAutoState:=50;
ELSIF GeneralAlarm=TRUE THEN
iAutoState:=200;
END_IF
50:
IF GeneralAlarm=FALSE AND RFID_ReadCmd_Mid=TRUE AND RFID_WriteCmd_Mid=FALSE THEN
RFID_ReadCmd_Mid :=FALSE;
RFID_WriteCmd_Mid:=FALSE;
ELSIF GeneralAlarm=FALSE AND RFID_ReadCmd_Mid=FALSE AND RFID_WriteCmd_Mid=FALSE THEN
iAutoState:=60;
END_IF
60:
IF AutoRdCmd=TRUE AND AutoWrCmd=FALSE AND TagPresent=TRUE AND RfidErr=FALSE THEN
RFID_ReadCmd_Mid:=TRUE;
RFID_WriteCmd_Mid:=FALSE;
iAutoState:=70;
END_IF
70:
IF Done=TRUE AND RfidErr=FALSE THEN
iStartAddrChangebale:=iStartAddr+256;
BMOV(pbyDataSrc:=pRdSrcMid , uiSize:=128 , pbyDataDes:=pRdThree);
ELSIF RfidErr THEN
GeneralAlarm:=TRUE;
END_IF
IF Done=TRUE AND GeneralAlarm =FALSE THEN
iAutoState:=80;
ELSIF GeneralAlarm=TRUE THEN
iAutoState:=200;
END_IF
80://RFID DATA READ FINISHE RETURN
IF GeneralAlarm=FALSE THEN
RW_Done:=TRUE;
RFID_ReadCmd_Mid :=FALSE;
RFID_WriteCmd_Mid:=FALSE;
iStartAddrChangebale:=0;
iAutoState:=0;
END_IF
100://RFID DATA WRITE CONTROL
IF AutoRdCmd=FALSE AND AutoWrCmd=TRUE THEN
iStartAddrChangebale:=iStartAddr;
BMOV(pbyDataSrc:=pWrOne , uiSize:=128 , pbyDataDes:=pWrSrcMid);
RFID_ReadCmd_Mid :=FALSE;
RFID_WriteCmd_Mid:=TRUE;
iAutoState:=105;
END_IF
105:
IF Done=TRUE AND RfidErr=FALSE THEN
GeneralAlarm:=FALSE;
ELSIF RfidErr THEN
GeneralAlarm:=TRUE;
END_IF
IF Done=TRUE AND GeneralAlarm =FALSE THEN
RFID_ReadCmd_Mid :=FALSE;
RFID_WriteCmd_Mid:=FALSE;
iAutoState:=110;
ELSIF GeneralAlarm=TRUE THEN
iAutoState:=200;
END_IF
110:
IF AutoRdCmd=FALSE AND AutoWrCmd=TRUE THEN
iStartAddrChangebale:=iStartAddr+128;
BMOV(pbyDataSrc:=pWrTwo , uiSize:=128 , pbyDataDes:=pWrSrcMid);
RFID_ReadCmd_Mid :=FALSE;
RFID_WriteCmd_Mid:=TRUE;
iAutoState:=115;
END_IF
115:
IF Done=TRUE AND RfidErr=FALSE THEN
GeneralAlarm:=FALSE;
ELSIF RfidErr THEN
GeneralAlarm:=TRUE;
END_IF
IF Done=TRUE AND GeneralAlarm =FALSE THEN
RFID_ReadCmd_Mid :=FALSE;
RFID_WriteCmd_Mid:=FALSE;
iAutoState:=120;
ELSIF GeneralAlarm=TRUE THEN
iAutoState:=200;
END_IF
120:
IF AutoRdCmd=FALSE AND AutoWrCmd=TRUE THEN
iStartAddrChangebale:=iStartAddr+256;
BMOV(pbyDataSrc:=pWrThree , uiSize:=128 , pbyDataDes:=pWrSrcMid);
RFID_ReadCmd_Mid :=FALSE;
RFID_WriteCmd_Mid:=TRUE;
iAutoState:=125;
END_IF
125:
IF Done=TRUE AND RfidErr=FALSE THEN
GeneralAlarm:=FALSE;
ELSIF RfidErr THEN
GeneralAlarm:=TRUE;
END_IF
IF Done=TRUE AND GeneralAlarm =FALSE THEN
RFID_ReadCmd_Mid :=FALSE;
RFID_WriteCmd_Mid:=FALSE;
iAutoState:=130;
ELSIF GeneralAlarm=TRUE THEN
iAutoState:=200;
END_IF
130://RFID DATA WRITE FINISHE RETURN
IF GeneralAlarm=FALSE THEN
RW_Done:=TRUE;
RFID_ReadCmd_Mid :=FALSE;
RFID_WriteCmd_Mid:=FALSE;
iStartAddrChangebale:=0;
iAutoState:=0;
END_IF
200://RFID DATA WRITE OR READ ALARM
IF OPMODE.User_Interface_OUT.Reset THEN
GeneralAlarm:=FALSE;
TagNotExitAlarm:=FALSE;
RfidNotHeaderAlarm:=FALSE;
RFID_ReadCmd_Mid:=FALSE;
RFID_WriteCmd_Mid:=FALSE;
RW_Done:=FALSE;
iStartAddrChangebale:=0;
iAutoState:=0;
END_IF
END_CASE
END_IF
实例应用-LD
数据操作功能块封装
功能块封装功能类似数据库读写操作,自动读写数据和手动读写数据,访问二维数组中的数据操作。可通过二维数组的行列访问目标数据或通过指针访问目标数组。
以后有时间会抽时间分享一些TIA和Codesys的常用功能块使用方法。