1、ZTM卡增加清零功能

2、固高总线卡优化位置触发函数
master
lhiven 1 year ago
parent 8c3dcd9910
commit a34f3f1f6b

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.20.24.1")]
[assembly: AssemblyVersion("2.20.24.2")]
//[assembly: AssemblyFileVersion("1.0.0.0")]

@ -49,6 +49,8 @@
this.txtHomeOffset = new System.Windows.Forms.TextBox();
this.label23 = new System.Windows.Forms.Label();
this.label12 = new System.Windows.Forms.Label();
this.txtNeedGoHome = new System.Windows.Forms.TextBox();
this.label51 = new System.Windows.Forms.Label();
this.txtHomeVelMode = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
@ -123,8 +125,8 @@
this.txtPulseOutDir = new System.Windows.Forms.TextBox();
this.label18 = new System.Windows.Forms.Label();
this.label19 = new System.Windows.Forms.Label();
this.label51 = new System.Windows.Forms.Label();
this.txtNeedGoHome = new System.Windows.Forms.TextBox();
this.label52 = new System.Windows.Forms.Label();
this.txtAssistEncoder = new System.Windows.Forms.TextBox();
this.gboxCardProperty.SuspendLayout();
this.gboxHomePro.SuspendLayout();
this.gboxMotorPro.SuspendLayout();
@ -335,6 +337,22 @@
this.label12.TabIndex = 0;
this.label12.Text = "回原后偏移:";
//
// txtNeedGoHome
//
this.txtNeedGoHome.Location = new System.Drawing.Point(159, 123);
this.txtNeedGoHome.Name = "txtNeedGoHome";
this.txtNeedGoHome.Size = new System.Drawing.Size(100, 21);
this.txtNeedGoHome.TabIndex = 1;
//
// label51
//
this.label51.AutoSize = true;
this.label51.Location = new System.Drawing.Point(59, 126);
this.label51.Name = "label51";
this.label51.Size = new System.Drawing.Size(83, 12);
this.label51.TabIndex = 0;
this.label51.Text = "是否需要回原:";
//
// txtHomeVelMode
//
this.txtHomeVelMode.Location = new System.Drawing.Point(159, 88);
@ -384,6 +402,7 @@
this.gboxMotorPro.Controls.Add(this.label17);
this.gboxMotorPro.Controls.Add(this.txtAlarmLogic);
this.gboxMotorPro.Controls.Add(this.txtEnableEmg);
this.gboxMotorPro.Controls.Add(this.txtAssistEncoder);
this.gboxMotorPro.Controls.Add(this.txtAbsoluteEncoder);
this.gboxMotorPro.Controls.Add(this.txtCurrent);
this.gboxMotorPro.Controls.Add(this.txtHcmpPulseWidth);
@ -398,6 +417,7 @@
this.gboxMotorPro.Controls.Add(this.txtPulseOneRound);
this.gboxMotorPro.Controls.Add(this.label48);
this.gboxMotorPro.Controls.Add(this.txtDecTime);
this.gboxMotorPro.Controls.Add(this.label52);
this.gboxMotorPro.Controls.Add(this.label45);
this.gboxMotorPro.Controls.Add(this.label5);
this.gboxMotorPro.Controls.Add(this.label9);
@ -1010,21 +1030,21 @@
this.label19.TabIndex = 0;
this.label19.Text = "是否启用编码器:";
//
// label51
// label52
//
this.label51.AutoSize = true;
this.label51.Location = new System.Drawing.Point(59, 126);
this.label51.Name = "label51";
this.label51.Size = new System.Drawing.Size(83, 12);
this.label51.TabIndex = 0;
this.label51.Text = "是否需要回原:";
this.label52.AutoSize = true;
this.label52.Location = new System.Drawing.Point(343, 568);
this.label52.Name = "label52";
this.label52.Size = new System.Drawing.Size(83, 12);
this.label52.TabIndex = 0;
this.label52.Text = "辅助值编码器:";
//
// txtNeedGoHome
// txtAssistEncoder
//
this.txtNeedGoHome.Location = new System.Drawing.Point(159, 123);
this.txtNeedGoHome.Name = "txtNeedGoHome";
this.txtNeedGoHome.Size = new System.Drawing.Size(100, 21);
this.txtNeedGoHome.TabIndex = 1;
this.txtAssistEncoder.Location = new System.Drawing.Point(436, 565);
this.txtAssistEncoder.Name = "txtAssistEncoder";
this.txtAssistEncoder.Size = new System.Drawing.Size(100, 21);
this.txtAssistEncoder.TabIndex = 1;
//
// AxisProperty
//
@ -1145,5 +1165,7 @@
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox txtNeedGoHome;
private System.Windows.Forms.Label label51;
private System.Windows.Forms.TextBox txtAssistEncoder;
private System.Windows.Forms.Label label52;
}
}

