|
|
/*********************************************************************
|
|
|
*文件说明: 卡接口,分为运动控制卡、IO卡、ad卡、
|
|
|
所有控制卡/通用类对象封装按此接口要求
|
|
|
*作者: logos
|
|
|
*日期: 2016/04/12
|
|
|
*修改日志: 2016/04/12 EW-0551 创建
|
|
|
|
|
|
***注意事项***
|
|
|
1. 无论哪种类型卡,都必须支持公共接口
|
|
|
2. 根据axis/io/ad数量获取相应操作接口,若接口检测不通过,则硬件加载会失败
|
|
|
io类提供通用IO输入输出的操作,总共3个接口,read_in/read_out/write_out,
|
|
|
若一个硬件包含IO类功能,则必须实现这3个接口。
|
|
|
3. ad卡提供read_ad功能,若包含此类型,则必须支持该接口
|
|
|
4. 如果一张卡axis数量不为0,则IO数量也不能为0.
|
|
|
5. 初始化参数描述/轴回原方法必须从get_dev_info接口返回,数量和数组大小匹配
|
|
|
***********************************************************************/
|
|
|
#pragma once
|
|
|
#ifndef _INCLUDE_MOTOR_H
|
|
|
#define _INCLUDE_MOTOR_H
|
|
|
#include "dtype.h"
|
|
|
|
|
|
/***********************************************
|
|
|
*Function: 获取硬件信息描述
|
|
|
*Intput: pDev 硬件信息结构体
|
|
|
*Output: pDev 硬件信息缓冲区
|
|
|
*Return: 成功返回0,失败返回错误码<0
|
|
|
*********************************************/
|
|
|
EXPORT_C int WINAPI get_dev_info(TDevInfo* pDev);
|
|
|
|
|
|
/***********************************************
|
|
|
*Function: 重置单轴状态、限位等
|
|
|
*Intput: cindex 卡号
|
|
|
axisIndex 轴号
|
|
|
*Output: NULL
|
|
|
*Return: 成功返回0,失败返回错误码<0
|
|
|
*********************************************/
|
|
|
EXPORT_C int WINAPI axis_reset(ushort cindex, ushort axisIndex);
|
|
|
|
|
|
/***********************************************
|
|
|
*Function: 单轴清零位置
|
|
|
*Intput: cindex 卡号
|
|
|
axisIndex 轴号
|
|
|
*Output: NULL
|
|
|
*Return: 成功返回0,失败返回错误码<0
|
|
|
*********************************************/
|
|
|
EXPORT_C int WINAPI axis_zero_pos(ushort cindex, ushort axisIndex);
|
|
|
|
|
|
/***********************************************
|
|
|
*Function: 单轴回原
|
|
|
*Intput: cindex 卡号
|
|
|
axisIndex 轴号
|
|
|
homeType 回原方式,根据 THomeTypeDesc 序号传递
|
|
|
pos 回原搜索距离
|
|
|
pspeed 回原速度
|
|
|
*Output: NULL
|
|
|
*Return: 成功返回0,失败返回错误码<0
|
|
|
*********************************************/
|
|
|
EXPORT_C int WINAPI axis_home(ushort cindex, ushort axisIndex, ushort homeType, double pos, double offset, double vel);
|
|
|
|
|
|
/***********************************************
|
|
|
*Function: 判断单轴是否正在运动
|
|
|
*Intput: cindex 卡号
|
|
|
axisIndex 轴号
|
|
|
*Output: NULL
|
|
|
*Return: 1表示正在运动 0表示不在运动中
|
|
|
*********************************************/
|
|
|
EXPORT_C int WINAPI axis_is_moving(ushort cindex, ushort axisIndex);
|
|
|
|
|
|
/***********************************************
|
|
|
*Function: 设置单轴速度,就绪/运动时都可用
|
|
|
*Intput: cindex 卡号
|
|
|
axisIndex 轴号
|
|
|
vel 运动速度 脉冲/ms
|
|
|
acc 运动加速度
|
|
|
dec 运动减速度
|
|
|
*Output: NULL
|
|
|
*Return: 成功返回0,失败返回错误码<0
|
|
|
*********************************************/
|
|
|
EXPORT_C int WINAPI axis_set_speed(ushort cindex, ushort axisIndex, double vel, double acc, double dec);
|
|
|
|
|
|
/***********************************************
|
|
|
*Function: 运动中修改单轴目标位置,仅单轴运动中可用,插补时不可用
|
|
|
*Intput: cindex 卡号
|
|
|
axisIndex 轴号
|
|
|
pos 目标位置 脉冲
|
|
|
*Output: NULL
|
|
|
*Return: 成功返回0,失败返回错误码<0
|
|
|
*********************************************/
|
|
|
EXPORT_C int WINAPI axis_set_pos(ushort cindex, ushort axisIndex, double pos);
|
|
|
|
|
|
/***********************************************
|
|
|
*Function: 停止单轴运动
|
|
|
*Intput: cindex 卡号
|
|
|
axisIndex 轴号
|
|
|
type 0: 平滑停止
|
|
|
1:紧急停止
|
|
|
*Output: NULL
|
|
|
*Return: 成功返回0,失败返回错误码<0
|
|
|
*********************************************/
|
|
|
EXPORT_C int WINAPI axis_stop(ushort cindex, ushort axisIndex, int type);
|
|
|
|
|
|
/***********************************************
|
|
|
*Function: 单轴相对移动(连续)
|
|
|
*Intput: cindex 卡号
|
|
|
axisIndex 轴号
|
|
|
dir 0 负方向 1 正方向
|
|
|
vel 运动速度 脉冲/ms
|
|
|
acc 运动加速度
|
|
|
dec 运动减速度
|
|
|
*Output: 无
|
|
|
*Return: 成功返回0,失败返回错误码<0
|
|
|
*********************************************/
|
|
|
EXPORT_C int WINAPI axis_move_jog(ushort cindex, ushort axisIndex, int dir, double vel, double acc, double dec);
|
|
|
|
|
|
/***********************************************
|
|
|
*Function: 单轴移动到指定位置(脉冲)
|
|
|
*Intput: cindex 卡号
|
|
|
axisIndex 轴号
|
|
|
pos 点位(脉冲)
|
|
|
vel 运动速度 脉冲/ms
|
|
|
acc 运动加速度
|
|
|
dec 运动减速度
|
|
|
*Output: NULL
|
|
|
*Return: 成功返回0,失败返回错误码<0
|
|
|
*********************************************/
|
|
|
EXPORT_C int WINAPI axis_move_pos(ushort cindex, ushort axisIndex, double pos, double vel, double acc, double dec);
|
|
|
|
|
|
/***********************************************
|
|
|
*Function: 单轴相对当前位置移动(脉冲)
|
|
|
*Intput: cindex 卡号
|
|
|
axisIndex 轴号
|
|
|
offset 偏移距离 有正负之分
|
|
|
vel 运动速度 脉冲/ms
|
|
|
acc 运动加速度
|
|
|
dec 运动减速度
|
|
|
*Output: 无
|
|
|
*Return: 成功返回0,失败返回错误码<0
|
|
|
*********************************************/
|
|
|
EXPORT_C int WINAPI axis_move_offset(ushort cindex, ushort axisIndex, double offset, double vel, double acc, double dec);
|
|
|
|
|
|
/***********************************************
|
|
|
*Function: 读取指定轴IO输入输出状态
|
|
|
*Intput: cindex 卡索引
|
|
|
axisIndex 轴索引
|
|
|
dio_type IO类型
|
|
|
*Output: NULL
|
|
|
*Return: 有信号为1,无信号为0
|
|
|
*********************************************/
|
|
|
EXPORT_C int WINAPI axis_read(ushort cindex, ushort axisIndex, EIOType dio_type);
|
|
|
|
|
|
/***********************************************
|
|
|
*Function: 对指定位轴IO操作
|
|
|
*Intput: cindex 卡索引
|
|
|
axisIndex 轴索引
|
|
|
do_type 输出IO类型
|
|
|
val 写入值 1 / 0
|
|
|
*Output: NULL
|
|
|
*Return: 成功返回0,失败返回错误码<0
|
|
|
*********************************************/
|
|
|
EXPORT_C int WINAPI axis_write(ushort cindex, ushort axisIndex, ushort val, EIOType do_type);
|
|
|
|
|
|
/***********************************************
|
|
|
*Function: 获取轴当前位置(脉冲)
|
|
|
*Intput: ardIndex, 卡号
|
|
|
axisIndex 轴号
|
|
|
postype 0 编码器位置 1 规划器位置
|
|
|
*Output: pval 当前点位数据
|
|
|
*Return: 参考EM_ERR_CODE
|
|
|
*********************************************/
|
|
|
EXPORT_C int WINAPI axis_get_pos(ushort cindex, ushort axisIndex, EMPosType postype, double *pval);
|
|
|
|
|
|
/***********************************************
|
|
|
*Function: 创建一个坐标系
|
|
|
*Intput: cindex, 卡号
|
|
|
pAxisIndex 轴号索引数组
|
|
|
nsize 数组大小,最少两个轴
|
|
|
*Output: NULL
|
|
|
*Return: 成功返回坐标系ID>=0 失败返回错误码<0
|
|
|
*********************************************/
|
|
|
EXPORT_C int WINAPI create_crd(ushort cindex, ushort *pAxisIndex, ushort nsize);
|
|
|
|
|
|
/***********************************************
|
|
|
*Function: 增加一个位置到直线插补运动队列
|
|
|
*Intput: crd 坐标系ID
|
|
|
ppos 位置数组(脉冲),大小必须是创建坐标系时的轴数量
|
|
|
nsize 数组大小,需跟创建坐标系时保持一致
|
|
|
vel 运动速度 脉冲/ms
|
|
|
acc 运动加速度
|
|
|
endvel 终点速度,默认为0
|
|
|
*Output: NULL
|
|
|
*Return: 成功返回0,失败返回错误码<0
|
|
|
PS: 根据卡类型决定支持最大多少轴插补
|
|
|
*********************************************/
|
|
|
EXPORT_C int WINAPI add_line_pos(int crd, double *ppos, ushort nsize, double vel, double acc, double endvel = 0);
|
|
|
|
|
|
/***********************************************
|
|
|
*Function: 增加两个位置到圆弧插补运动队列
|
|
|
*Intput: crd 坐标系ID
|
|
|
ppos1 位置数组(脉冲),大小必须是创建坐标系时的轴数量
|
|
|
ppos2 位置数组(脉冲),大小必须是创建坐标系时的轴数量
|
|
|
ppos3 位置数组(脉冲),大小必须是创建坐标系时的轴数量
|
|
|
nsize 数组大小,需跟创建坐标系时保持一致
|
|
|
vel 运动速度 脉冲/ms
|
|
|
acc 运动加速度
|
|
|
endvel 终点速度,默认为0
|
|
|
*Output: NULL
|
|
|
*Return: 成功返回0,失败返回错误码<0
|
|
|
PS: 圆弧插补只能基于两轴进行,通过ppos1,ppos2 ppos3 3个点计算得出
|
|
|
若点位数据超过两轴发生变化,则会运动失败
|
|
|
*********************************************/
|
|
|
EXPORT_C int WINAPI add_arc_pos(int crd, double *ppos1, double *ppos2, double *ppos3, ushort nsize, double vel, double acc, double endvel = 0);
|
|
|
|
|
|
/***********************************************
|
|
|
*Function: 启动插补运动
|
|
|
*Intput: crd 坐标系ID
|
|
|
*Output: NULL
|
|
|
*Return: 成功返回0,失败返回错误码<0
|
|
|
*********************************************/
|
|
|
EXPORT_C int WINAPI crd_move(int crd);
|
|
|
|
|
|
/***********************************************
|
|
|
*Function: 查询插补运动坐标系状态
|
|
|
*Intput: crd 坐标系ID
|
|
|
*Output: progress 返回当前已经完成的插补段数
|
|
|
*Return: 返回1标识在运动中,0不在运动
|
|
|
*********************************************/
|
|
|
EXPORT_C int WINAPI crd_is_moving(int crd, int *progress);
|
|
|
|
|
|
/***********************************************
|
|
|
*Function: 关闭一个坐标系
|
|
|
*Intput: crd 坐标系ID
|
|
|
*Output: NULL
|
|
|
*Return: 成功返回0,失败返回错误码<0
|
|
|
*********************************************/
|
|
|
EXPORT_C int WINAPI close_crd(int crd);
|
|
|
|
|
|
/***********************************************
|
|
|
*Function: 读取指定位通用输入io状态
|
|
|
*Intput: cindex 卡索引
|
|
|
in_index io索引号
|
|
|
*Output: NULL
|
|
|
*Return: 有信号为1,无信号为0
|
|
|
*********************************************/
|
|
|
EXPORT_C int WINAPI read_in(ushort cindex, ushort in_index);
|
|
|
|
|
|
/***********************************************
|
|
|
*Function: 获取指定位通用IO操作状态
|
|
|
*Intput: cindex 卡索引
|
|
|
out_index io索引号
|
|
|
*Output: NULL
|
|
|
*Return: 有信号为1,无信号为0,失败返回EM_ERR_CODE
|
|
|
*********************************************/
|
|
|
EXPORT_C int WINAPI read_out(ushort cindex, ushort out_index);
|
|
|
|
|
|
/***********************************************
|
|
|
*Function: 对指定位通用输出IO写入值
|
|
|
*Intput: cindex 卡索引
|
|
|
out_index io索引号
|
|
|
val 写入值 1 / 0
|
|
|
*Output: NULL
|
|
|
*Return: 成功返回0,失败返回错误码<0
|
|
|
*********************************************/
|
|
|
EXPORT_C int WINAPI write_out(ushort cindex, ushort out_index, ushort val);
|
|
|
|
|
|
/***********************************************
|
|
|
*Function: 读取指定通道的模拟量值
|
|
|
*Intput: cindex 卡索引
|
|
|
index 通道索引
|
|
|
*Output: pVal 待读取模拟量
|
|
|
*Return: 成功返回0,失败返回错误码<0
|
|
|
*********************************************/
|
|
|
EXPORT_C int WINAPI read_ad(ushort cindex, ushort index, double* pVal);
|
|
|
|
|
|
/***********************************************
|
|
|
*Function: 对指定通道写入模拟量
|
|
|
*Intput: cindex 卡索引
|
|
|
index 通道索引
|
|
|
val 模拟量
|
|
|
*Output: NULL
|
|
|
*Return: 成功返回0,失败返回错误码<0
|
|
|
*********************************************/
|
|
|
EXPORT_C int WINAPI write_ad(ushort cindex, ushort index, double val);
|
|
|
|
|
|
#endif //防止重复包含
|