【发那科】【KAREL】读取当前的坐标系,并写入到寄存器

本文介绍了KAREL编程中的内置函数SET_POS_REG,用于在指定位置寄存器存储XYZWPR值,提供输入参数解析和操作状态说明。通过示例展示了如何在程序中使用该函数并验证其成功执行。
摘要由CSDN通过智能技术生成

--【KAREL 内置函数的介绍】

-- SET_POS_REG Built-In Procedure

-- Purpose: Stores an XYZWPR value in the specified position register

-- Syntax : SET_POS_REG(register_no, posn, status, group_no>)

-- Input/Output Parameters :

-- [in] register_no : INTEGER

-- [in] posn : XYZWPR

-- [out] status : INTEGER

-- [in] group_no : INTEGER

-- %ENVIRONMENT Group :REGOPE

-- Details:

-- • register_no specifies the position register in which to store the value.

-- • The position data is set in XYZWPR representation with no conversion.

-- • status explains the status of the attempted operation. If not equal to 0, then an error occurred.

-- • If group_no is omitted, the default group for the program is assumed. Data for other groups

-- is not changed.

-- • If group_no is specified, it must be in the range of 1 to the total number of groups defined on

-- the controller.

--【KAREL 内置函数的示例】



PROGRAM  reg_ex
----------------------------------------------------
-- Creation date: 2023.08.12
-- Created by: Ming.Li
----------------------------------------------------
-- Version: 0.0.0.0 - 00
----------------------------------------------------
-- Function: 【寄存器写入数据】
----------------------------------------------------

%COMMENT = 'REGISTER_EX1'
%ALPHABETIZE
%INCLUDE KLEVKEYS
%INCLUDE KLEVKMSK
%INCLUDE KLEVCCDF
%INCLUDE KLIOUOP
%INCLUDE KLIOTYPS

CONST
cc_success  = 0      -- Success status
cc_xyzwpr   = 2      -- Position Register has an XYZWPR
cc_jntpos   = 9      -- Position Register has a JOINTPOS

VAR
xyz :XYZWPR
jpos :JOINTPOS
r_val :REAL
prg_indx,
i_val,
pos_type,
num_axes,
status :INTEGER
r_flg :BOOLEAN


----------------------------------------------------
-- BEGIN REGISTER                           
----------------------------------------------------

BEGIN

-- Clear the TP USER menu screen    
write(chr(137),chr(128)); 
-- Force the TP USER menu to be visible
FORCE_SPMENU(TP_PANEL,SPI_TPUSER,1)

WRITE('Getting Current Position',cr)
-- Get the current position

xyz = CURPOS(0,0) 
WRITE('Storing Current position to PR[1]',cr)
-- Store the position in PR[1]
SET_POS_REG(1,xyz, status) 

-- -- verify SET_POS_REG is successful
IF (status = cc_success) THEN 
WRITE('Executing "PROG_VAL.TP"',cr)
ENDIF
-- --Execute ’PROG_VAL.TP’ starting at line 2. Do not pause on entry of PROG_VAL.

-- -- CALL_PROGLIN('PROG_VAL',2,prg_indx, FALSE)

END reg_ex

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值