/// <summary> /// 切换轴运动为Jog运动 /// </summary> /// <param name="nCardNum"></param> /// <param name="nAxis">轴号</param> /// <returns></returns> public override short PrfJog(short nCardNum, short nAxis) { short nRtn = 0; nRtn |= CMc.GT_PrfJog(nCardNum, nAxis); return(nRtn); }
/// <summary> /// JOG移动 /// </summary> /// <param name="nCardNum"></param> /// <param name="nAxis">轴号</param> /// <param name="dVel"></param> /// <param name="dAcce"></param> /// <returns></returns> public override short JogMove(short nCardNum, short nAxis, double dVel, double dAcce) { short nRtn = 0; if (nCardNum < 0 || nAxis > m_maxAxisNum) { return(-1); } //获取标志位状态 nRtn |= CMc.GT_ClrSts(nCardNum, 1, m_maxAxisNum); int sts; nRtn |= CMc.GT_GetSts(nCardNum, nAxis, out sts, 1, out m_oClk); int mode; nRtn |= CMc.GT_GetPrfMode(nCardNum, nAxis, out mode, 1, out m_oClk); //mode值 //0:trap 1:Jog 2:S 3:PT 4:PVS 5:interpolation 6:gear if ((sts & 0x400) != 0) //运动情况下可以改变速度和加速度 { if (1 != mode) { return(nRtn); } } else //静止情况下才能修改运动模式 { if (1 != mode) { nRtn |= CMc.GT_PrfJog(nCardNum, nAxis); } } //设置Jog运动参数 CMc.JOG_PRM jogPrm; jogPrm.m_acc = dAcce; //加速度,单位“脉冲/毫秒2” jogPrm.m_dec = dAcce; //减速度,单位“脉冲/毫秒2” jogPrm.m_smooth = 0.625; //平滑系数,取值范围[0,1] nRtn |= CMc.GT_SetJogPrm(nCardNum, nAxis, ref jogPrm); //启动运动 nRtn |= CMc.GT_SetVel(nCardNum, nAxis, dVel); //设置目标速度,单位是“脉冲/毫秒” nRtn |= CMc.GT_Update(nCardNum, 1 << (nAxis - 1)); return(nRtn); }
/// <summary> /// 设置Jog运动参数 /// </summary> /// <param name="nCardNum"></param> /// <param name="nAxis">轴号</param> /// <param name="acc">加速度 单位“脉冲/毫秒2”</param> /// <param name="dec">减速度 单位“脉冲/毫秒2”</param> /// <param name="smooth">平滑系数,取值范围[0,1]</param> /// <returns></returns> public override short SetJogPrm(short nCardNum, short nAxis, double acc, double dec, double smooth = 0) { //设置Jog运动参数 short nRtn = 0; CMc.GT_PrfJog(nCardNum, nAxis); CMc.JOG_PRM mytprfvel; mytprfvel.m_acc = acc; //加速度,单位“脉冲/毫秒2” mytprfvel.m_dec = dec; //减速度,单位“脉冲/毫秒2” mytprfvel.m_smooth = smooth; //平滑系数,取值范围[0,1] nRtn |= CMc.GT_SetJogPrm(nCardNum, nAxis, ref mytprfvel); return(nRtn); }