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:
- SetAxisMotionProfile: sets the motion profile of an axis. In the sample, the motion profile is defined in the instance of the McProfileSettings class,
ProfileSettings
. - SetAxisCountsPerUnit: sets the conversion ratio of the user-defined position unit to the count (pulse) unit used by an axis. In the sample,
Numerator
andDenominator
are one, so the ratio is 1:1.Reverse
is false, so the direction of the axis is not reversed. - EnableAxisUnitConversion: enables the axis to use a real-world unit. After you set a conversion ratio using SetAxisCountsPerUnit, you need to use this method to enable the conversion so the ratio takes effect.
- GetAxisByIndex: gets the information of an axis.
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