AddModuleConfiguration
This function allows users to add devices that auto-configuration cannot detect by overriding it.
It serves two purposes:
- Adding devices that can't be detected by auto-configuration, such as IO-Link devices, certain CANopen devices, and devices linked to the coupler.
- Overriding the EtherCAT auto-configuration. To override the auto-configuration, this function must be used before the device connects to KINGSTAR.
Syntax
KsError AddModuleConfiguration(
int SlaveId,
int ModuleId,
KsConfigurationType ConfigurationType,
VOID* Configuration
);
Parameters
SlaveId: the slave index. This index value is automatically assigned by the KINGSTAR master when the EtherCAT network starts, based on the physical connection order. The first device connected directly to the master is assigned Index 0, followed by Index 1, Index 2, and so on. These indexes remain consistent within the slave array even if devices are added, removed, or reconnected. Please refer to the use cases in HotConnect, Repair, and Restart for more details.
ModuleId: the module (devices linked to the coupler) ID. It can be slot ID, port ID, or CANopen slave ID.
ConfigurationType: the type of link between the device and the coupler. See the KsConfigurationType type.
Configuration: pointer to the configuration structure. It depends on what protocol you use. For example, if it's IO-Link, the configuration is the IoLinkSetting structure.
Return value
If the function succeeds, it returns errNoError, otherwise an error code. For more information about the error code, see the KsError list.
Remarks
This function must be called after Create and before Start.
Usable EtherCAT states
ecatOffline
Example
// configIoLink
IoLinkSetting IoLink = {
17, // IO-Link specification: Version 1.1
0, // SPDU
3, // Control
32, // Input length
0 // Output length
};
nRet = AddModuleConfiguration(
2, // EthercatSlaveID
0, // LinkedDeviceID
configIoLink, // Protocol
&IoLink // Settings
);
// configCANopen
CanOpenSetting CanOpen = { 0 };
CanOpen.RxPdoCount = 4;
CanOpen.RxPdos[0] = { TRUE, 16, 0x1800, 0xFF };
CanOpen.RxPdos[1] = { FALSE, 48, 0x1801, 0xFF };
CanOpen.RxPdos[2] = { FALSE, 48, 0x1802, 0xFF };
CanOpen.RxPdos[3] = { FALSE, 0, 0x1803, 0xFF };
CanOpen.TxPdoCount = 4;
CanOpen.TxPdos[0] = { TRUE, 16, 0x1400, 0xFF };
CanOpen.TxPdos[1] = { FALSE, 48, 0x1401, 0xFF };
CanOpen.TxPdos[2] = { FALSE, 48, 0x1402, 0xFF };
CanOpen.TxPdos[3] = { FALSE, 0, 0x1403, 0xFF };
CanOpen.SdoCommandCount = 1;
CanOpen.SdoCommands[0].Index = 0x6060;
CanOpen.SdoCommands[0].SubIndex = 0;
CanOpen.SdoCommands[0].Length = 1;
CanOpen.SdoCommands[0].Data[0] = 0x1;
nRet = AddModuleConfiguration(
1, // EthercatSlaveID
0x70, // LinkedDeviceID, it is CANopen device's node ID for CANopen protocol
configCANopen, // Protocol
&CanOpen // Settings
);
// configEsi
AddModuleConfiguration(3, (int)strlen("Sanyodenki RS2 special"), configEsi, "Sanyodenki RS2 special");
Requirements
| RT | Win32 | |
|---|---|---|
| Minimum supported version | 4.0 | 4.0 |
| Header | ksapi.h | ksapi.h |
| Library | KsApi_Rtss.lib | KsApi.lib |
See also