/
Beckhoff TwinCAT

Beckhoff TwinCAT

For details about the releases, see here.

PMLib Version

Compatible with PMC Version

Download

Changelog

PMLib Version

Compatible with PMC Version

Download

Changelog

6.03.039.00

117.17.43 or higher

pmlib 2025.03v7.17.43 (6.03.039.00)

6.03.037.00

117.17.12 or higher

pmlib 2025.01v7.17.12 (6.03.037.00)

Creating a new project

Step 1: Start by clicking File->New->Project

Step 2: In the New Project window select Installed->Templates->TwinCAT Projects and then select TwinCAT XAE Project. Choose a name and location and then click "OK"

Step 3: Once the new TwinCAT XAE project is created go to the Solution Explorer. Expand the new project and right click PLC. Then select "Add New Item"

Step 4: In the Add New Item window select Standard PLC Project. Choose a name for the PLC project, then click "Add"

Setup Fieldbus

Step 1: Before starting, make sure that the included ESI (EtherCAT Slave Information) XML file is saved in the TwinCAT installation directory (default: C:\TwinCAT\IO\EtherCAT or C:\TwinCAT\3.1\Config\Io\EtherCAT)

Step 2: In the Solution Explorer, expand the I/O drop down then right click Devices. Click "Add New Item"

Step 3: In the Insert Device window select EtherCAT->EtherCAT Master, give the new EtherCAT Master a name then click "Ok"

Step 4: In the Device Found At window select the Ethernet Adapter that the PMC is connected to, then click "OK"

Step 5: In the Solution Explorer go to I/O->Devices and right click the new EtherCAT Master device and click "Add New Item"

Step 6: In the Insert EtherCAT Device window select Planar Motor Incorporated->Planar Motor Controller->Communication Protocol A then click "OK"

Import and use library

Step 1: First go to PLC and then click "Library Repository"

Step 2: In the Library Repository window click the "Install..." button

Step 3: Browse to find the included .compiled-library file and click "Open"

Step 4: Then in the Solution Explorer expand the PLC Project and right click on the References folder and click "Add library"

Step 5: In the Add Library window select PMCLib and click "OK"

Step 6: Next expand the PLC->PLC project->POUs and open MAIN. There declare a PMControllerType and two arrays. One array is a 400 element array of type BYTE declared at a fixed input address (ex. %IB0) of the PLC. The other is a 400 element array of type BYTE declared at a fixed output address (ex. %QB0) of the PLC. The exact input and output addresses don’t matter, but it must not overlap with any other input and output variables.

Then assign the address of the input (%IB) array to the DataFromPMC member of the PMControllerType. Next assign the address of the output (%QB) array to the DataToPMC member of the PMControllerType

Step 7: Then build the project by clicking Build->Build Solution. This is necessary so that the arrays will show up for mapping. 

Step 8: Right click I/O->Devices->EtherCAT Master Device Name->Box 1 (Communication Protocol A)->Transmit PDO Mapping->DataFromPMCArray then click Change Link…

Step 9: Once in the Attach Variable window, make sure that the Show Variables and Show Variable Types selections are set the same as here. Then select the array that you declared in the input (%IB) area of the PLC.

Step 10: Right click I/O->Devices->EtherCAT Master Device Name->Box 1 (Communication Protocol A)->Transmit PDO Mapping->DataToPMCArray then click Change Link…

Step 11: Once in the Attach Variable window, make sure that the Show Variables and Show Variable Types selections are set the same as here. Then select the array that you declared in the output (%QB) area of the PLC.

Step 12: In the MAIN of the PLC project make sure the following is done before using the PMC library. 
    Make sure that DataFromPMC member of the PMControllerType is assigned the address of the input (%IB0) mapped array. 
    Make sure that DataToPMC member of the PMControllerType is assigned the address of the output (%QB0) mapped array
    Make sure that one and only one instance of the PMC_AutoRefresh function block is declared and that the PMC_AutoRefresh function block is called once and only once per PLC cycle.

Upgrade Library

Step 1: (Note library versions are tied to the TwinCAT install not the project) Click PLC->Library Repository

Step 2: In the Library Repository window find PMCLib, select the old version and click "Uninstall"

Untitled-1-20241217-193406.png

Step 3: Click "Yes" in the confirmation window

Step 4: Once the old library is uninstalled click "Install..."

Step 5: Browse to the new .compiled-library and click "Open"

Setup Streaming (Optional) - only for synchronization with external axis

Step 1: Navigate to I/O->Devices and expand the EtherCAT Master device that is connected to the PMC. Then double click the Box 1 (Communication Protocol A) option.

Step 2: In the resulting window select the "DC" tab and change the Operation Mode to "DC for synchronization".

Untitled-1-20241217-193648.png

Step 3: Then click "Advanced Settings...".

Step 4: In the Advanced Setting window select "User Defined" for the Cycle Time (us). Change the User Defined Cycle Time so that it is equal to the cycle time of the task that communicates with the PMC. Then select "Use as potential Reference Clock" and then click "OK".

File I/O On the PLC (Optional)

The following are one possible way to read and write files to the PLC storage. It could be helpful for commands such as Set PMC Configuration.

TwinCAT uses the normal Windows folders to store files. So one possibility is to directly copy the file into the target Twincat PLC.

An alternative is to use the project Deployment option. 

Step 1: Right click on the PLC project and select Properties.

Step 2: In the Deployment tab, specify the source path (on development PC) and target path (on target PLC) for the file. The triggering event can be customized, TwinCAT will perform the file copy on Activate Configuration, for example.

 

Feedback and Comments

Please email us at tech.portal@planarmotor.com