当前位置: 首页 > article >正文

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

官方说明

 

功能说明

参数

类型

功能

 pbyDataSrcPOINTER TO BYTE指向源数组指针
uiSizeUINT要移动数据的BYTE数
pbyDataDesPOINTER 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的常用功能块使用方法。


http://www.kler.cn/a/391361.html

相关文章:

  • Linux搭建TRELLIS详细流程
  • mysql 查询优化之字段建立全文索引
  • Move AI技术浅析(二):输入与预处理
  • C/C++基础错题归纳
  • PyTorch 神经网络回归(Regression)任务:关系拟合与优化过程
  • Linux 基本使用和程序部署
  • P-tuning、Prompt-tuning和Prefix-tuning区别是什么?
  • Java 实现自定义 LRU 缓存
  • 【Effective C++】阅读笔记6
  • css2D变换用法
  • SobarQube实现PDF报告导出
  • Linux——基础指令2 + 权限
  • [SaaS] 数禾科技 AIGC生成营销素材
  • 35.Redis 7.0简介
  • ensp中配置ISIS以及ISIS不同区域的通信
  • pytorch torch.randint
  • 解决SLF4J: Class path contains multiple SLF4J bindings问题
  • 丹摩征文活动 | 搭建 CogVideoX-2b详细教程:用短短6秒展现创作魅力
  • labview实现上升沿和下降沿
  • 【海外SRC漏洞挖掘】谷歌语法发现XSS+Waf Bypass
  • SpringBoot下Bean的单例模式详解
  • Spring Boot编程训练系统:开发中的挑战与解决方案
  • PVE纵览-从零开始:了解Proxmox Virtual Environment
  • C++初阶——list
  • 【MySQL】MySQL函数之JSON_EXTRACT
  • python机器人Agent编程——使用swarm框架和ollama实现一个本地大模型和爬虫结合的手机号归属地天气查询Agent流(体会)