#region 自动运行流程
private void AutoRunProcess()
{
AddLog(0, "系统归零完成,等待触发");
//初始化当前步骤
CurrentStep = RunStep.RunReady;
bool fRun = false;
bool fOver = false;
int Error = 0;
int CycleTimes = 0;
while (true)
{
//检测是否按下启动信号
int start = Dmc2410.d2410_read_inbit(0, 2);
if (start == 0)
{
fRun = true;
CurrentStep = RunStep.MoveToReclaimer;
}
if (fRun)
{
AddLog(0, "系统开始生产...");
MySQLHelper.Log("系统开始生产...", 0, CommonMethods.objAdmin.LoginName);
fRun = false;
SysStatus = 1;
while (true)
{
switch (CurrentStep)
{
case RunStep.MoveToReclaimer:
UpdateStep("1:前往取料口");
if (CycleTimes == 0)
{
Dmc2410.d2410_set_position(XAxis, 0); // 指定轴号, 绝对位置值
Dmc2410.d2410_set_position(YAxis, 0);
//设置直线插补的参数
/*
void d2410_set_vector_profile(double Min_Vel,double Max_Vel,double Tacc,
double Tdec)
功 能:设定插补矢量运动曲线的起始速度、运行速度、加速时间、减速时间
参 数:Min_Vel 起始速度,单位 pps pps,pulse per second ,用来表示步进电机的转速
Max_Vel 运行速度,单位 pps
Tacc 总加速时间,单位 s
Tdec 总减速时间,单位 s
*/
Dmc2410.d2410_set_vector_profile(objConfig.VelMin, objConfig.VelMax, objConfig.Tac, objConfig.Tac);
//指定任意两轴以对称的梯形速度曲线做插补运动
/*
void d2410_t_line2(WORD axis1,long Dist1,WORD axis2,long Dist2,WORD
posi_mode)
功 能:指定任意两轴以对称的梯形速度曲线做插补运动
参 数:axis1 指定两轴插补的第一轴
axis2 指定两轴插补的第二轴
Dist1 指定 axis1 的位移值,单位:脉冲数
Dist2 指定 axis2 的位移值,单位:脉冲数
posi_mode 位移模式设定:0 表示相对位移,1 表示绝对位移
返回值:无
*/
Dmc2410.d2410_t_line2(XAxis, objConfig.OrginX, YAxis, objConfig.OrginY, 0);
}
else
{
//设置直线插补的参数
Dmc2410.d2410_set_vector_profile(objConfig.VelMin, objConfig.VelMax, objConfig.Tac, objConfig.Tac);
Dmc2410.d2410_t_line2(XAxis, objConfig.OutletX, YAxis, objConfig.OutletY, 0);
}
/*
WORD d2410_check_done(WORD axis)
功 能:检测指定轴的运动状态,停止或是在运行中。
参 数:axis 指定轴号
返回值:0 表示指定轴正在运行,1 表示指定轴已停止。
*/
while (Dmc2410.d2410_check_done(XAxis) == 0 || Dmc2410.d2410_check_done(YAxis) == 0)
{
if (IsAutoStop)
{
fOver = true;
break;
}
Thread.Sleep(10);
}
if (CycleTimes > 0)
{
Invoke(new Action(() =>
{
this.pointCurve1.ClearAllPoints();
}));
}
break;
case RunStep.ReclaimerWait:
//实际项目在这里需要检测是否有料
UpdateStep("2:检测是否有料");
Thread.Sleep(2000);
break;
case RunStep.ReclaimerDown:
UpdateStep("3:取料口下降");
Dmc2410.d2410_set_position(ZAxis, 0);
Dmc2410.d2410_set_st_profile(ZAxis, objConfig.VelMin, objConfig.VelMax, objConfig.Tac, objConfig.Tac, objConfig.STac, objConfig.STac);
/*
void d2410_s_pmove(WORD axis,long Dist,WORD posi_mode)
功 能:使指定轴以对称 S 形速度曲线做定长位移运动
参 数:axis 指定轴号
Dist (绝对/相对)位移值,单位:脉冲数
posi_mode 位移模式设定:0 表示相对位移,1 表示绝对位移
*/
Dmc2410.d2410_s_pmove(ZAxis, objConfig.DownZAxis, 0);
while (Dmc2410.d2410_check_done(ZAxis) == 0)
{
if (IsAutoStop)
{
fOver = true;
break;
}
Thread.Sleep(10);
}
break;
case RunStep.ReclaimerGrap:
UpdateStep(
雷赛运动控制卡例子
最新推荐文章于 2024-07-17 09:17:26 发布

最低0.47元/天 解锁文章
2851

被折叠的 条评论
为什么被折叠?



