The initialization settings

While an EtherCAT link is being created between hardware and the KINGSTAR Subsystem, we need to initialize a few settings before the link state becomes Op. The flag OPFlag, which signals whether an EtherCAT link has been created, is put after Start (see The Connect button > Start the KINGSTAR Subsystem). When OPFlag is false, it means the link has not been created yet. At this stage, we clear the device list and initialize the settings of the axes using for loops.

The initialization uses the following KINGSTAR methods:

After the initialization settings are configured, we set OPFlag to true.

Private Sub t_Staus_Tick(sender As Object, e As EventArgs) Handles t_Staus.Tick
   .........
   If OPFlag = False Then
      lbMList.Items.Clear()

      For i As Integer = 0 To KSMStatus.AxesCount - 1

         '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) 
      Next

      For i As Integer = 0 To KSMStatus.AxesCount - 1

         'Gets the details information of an axis.
         KSMAxisDetails(i) = KS_API.GetAxisByIndex(i)
      Next

      .........
      OPFlag = True
   End If
   .........
End Sub