📄 datatype.h
字号:
/******************************************************************
* 文件名称: DataType . h *
* 文件用途: 自定义数据类型声明头文件 *
* *
* *
* *
*******************************************************************/
#ifndef __DATATYPE_H__
#define __DATATYPE_H__
//#include "W79E532.h"
//#include <absacc.h>
/*----------- 自定义数据类型----------*/
#define uchar unsigned char
#define uint unsigned int
/*------------MCU与DSP接口------------------*/
//输入/输出缓冲区数据结构
struct MCUOUTPUTBUFFER
{
//运动
long lYIncrement;
long lZIncrement;
uint unReserve0[4]; //保留
long lI;
long lK;
long lR;
long lFeedrate;
uint unReserve1[3]; //保留
//状态
uchar ucReserve2;
uchar ucCommandStatus; //命令状态字
uchar ucReserve3;
uchar ucMotionMode; //运动模式
uchar ucReserve4;
uchar ucScaleMeter; //量仪信号
uchar ucReserve5;
uchar ucMCUOperateMode; //MCU工作模式
uint unReserve6; //保留
//输出
uchar ucF[8]; //输出
uint unReserve7[2]; //保留
long lDelayTimeIO; //I/O延时
uint unReserve8[2]; //保留
};
struct MCUINPUTBUFFER
{
//运动
long lProgramY;
long lProgramZ;
long lMachineY;
long lMachineZ;
long lLeaveY;
long lLeaveZ;
int nYservoError;
int nZservoError;
uint unReserve0[4]; //保留
//输入
uchar ucG[12]; //I/O输入
//状态
uchar ucReserve1;
uchar ucAlarmCode; //报警代码
uchar ucReserve2;
uchar ucMotionStatus; //运动状态
uint unReserve3[2]; //保留
};
//参数值数据结构
struct PARAMETERVALUE
{
//G00
uint unYHomeFastSpeed;
uint unZHomeFastSpeed;
uint unYAccelerateTime;
uint unZAccelerateTime;
uint unYFastSpeed;
uint unZFastSpeed;
//G01
uint unYHomeSlowSpeed;
uint unZHomeSlowSpeed;
uint unYCutAccelerateTime;
uint unZCutAccelerateTime;
uint unFastMultipleScale;
// uchar ucReserve1;
uint unFeedMultipleScale;
uchar ucReserve2;
uchar ucHWMultiple;
//其他运动参数
uint unYBacklash;
uint unZBacklash;
uchar ucReserve3; //保留字节
uchar ucBitParameter1; //位参数1
uchar ucReserve4; //保留字节
uchar ucBitParameter2; //位参数2
uchar ucReserve5; //保留字节
uchar ucBitParameter3; //位参数3
uchar ucReserve6; //保留字节
uchar ucBitParameter4; //位参数3
uchar ucReserve7; //保留字节
uchar ucBitParameter5; //位参数3
uchar ucReserve8; //保留字节
uchar ucBitParameter6; //位参数3
uint unMTime;
uint unYPitch;
uint unZPitch;
uint unYMotorGear;
uint unZMotorGear;
uint unYLeadScrewGear;
uint unZLeadScrewGear;
uint unYVelocitySensitivity;
uint unZVelocitySensitivity;
uint unYEncoderResolution;
uint unZEncoderResolution;
//PID参数
uint unKYp;
uint unKYi;
uint unIYlimit;
uint unKYd;
uint unKYv;
uint unKZp;
uint unKZi;
uint unIZlimit;
uint unKZd;
uint unKZv;
uint unYServoError;
uint unZServoError;
uint unYZeroOffset;
uint unZZeroOffset;
uint unYPitchOrigin;
uint unYPitchInteral;
uint unZPitchOrigin;
uint unZPitchInteral;
uint unYDegree;
uint unZDegree;
uint unFastBackStroke;
// 不用传送到DSP的参数
long lYPStroke;
long lYNStroke;
long lZPStroke;
long lZNStroke;
uint unSpindleLow;
uint unSpindleMiddle;
uint unSpindleHigh;
uint unBrakeTime;
uint unNoInterval; //顺序号间隔
long lMDIFeedRate;
uint unYHomeGrid;
uint unZHomeGrid;
};
//PLC诊断信号数据结构
struct PLCSIGNEL
{
uchar ucG[12];
uchar ucF[8];
uchar ucX[6];
uchar ucY[4];
uchar ucR[16];
uchar ucT[2];
uchar ucC[2];
uint unTPresent[8]; //定时器预置值
uint unCPresent[8]; //计数器预置值
uint unTCurrent[8]; //定时器当前值
uint unCCurrent[8]; //计数器当前值
};
//显示参数数据结构
struct PARAMETER
{
uchar ucType; //数值类型,0=整数(2Byte),1=浮点数(2Byte),2=二进制数(1Byte),3=浮点数(4Byte),浮点数保留3位小数
long lMin; //最小值
long lMax; //最大值
void xdata *pParameterAdr; //参数的地址
};
/*-----------------程序编译数据结构------------------*/
union UINTandPointer //无符号整数与其指针共用体
{
uint unData;
uint xdata * punData;
};
union LONGandPointer //长整数与其指针共用体
{
long lData;
long xdata * plData;
};
union UCHARandPointer //无符号字符与其指针共用体
{
uchar ucData;
uint xdata * punData;
};
union LONGandVoidPointer //长整数与空指针共用体
{
long lData;
void xdata * pData;
};
//代码缓冲区数据结构
struct CODECOMPILEBUFFER
{
//G代码
uchar ucGCodeGroup1;
uchar ucGCodeGroup2;
uchar ucGCodeGroup3;
//运动参数
union LONGandPointer lProgramY;
union LONGandPointer lProgramZ;
union LONGandPointer lFeedRate;
union LONGandPointer lI;
union LONGandPointer lK;
union LONGandPointer lR;
uchar ucMCodeGroup1;
uint unJumpRowNo;
union UCHARandPointer ucCallTimes;
union LONGandPointer lDelayTime; //延时时间
uchar ucDataType; //数据类型标志位(bit=0:常数;bit=1:指针)
// |bit7|bit6|bit5|bit4|bit3|bit2|bit1|bit0|=
// | Y | Z | F | L | D | I | K | R |
};
//输出命令结构
struct OUTPUTCOMMAND
{
uchar ucOutputByteNo; //输出字节编号
uchar ucOutputByte; //输出字节
uchar ucBitValue; //输出位值
uchar ucLightDeal; // 指示灯处理代号
union LONGandPointer lDelayTime; //延时时间
};
//输入命令结构
struct INPUTCOMMAND
{
uchar ucInputByteNo; //输入字节编号
uchar ucInputByte; //输入字节
uchar ucBitValue; //输入位值
uint unJumpRowNo; //跳转行号
};
struct MOTIONCOMMAND
{
union LONGandPointer lY;
union LONGandPointer lZ;
union LONGandPointer lFeedrate;
};
//子程序调用命令
struct CALLCOMMAND
{
uint unJumpRowNo; //子程序的开始行号
union UCHARandPointer ucCallTimes; //调用次数
uint ucRemainTimes; //剩余调用次数
};
//宏指令结构
struct MACROCOMMAND
{
union LONGandVoidPointer lResult; //运算结果
union LONGandVoidPointer lData1; //操作数1
union LONGandVoidPointer lData2; //操作数2
};
//命令内容共用体
union COMMANDDATA
{
struct MOTIONCOMMAND MotionCommand;
struct OUTPUTCOMMAND OutputCommand;
struct INPUTCOMMAND InputCommand;
struct CALLCOMMAND CallCommand;
struct MACROCOMMAND MacroCommand;
union LONGandPointer lDelayTime;
uint unJumpRowNo;
};
//命令存储结构
struct COMMAND
{
uint unRowNo; //行号
uchar ucCommandType; //命令类型
uchar ucDataFlag; //数据类型标志 |bit7|bit6|bit5|bit4|bit3|bit2|bit1|bit0|=|Y|Z|F|L|D|I|K|R|=|Data1Pointer|Data2Pointer|Data1Type|Data2Type|ResultType|Operator2~0|
union COMMANDDATA CommandData; //命令数据
};
/*----------------程序存储数据结构--------------------------*/
//文件管理表数据结构
struct FATNODE
{
uint unFileStart; //NC 程序文件在程序代码空间的开始位置的索引号
uchar ucComplieFlag; //编译结果标志(0-错误;1-主程序编译通过;2-子程序编译通过)
};
//PLC存储数据结构
struct PLC_CODE
{
uchar ucPLCCommandType; //命令类型
uchar ucPLCAddress[2]; //命令地址(ucPLCAddress[0]-字节地址;ucPLCAddress[1]-位地址)
};
/*---------------------坐标-----------------------------------*/
//位置点数据结构
struct POINT
{
long lY;
long lZ;
};
/*--------------------显示----------------------------------------*/
//显存光标位置指针
union CURSOR_ADR
{
uint Adr ; //光标指针位置
struct
{
unsigned char AdrH; //光标指针位置高字节
unsigned char AdrL; //光标指针位置低字节
}AdrByte;
};
union UINTandBYTE //无符号整数与字节的公用体
{
uint unData;
struct //高低字节结构体
{
uchar ucDataH;
uchar ucDataL;
}DataByte;
};
enum AlarmCode
{
ESP, //0
PLCRunError,
PLCProgramError,
YDriverAlarm,
ZDriverAlarm,
YServoError, //5
ZServoError,
YAdjustErrorN,
YAdjustErrorP,
ZAdjustErrorN,
ZAdjustErrorP, //10
ParameterAlarm,
ParameterError,
YJLimtP,
YJLimtN,
ZJLimtP, //15
ZJLimtN,
URGENTBACK,
YPLimtP,
YPLimtN,
ZPLimtP, //20
ZPLimtN,
GWMOver,
HPMover,
RMOver,
YNoHome, //25
ZNoHome,
LiquidLow,
NoAlarm //28
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -