ecat_digital_io#
Overview#
This example demonstrates how to develop a remote IO device based on Slave Stack Code(SSC).
This remote IO device only supports SM-Synchron mode for DC operation, and implements one Input channel and one Output channel:
Output channel: connected with the LED and used to control this LED.
Input channel: used to read the LED current status.
Note that the demo CAN NOT be built directly. Please see the “Prepare the Demo” section for more details.
Running the demo#
When the example is running, the serial port will output:
Start the SSC digital_io example...
After the PLC program started, the LED starts to blink with 0.5Hz frequency.
NOTE: refer to the User Guide for the details of how to setup the PLC project on TwinCAT3.
TwinCAT Setup#
To demonstrate this IO example, TwinCAT is used as the EtherCAT MainDevice.
Supported Boards#
MIMXRT1180-EVK
Hardware requirements
MIMXRT1180-EVK RevC
RJ45 Network cable
Mini/micro USB cable
Personal Computer on which the TwinCat3 has been installed(Windows 10 is recommended)
Board settings
For multiple boards cascades, R142 register needs to be removed.
EEPROM LPI2C Emulator
i.MX RT1180 supports EEPROM LPI2C emulator, please skip this chapter if you used EEPROM hardware.
Hardware Setting
Connection:
J51: pin4 <–> J44: pin20
J51: pin6 <–> J44: pin18
Remove EEPROM:
U48
Add EEPROM_I2C_EMULATOR macro
Add EEPROM_I2C_EMULATOR macro to enable eeprom i2c emulator funtion
Now you can refer “Prepare the Demo” to setup ecat_examples
Prepare the Demo
Generate the SSC source code
Download Slave Stack Code Tool(SSC Tool V5.13) from BECKHOFF official website and install it
Open Slave Stack Code Tool
Click ‘File’ -> ‘New’ -> ‘Import’ to import the Congfig file Select digital_io.xml under path ‘.\boards\evkmimxrt1180\ecat_examples\digital_io<core>\SSC’.
Click ‘Custom’ -> ‘NXP ECAT…’ -> ‘OK’ to select the subdevice description file
Click ‘Tool’ -> ‘Application’ -> ‘Import’ to import Application information Select digital_io.xlsx under path ‘.\boards\evkmimxrt1180\ecat_examples\digital_io<core>\SSC’.
Click ‘Project’ -> ‘Create new Slave Files’ ‘Source Folder’(default): ‘.\boards\evkmimxrt1180\ecat_examples\digital_io<core>\SSC\Src’. Click ‘Start’.
Remove digital_io.c under Src folder
Connect EtherCAT Port0 with TwinCAT3
RJ45 interface labeled as J28 is the EtherCAT Port0, RJ45 interface labeled as J32 is the EtherCAT Port1.
Connect a USB cable between the host PC and the OpenSDA USB port on the target board
Open a serial terminal with the following settings
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board
Either press the reset button on your board or launch the debugger in your IDE to begin running the demo
Update ESI file to EEPROM
Copy ESI file ‘ECAT-IO.xml’ generated by SSC TOOL to <TwinCAT_installation_folder>/<twincat_version>/Config/io/EtherCAT/
Restart TwinCAT3 IDE
Scan device and Update EEPROM
Scan and load this device and create a PLC project in TwinCat3 The PLC Main code is as follows:
PROGRAM MAIN VAR Delay : TON; LedIn AT %I* : BOOL; LedOut AT %Q* : BOOL; END_VAR Delay(IN := TRUE, PT := T#1S); IF Delay.Q THEN LedOut := NOT LedIn; Delay(IN := FALSE); END_IF;
Activate configuration and start PLC Main function
FRDM-MIMXRT1186
Hardware requirements
FRDM-IMXRT1186 A2
RJ45 Network cable
Type-C USB cable
Personal Computer on which the TwinCat3 has been installed(Windows 10 is recommended)
Board settings
J12(2-3)/J13(2-3): eCAT0 Function Via J57A(Default).
J18(2-3)/J17(2-3): eCAT1 Function Via J57B(Default).
EEPROM LPI2C Emulator
FRDM-IMXRT1186 supports EEPROM LPI2C emulator, please skip this chapter if you used EEPROM hardware.
Hardware Setting
Remove Jumper:
J31: pin1 - pin2
J35: pin1 - pin2
Remove Resistors:
R297: pin1 - pin2
R299: pin1 - pin2
Add Resistors:
R30
R31
R297: pin1 - pin3
R299: pin1 - pin3
Connection:
J31: pin1 <–> J2: pin18
J35: pin1 <–> J2: pin20
Add EEPROM_I2C_EMULATOR macro
Add EEPROM_I2C_EMULATOR macro to enable eeprom i2c emulator funtion
Now you can refer “Prepare the Demo” to setup ecat_examples
Prepare the Demo
Generate the SSC source code
Download Slave Stack Code Tool(SSC Tool V5.13) from BECKHOFF official website and install it
Open Slave Stack Code Tool
Click ‘File’ -> ‘New’ -> ‘Import’ to import the Congfig file Select digital_io.xml under path ‘.\boards\frdmimxrt1186\ecat_examples\digital_io<core>\SSC’.
Click ‘Custom’ -> ‘NXP ECAT…’ -> ‘OK’ to select the subdevice description file
Click ‘Tool’ -> ‘Application’ -> ‘Import’ to import Application information Select digital_io.xlsx under path ‘.\boards\frdmimxrt1186\ecat_examples\digital_io<core>\SSC’.
Click ‘Project’ -> ‘Create new Slave Files’ ‘Source Folder’(default): ‘.\boards\frdmimxrt1186\ecat_examples\digital_io<core>\SSC\Src’. Click ‘Start’.
Remove digital_io.c under Src folder
Connect EtherCAT Port0 with TwinCAT3
RJ45 interface labeled as J57A is the EtherCAT Port0 and RJ45 interface labeled as J57B is the EtherCAT Port1.
Connect a USB cable between the host PC and the OpenSDA USB port on the target board
Open a serial terminal with the following settings
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board
Either press the reset button on your board or launch the debugger in your IDE to begin running the demo
Update ESI file to EEPROM
Copy ESI file ‘ECAT-IO.xml’ generated by SSC TOOL to <TwinCAT_installation_folder>/<twincat_version>/Config/io/EtherCAT/
Restart TwinCAT3 IDE
Scan device and Update EEPROM
Scan and load this device and create a PLC project in TwinCat3 The PLC Main code is as follows:
PROGRAM MAIN VAR Delay : TON; LedIn AT %I* : BOOL; LedOut AT %Q* : BOOL; END_VAR Delay(IN := TRUE, PT := T#1S); IF Delay.Q THEN LedOut := NOT LedIn; Delay(IN := FALSE); END_IF;
Activate configuration and start PLC Main function
iMX943-EVK
Hardware requirements
IMX943-EVK board
RJ45 Network cable
Mini/micro USB cable
Personal Computer on which the TwinCat3 has been installed
Board settings
Connect J44-10(GPIO_IO31 pad, signal name M1_LED_TP1) and J43-14(GND) to oscilloscope
Prepare the Demo
Generate the SSC source code
Download Slave Stack Code Tool(SSC Tool V5.13) from BECKHOFF official website and install it
Open Slave Stack Code Tool
Click ‘File’ -> ‘New’ -> ‘Import’ to import the Congfig file Select digital_io.xml under path ‘.\boards\imx943evk\ecat_examples\digital_io<core>\SSC’.
Click ‘Custom’ -> ‘NXP ECAT…’ -> ‘OK’ to select the subdevice description file
Click ‘Tool’ -> ‘Application’ -> ‘Import’ to import Application information Select digital_io.xlsx under path ‘.\boards\imx943evk\ecat_examples\digital_io<core>\SSC’.
Click ‘Project’ -> ‘Create new Slave Files’ ‘Source Folder’(default): ‘.\boards\imx943evk\ecat_examples\digital_io<core>\SSC\Src’. Click ‘Start’.
Remove digital_io.c under Src folder
Connect EtherCAT Port0 with TwinCAT3
RJ45 interface labeled as J24 SH2 is the EtherCAT Port0 and RJ45 interface labeled as J24 SH1 is the EtherCAT Port1.
Connect a USB cable between the host PC and the OpenSDA USB port on the target board
Open a serial terminal with the following settings
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board
Either press the reset button on your board or launch the debugger in your IDE to begin running the demo
Update ESI file to EEPROM
Copy ESI file ‘ECAT-IO.xml’ generated by SSC TOOL to <TwinCAT_installation_folder>/<twincat_version>/Config/io/EtherCAT/
Restart TwinCAT3 IDE
Scan device and Update EEPROM
Scan and load this device and create a PLC project in TwinCat3 The PLC Main code is as follows:
PROGRAM MAIN VAR Delay : TON; LedIn AT %I* : BOOL; LedOut AT %Q* : BOOL; END_VAR Delay(IN := TRUE, PT := T#1S); IF Delay.Q THEN LedOut := NOT LedIn; Delay(IN := FALSE); END_IF;
Activate configuration and start PLC Main function
Note: Since no LED connected to the RGPIO. Please use oscilloscope probe to the pin to check the output.