初始化設定

在硬體與 KINGSTAR 子系統建立 EtherCAT 連結時,我們需在連接狀態變為 Op 之前初始化一些設定,信號指示 EtherCAT 連結是否建立之旗標 OPFlag 放在 Start 之後(請見 連接鈕 > Start the KINGSTAR Subsystem),當 OPFlag 為 false,表示連結尚未建立,此時我們清除裝置清單並使用 for 迴圈初始化軸之設定。

初始化使用下列 KINGSTAR 方法:

初始化設定配置完成後,將 OPFlag 設為 true。

private void t_Staus_Tick(object sender, EventArgs e)
{
   .........	
   if (OPFlag == false)
   {
      lbMList.Items.Clear();
      for (int i = 0; i < KSMStatus.AxesCount; i++)
      {
         //Sets the unit of acceleration and jerk for an axis.
         motion.SetAxisMotionProfile(i, ProfileSettings);

         //Sets the conversion ratio of user-defined position unit to the count (pulse) unit used by the axis.
         motion.SetAxisCountsPerUnit(i, Numerator, Denominator, Reverse);

         //Enables the axis to use a real-world unit.
         motion.EnableAxisUnitConversion(i, true);
      }
      for (int i = 0; i < KSMStatus.AxesCount; i++)
      {
         //Gets the details information of an axis.
         KSMAxisDetails[i]=KS_API.GetAxisByIndex(i);
      }
      .........
   OPFlag = true;
   .........
}