Example program #1: 2-channel control for a 24 VDC motor with PWM
Using the sample programs This document contains sample applications of our products for certain areas of application. The application notes provided here are based on typical features of our products and only serve as examples. The notes contained in this document explicitly do not refer to specific applications. The customer is therefore responsible for assessing and deciding whether the product is suitable for a particular application. We accept no responsibility for the completeness and correctness of the source code contained in this document. We reserve the right to modify the content of this document at any time and accept no responsibility for errors and missing information. |
Example 1: 2-channel control for a 24 VDC motor with PWM
Download (sample file)
In this example two 24 VDC small-power motors (max. 2 A) are controlled independently via PWM. Each motor is controlled via one of the EL2262 channels. No position/speed feedback takes place. The EL2262 is used as actuator.
Data:
- 1 ms cycle time
- 1000x oversampling on both channels
- 1 MHz output cycle, 500 kHz max. PWM frequency
- In the example: axis 1 operates with 25 kHz, axis 2 with 15 kHz PWM frequency, duty factor configurable via visualization, 0..100%
Connection diagram:
Starting the example program
The application examples have been tested with a test configuration and are described accordingly.
Certain deviations when setting up actual applications are possible.
The following hardware and software were used for the test configuration:
- TwinCAT master PC with Windows XP Professional SP 3, TwinCAT version 2.10 (Build 1330) and INTEL PRO/100 VE Ethernet adapter
- Beckhoff EtherCAT Coupler EK1100, EL2262 and EL9010 Terminals
- Inductive proximity limit switch, switching to positive potential, with 3-wire connection, max. switching frequency: 3000 Hz
Procedure for starting the program
- After clicking the Download button, save the zip file locally on your hard disk, and unzip the *.TSM (configuration) and the *.PRO (PLC program) files into a temporary working folder.
- Run the *.TSM file and the *.PRO file; the TwinCAT System Manager and TwinCAT PLC will open.
- Connect the hardware in accordance with fig. Connection for sample program 1 and connect the Ethernet adapter of your PC to the EtherCAT coupler (further information on this can be found in the corresponding coupler manuals)
- Select the local Ethernet adapter (with real-time driver, if applicable) under System configuration, I/O configuration, I/O devices, Device (EtherCAT); then on the “Adapter” tab choose “Search...”, select the appropriate adapter and confirm (see Fig. Searching the Ethernet adapter + Selection and confirmation of the Ethernet adapter).
- Activation of the configuration (Fig. Activation of the configuration) and confirmation (Fig. Confirming the activation of the configuration)
- Confirm new variable mapping (Fig. Generating variable mapping), restart in RUN mode (Fig. Restarting TwinCAT in RUN mode)
- In TwinCAT PLC, under the “Project” menu, select “Rebuild all” to compile the project (Fig. Compile project)
- In TwinCAT PLC: log in with the “F11” button, confirm loading the program (Fig. Confirming program start), run the program with the “F5” button