EtherCAT Slave Configuration
- Create new SSC file using EtherCAT Slave Design Quick Guide and ETG2000 specification document
- Configure SSC settings for slave implementation
- Define EtherCAT basic data types
Code Generation Process
- Create SSC file (recommended version 5.12 for fewer modifications)
- Modify SlaveInformation section
- Keep Generic settings unchanged
- Update Hardware configuration for STM32
- Maintain default EtherCAT Sttate Machine
- Adjust Synchronisasion: Add 1ms timer for EtherCAT watchdog
- Modify Application: Exclude el9800app.c and include necessary headers
- Update ProcessData: Adjust PDO transfer addresses
- Configure MailBox: Set SM transfer addresses
ET1200 has 1KB memory (0x1000-0x1400):
- 0x1000-0x11FF for mailbox
- 0x1200-0x13FF for PDO
PDO Variable Configuration
- Add PDO variables in Excel worksheet
- Only 0x6000 and 0x7000 PDOs require manual mapping
- Save configuration as 'myapp'
- Generate EtherCAT code
STM32 Implementation
Import generated files into project and modify:
- Add required definitions in el9800hw.c
- Implement SPI, timer, and interrupt initialization
- Update RxTxSpiData function for SPI communication
- Add timer interrupt handler
/* SPI Initialization Example */
void SPI_Init_Config(void) {
GPIO_InitTypeDef GPIO_InitStruct;
SPI_InitTypeDef SPI_InitStruct;
// Enable clocks and configure pins
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);
// Configure SPI pins
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_Init(GPIOB, &GPIO_InitStruct);
// SPI configuration
SPI_InitStruct.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
SPI_InitStruct.SPI_Mode = SPI_Mode_Master;
SPI_InitStruct.SPI_DataSize = SPI_DataSize_8b;
SPI_InitStruct.SPI_CPOL = SPI_CPOL_High;
SPI_InitStruct.SPI_CPHA = SPI_CPHA_2Edge;
SPI_Init(SPI1, &SPI_InitStruct);
SPI_Cmd(SPI1, ENABLE);
}
Master Configuration (TwinCAT 3)
- Place generated XML file in TwinCAT directory
- Create new project in Visual Studio
- Install network adapter
- Obtain license
- Scan devices and confirm all prompts
- Switch to Operational state
- Verify initial values and communication
- Test value writing functionality
For variable additions:
- Modify XML file for all related objects (0x6000/0x7000, etc.)
- Update myappObjects.h with matching definitions
- Adjust PDO transfer functions in myapp.c
Note: Regenerating code with SSC and replacing specific files may be more efficient thann manual modifications.