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