固高脉冲卡优化原地在高速口输出脉冲

master
lhiven 6 months ago
parent 4a80c9155e
commit edc408b6a1

@ -1739,7 +1739,7 @@ namespace Rs.Motion.GugaoPulse
public override ErrorCode ComparePulse(ushort channel,bool dp=true) public override ErrorCode ComparePulse(ushort channel,bool dp=true)
{ {
// LogHelper.Debug($"ComparePulse:{channel},{dp}");
//apiResult = mc_pulse.GT_2DComparePulse((short)Config.CardId, (short)(channel - 1), 1, 0, (short)Config.HcmpPulseWidth); //apiResult = mc_pulse.GT_2DComparePulse((short)Config.CardId, (short)(channel - 1), 1, 0, (short)Config.HcmpPulseWidth);
short value = (short)channel; short value = (short)channel;
if (value != 0) if (value != 0)
@ -1747,13 +1747,19 @@ namespace Rs.Motion.GugaoPulse
value = (short)(1 << (channel - 1)); value = (short)(1 << (channel - 1));
} }
ClearCompare(channel); //ClearCompare(channel);
apiResult = mc_pulse.GT_CompareStop((short)Config.CardId);
LogHelper.Debug($"{apiResult} = mc_pulse.GT_CompareStop({(short)Config.CardId});");
apiResult = mc_pulse.GT_ComparePulse((short)Config.CardId, (short)(1 << (channel - 1)), (short)(dp ? 1 : 0), (short)Config.HcmpPulseWidth); apiResult = mc_pulse.GT_ComparePulse((short)Config.CardId, (short)(1 << (channel - 1)), (short)(dp ? 1 : 0), (short)Config.HcmpPulseWidth);
if (apiResult != 0) if (apiResult != 0)
{ {
LogHelper.Debug($"{apiResult} = mc_pulse.GT_ComparePulse({(short)Config.CardId}, {(short)(1 << (channel - 1))}, {(short)(dp ? 1 : 0)}, {(short)Config.HcmpPulseWidth});"); LogHelper.Debug($"{apiResult} = mc_pulse.GT_ComparePulse({(short)Config.CardId}, {(short)(1 << (channel - 1))}, {(short)(dp ? 1 : 0)}, {(short)Config.HcmpPulseWidth});");
return ErrorCode.Fail; return ErrorCode.Fail;
} }
else
{
LogHelper.Debug($"{apiResult} = mc_pulse.GT_ComparePulse({(short)Config.CardId}, {(short)(1 << (channel - 1))}, {(short)(dp ? 1 : 0)}, {(short)Config.HcmpPulseWidth});");
}
return ErrorCode.Ok; return ErrorCode.Ok;
} }

@ -12,6 +12,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Rs.Motion.GugaoPulse namespace Rs.Motion.GugaoPulse
@ -110,7 +111,7 @@ namespace Rs.Motion.GugaoPulse
//card.Init(); //card.Init();
//cardDic.Add(ushort.Parse(row["cardid"].ToString()), card); //cardDic.Add(ushort.Parse(row["cardid"].ToString()), card);
//打开运动控制卡 //打开运动控制卡
apiResult = mc_pulse.GT_Open(short.Parse(row["cardid"].ToString()), 0, 1); apiResult = mc_pulse.GT_Open(short.Parse(row["cardid"].ToString()), 0, 0);
if (apiResult != 0) if (apiResult != 0)
{ {
MessageQueue.Instance.Warn($"mc_pulse.GT_Open({short.Parse(row["cardid"].ToString())}, 0, 1);ret={apiResult}"); MessageQueue.Instance.Warn($"mc_pulse.GT_Open({short.Parse(row["cardid"].ToString())}, 0, 1);ret={apiResult}");
@ -118,9 +119,10 @@ namespace Rs.Motion.GugaoPulse
} }
else else
{ {
//加载配置文件 //加载配置文件
short cardid = short.Parse(row["cardid"].ToString()); short cardid = short.Parse(row["cardid"].ToString());
if(File.Exists($"gugao{cardid}.cfg")) if (File.Exists($"gugao{cardid}.cfg"))
{ {
apiResult = mc_pulse.GT_LoadConfig(short.Parse(row["cardid"].ToString()), $"gugao{cardid}.cfg"); apiResult = mc_pulse.GT_LoadConfig(short.Parse(row["cardid"].ToString()), $"gugao{cardid}.cfg");
LogHelper.Debug($"加载固高配置文件gugao{cardid},ret={apiResult}"); LogHelper.Debug($"加载固高配置文件gugao{cardid},ret={apiResult}");
@ -128,13 +130,17 @@ namespace Rs.Motion.GugaoPulse
MessageQueue.Instance.Insert($"mc_pulse.GT_Open({short.Parse(row["cardid"].ToString())}, 0, 1);ret={apiResult}"); MessageQueue.Instance.Insert($"mc_pulse.GT_Open({short.Parse(row["cardid"].ToString())}, 0, 1);ret={apiResult}");
} }
//清楚报警和限位 //清楚报警和限位
apiResult = mc_pulse.GT_ClrSts(0, 1, 8); apiResult = mc_pulse.GT_ClrSts(short.Parse(row["cardid"].ToString()), 1, 8);
if (apiResult != 0) if (apiResult != 0)
{ {
return ErrorCode.Fail; return ErrorCode.Fail;
} }
else
{
LogHelper.Debug($"{apiResult} = mc_pulse.GT_ClrSts({short.Parse(row["cardid"].ToString())}, 1, 8);");
}
short value = 32767 * 5 / 10; short value = 32767 * 5 / 10;
apiResult = mc_pulse.GT_SetDac(0, 11, ref value, 1); apiResult = mc_pulse.GT_SetDac(short.Parse(row["cardid"].ToString()), 11, ref value, 1);
MessageQueue.Instance.Insert($"GT_SetDac ret={apiResult}"); MessageQueue.Instance.Insert($"GT_SetDac ret={apiResult}");
} }
} }

Loading…
Cancel
Save