[Codesys]常用功能块应用分享-BMOV功能块功能介绍及其使用实例说明

官方说明

功能说明

|------------|-----------------|-------------|
| 参数 | 类型 | 功能 |
| pbyDataSrc | POINTER TO BYTE | 指向源数组指针 |
| uiSize | UINT | 要移动数据的BYTE数 |
| pbyDataDes | POINTER TO BYTE | 指向目标数组指针 |
| | | |

实例应用-ST

Crystal 复制代码
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的常用功能块使用方法。

相关推荐
EstrangedZ3 个月前
codesys进行控制虚拟轴运动时出现的一些奇怪bug的解释
codesys
深圳信迈科技DSP+ARM+FPGA3 个月前
【ARM+Codesys 客户案例 】 基于RK3568/A40i/STM32+CODESYS在工厂自动化中的应用:铆接机
arm开发·stm32·嵌入式硬件·自动化·codesys
深圳信迈科技DSP+ARM+FPGA3 个月前
【ARM+Codesys 客户案例 】 基于RK3568/A40i/STM32+CODESYS在工厂自动化中的应用:伊顿穆勒模块化控制器XC200
arm开发·stm32·嵌入式硬件·自动化·codesys
深圳信迈科技DSP+ARM+FPGA3 个月前
【ARM+Codesys 客户案例 】基于RK3568/A40i/STM32+CODESYS开发的控制器在自动输送分拣系统上的应用,支持定制
arm开发·codesys
深圳信迈科技DSP+ARM+FPGA3 个月前
物联网HMI/网关搭载ARM+CODESYS实现软PLC+HMI一体化
物联网·codesys
Lilixxs5 个月前
B站大课堂-自动化精品视频(个人存档)
自动化·教程·plc·运动控制·工业控制·codesys·bilibili
深圳信迈科技DSP+ARM+FPGA6 个月前
【ARM+Codesys案例】基于全志T3+Codesys软PLC的3C点胶边缘控制解决方案:整合了运动控制、视觉、激光测高等技术
codesys
xiaoyaoyou.xyz1 年前
CoDeSys系列-1、CoDeSys了解及资料收集
plc·codesys
WX_LW1 年前
codesys 6轴机器人正解程序
st