@ -1,4 +1,7 @@
using GTN;
using gts;
using Newtonsoft.Json;
using Rs.Framework;
using Rs.Motion.Base;
using Rs.Motion.Base.Config;
using System;
@ -1357,13 +1360,17 @@ namespace Rs.Motion.GugaoEcat
public override ErrorCode SetPosCompare(ushort channel, double[] postions)
{
apiResult = mc_ecat.GTN_PosCompareStatus(core, (short)channel, out mc_ecat.TPosCompareStatus pstatus);
//apiResult = mc_ecat.GTN_PosCompareStatus(core, (short)channel, out mc_ecat.TPosCompareStatus pstatus);
ClearCompare(channel);
//apiResult = mc_ecat.GTN_PosCompareClear(core, (short)channel);
//if(apiResult!=0)
//return ErrorCode.Fail;
short permit = 0x02;
apiResult = mc_ecat.GTN_SetTerminalPermitEx(core,0, mc_ecat.MC_HSO, ref permit,0x01,0x01);
//short permit = (short)(1 << channel);
short[] permit = new short[2];
permit[0] = 0x02;//第一路位置比较
permit[1] = 0x04;//第二路位置比较
apiResult = mc_ecat.GTN_SetTerminalPermitEx(core,0, mc_ecat.MC_HSO, ref permit[0],1, 2);
LogHelper.Debug($"mc_ecat.GTN_SetTerminalPermitEx({core},0, {mc_ecat.MC_HSO}, {permit},{(short)channel},0x01) ret={apiResult}");
//if (apiResult != 0)
//return ErrorCode.Fail;
//apiResult = mc_ecat.GTN_SetTerminalPermit(core, 0, mc_ecat.MC_HSO, (ushort)(1 << channel));
@ -1379,7 +1386,10 @@ namespace Rs.Motion.GugaoEcat
cmpMode.outputPulseWidth =(ushort)Config.HcmpPulseWidth;
cmpMode.sourceMode = 2;
cmpMode.sourceX =(short) Config.AssistEncoder;
string json=JsonConvert.SerializeObject(cmpMode);
apiResult = mc_ecat.GTN_SetPosCompareMode(core, (short)channel, ref cmpMode);
LogHelper.Debug($"mc_ecat.GTN_SetPosCompareMode({core}, 1 ,ref cmpMode); json={json} ret={apiResult}");
if (apiResult != 0)
return ErrorCode.Fail;
List<double> posPulse = new List<double>();
@ -1398,11 +1408,11 @@ namespace Rs.Motion.GugaoEcat
foreach (double data in posPulse)
{
mc_ecat.TPosCompareData cmpData = new mc_ecat.TPosCompareData();
cmpData.hso = 0x01;
cmpData.gpo = 0x01;
cmpData.hso = 0x03;
cmpData.gpo = 0x03;
cmpData.pos = (int)data;
cmpData.segmentNumber = seg++;
mc_ecat.GTN_PosCompareData(1, 1, ref cmpData);
mc_ecat.GTN_PosCompareData(1, (short)channel, ref cmpData);
}
apiResult = mc_ecat.GTN_PosCompareStart(core, (short)channel);
@ -1412,6 +1422,38 @@ namespace Rs.Motion.GugaoEcat
return ErrorCode.Ok;
}
public override ErrorCode CompareStatus(out short _pStatus, out int _pCount)
{
_pStatus = 0;
_pCount = 0;
apiResult = mc_ecat.GTN_PosCompareStatus(core, 2, out mc_ecat.TPosCompareStatus status);
string json = JsonConvert.SerializeObject(status);
LogHelper.Debug($"mc_ecat.GTN_PosCompareStatus({core}, 2, out mc_ecat.TPosCompareStatus status);status_json{json}");
//apiResult = mc_pulse.GT_CompareStatus((short)Config.CardId, out _pStatus, out _pCount);
if (apiResult != 0)
{
return ErrorCode.Fail;
}
return ErrorCode.Ok;
}
public override ErrorCode ComparePulse(ushort channel, bool dp = true)
{
short value = (short)channel;
if (value != 0)
{
value = (short)(1 << channel);
}
apiResult = mc_ecat.GTN_PosComparePulse(core, 1, 1, 1, 0);
LogHelper.Debug($"mc_ecat.GTN_PosComparePulse({core}, 1, 1, 1, 0) ret={apiResult}");
if (apiResult != 0)
{
return ErrorCode.Fail;
}
return ErrorCode.Ok;
}
public override ErrorCode ClearCompare(ushort uChannel)
{
apiResult = mc_ecat.GTN_PosCompareStop(core, (short)uChannel);

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.20.24.8")]
[assembly: AssemblyVersion("2.20.24.9")]
//[assembly: AssemblyFileVersion("1.0.0.0")]

@ -1117,27 +1117,25 @@ namespace Rs.Motion.GugaoEcat
/// <returns></returns>
public override ErrorCode Zero(int iOrig)
{
//if (!IsInitialized)
//{
// return ErrorCode.AxisNotInit;
//}
//m_dfCommandPosition = 0.0;
//m_LastErrorCode = ZTM.ZT_SetPosPulse(Config.CardMc, (short)Config.AxisId, iOrig);
//if (m_LastErrorCode != 0)
//{
// return ErrorCode.FAIL;
//}
//m_LastErrorCode = ZTM.ZT_SetPosEncoder(Config.CardMc, (short)Config.AxisId, iOrig);
//if (m_LastErrorCode != 0)
//{
// return ErrorCode.FAIL;
//}
//else
//{
// return ErrorCode.OK;
//}
if (!IsInitialized)
{
return ErrorCode.AxisNotInit;
}
m_apiResult = ZTM.ZT_SetPosPulse(Config.CardMc, (short)Config.AxisId, iOrig);
if (m_apiResult != 0)
{
return ErrorCode.Fail;
}
m_apiResult = ZTM.ZT_SetPosEncoder(Config.CardMc, (short)Config.AxisId, iOrig);
if (m_apiResult != 0)
{
return ErrorCode.Fail;
}
else
{
return ErrorCode.Ok;
}
}
public void SetHomeFinished()

Loading…
Cancel
Save