📄 mechineparams.cpp
字号:
// mechineparams.cpp: implementation of the mechineparams class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "test.h"
#include "mechineparams.h"
#include "func.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
extern SYSTEMTIME t1,t2;
BOOL brun=0;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
mechineparams::mechineparams()
{axisRRatio=0.2*.5;
axisZRatio=15/40.000;
Zstep=3.;
axisZscope=84.;
controltime=0.0002;
fenpin[0]=1.;fenpin[1]=1.;
baseangle[0]=0.072;baseangle[1]=0.072;
}
mechineparams::~mechineparams()
{
}
short mechineparams::axisRrun(double Spd, double pos, double zdt,double acc, double pulse, int time)
{short rtn;
//GTInitial();
//InputCfg();
//AxisInitial();
rtn=GT_Axis(2);
GT_SetAtlPos(0);
GT_ClrSts();
pos=pos/(baseangle[1]*fenpin[1]*axisRRatio);
Spd=Spd/(baseangle[1]*fenpin[1]*axisRRatio)*controltime;
//rtn=GT_PrflS(); //error(rtn); // 设置运动模式为S 曲线模式
rtn=GT_SetMAcc(acc); error(rtn); // 设置最大加速度为0.004
rtn=GT_SetVel(Spd); error(rtn); // 设置目标速度
rtn=GT_SetPos(pos); error(rtn); // 设置目标位置
rtn=GT_Update(); error(rtn); // 刷新参数
GetSystemTime(&t1);
brun=1;
return rtn;
}
short mechineparams::axisZrun(double Spd, double pos, double zdt,double acc, double pulse, int time)
{short rtn=0;
//GTInitial();
//InputCfg();
//AxisInitial();
rtn=GT_Axis(1);
GT_SetAtlPos(0);
GT_ClrSts();
pos=pos/(baseangle[0]*fenpin[0]*axisZRatio*Zstep/360);
Spd=Spd/(baseangle[0]*fenpin[0]*axisZRatio*Zstep/360)*controltime;
//rtn=GT_PrflS(); //error(rtn); // 设置运动模式为S 曲线模式
rtn=GT_SetMAcc(acc); //error(rtn); // 设置最大加速度为0.004
rtn=GT_SetVel(Spd); //error(rtn); // 设置目标速度
rtn=GT_SetPos(pos); //error(rtn); // 设置目标位置
rtn=GT_Update(); //error(rtn);
GetSystemTime(&t1);// 刷新参数
brun=1;
return rtn;
}
double mechineparams::atlzpos()
{
long Apos;
GT_Axis(1);
GT_GetAtlPos(&Apos);
return Apos*baseangle[0]*fenpin[0]*axisZRatio*Zstep/360;
}
double mechineparams::atlrpos()
{
long Apos;
GT_Axis(2);
GT_GetAtlPos(&Apos);
return Apos*baseangle[0]*fenpin[0]*axisRRatio;
}
short mechineparams::axisRVrun(double Spd, double zdt, double acc, double pulse, int time)
{short rtn=0;
Spd=Spd/(baseangle[1]*fenpin[1]*axisRRatio)*controltime;
//rtn=GT_PrflS(); //error(rtn); // 设置运动模式为S 曲线模式
rtn=GT_Axis(2);
rtn=GT_SetMAcc(0.1); //error(rtn); // 设置最大加速度为0.004
rtn=GT_SetVel(Spd); //error(rtn); // 设置目标速度
rtn=GT_Update(); //error(rtn); // 刷新参数
GetSystemTime(&t1);
brun=1;
return 0;
}
short mechineparams::axisZVrun(double Spd, double zdt, double acc, double pulse, int time)
{short rtn=0;
Spd=Spd/(baseangle[0]*fenpin[0]*axisZRatio*Zstep/360)*controltime;
//rtn=GT_PrflS(); //error(rtn); // 设置运动模式为S 曲线模式
rtn=GT_Axis(1);
rtn=GT_SetMAcc(acc);// error(rtn); // 设置最大加速度为0.004
rtn=GT_SetVel(Spd); //error(rtn); // 设置目标速度
rtn=GT_Update(); //error(rtn); // 刷新
GetSystemTime(&t1);
brun=1; return 0;
}
double mechineparams::axisatlsit(int axisnum,int pulsecnt)
{
if(axisnum==1)
return pulsecnt*(baseangle[0]*fenpin[0]*axisZRatio*Zstep/360);
else
if(axisnum==2)
return pulsecnt*(baseangle[1]*fenpin[1]*axisRRatio);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -