Create a TwinCAT Project from Scratch

Auteur avatarGareth Green | Dernière modification 3/12/2024 par Gareth Green en cours de rédaction

Introduction


...Beckhoff Technical help is available on 01491 410539 option 3

Étape 1 - Install Visual Studio / TwinCAT XAE Shell (if required)

...Not required if the PC has been cloned from the base setup
...This now applies to all installations. The "CNC" standard PCs used for the front end on Flowlines and ZXs have Visual Studio already installed but the TwinCAt version needs to be upgraded from 4022 to 4024
  1. Uninstall all references to Visual Studio 2013 and Beckhoff Twincat3. If this is needed, restart the PC
  2. Copy the install file from g:\Design\TwinCAT3\TC31-Full-Setup.3.1.4024.32.exe to the desktop of the Beckhoff PC
  3. Run the install as Administrator
  4. Delete the setup zip file and unzipped directory to save hard drive space

..."Specified account already exists" error will happen if the Visual Studio 2013 or Beckhoff TwinCAT is not fully uninstalled and PC restarted. Use Revo uninstaller to completely remove it

...From version 3.1.4024 onwards, is is not called visual studio, it is called "TwinCAT XAE Shell"



Étape 2 - Add the latest Device Description Table

...Not required if the PC has been cloned from the base setup
...Not required if the PC has been cloned from the base setup

Copy the contents of g:\design\twincat3\Beckhoff_EtherCAT_XML.zip

to

C:\TwinCAT\3.1\config\Io\EtherCAT and overwrite all the .xml files in this folder


...This allows the Beckhoff system to identify the latest version of the AX8000 drives

Étape 3 - Add Drive Manager 2 for AX8000 drives (if not installed already)

...Not required if the PC has been cloned from the base setup
...This step needs to be done for the AX8000 drives only
  1. Copy the Drive Manager 2 setup g:\design\TwinCAT3\TE5950-TC3-Drive-Manager-2.zip to Install Files or the desktop on the PC running Visual Studio
  2. Close Visual Studio if it is open
  3. Extract the Zip File
  4. Run the Setup File
  5. Delete the setup zip file and unzipped directory to save hard drive space



Étape 4 - Start a new project

  1. Open Visual Studio
  2. Click on New project
  3. Choose TwinCAT projects->TwinCAT XAE Project (xml format)
  4. Name is build number (no Suffix)
  5. Location is c:\TwinCAT\Stuga\
  6. Untick "Create Directory for solution"
  7. This may take some time - a long delay sometimes "Rebuilding Device Description Cache"
...This creates an empty template to build your project for the machine


Étape 5 - Clone the Repository

...A Repositiory or "Repo" is a storage area for the source code versioning system. In our case we use an online system called "bitbucket"
  1. Open Team Explorer
  2. Clone a new Git Repository
  3. URL to clone: https://bitbucket.org/StugaMachinery/tc3Multi
  4. Click on the destination setup
  5. Create a new folder under the machine build folder called "source"
  6. Click 'Clone'

Étape 6 - "Add" the clone if an error is thrown

On later versions (2022+) an error is thrown by the system

  1. Error Message
  2. Click Add
  3. Browse to the source folder and add



Étape 7 - Enter Git Credentials (if required)

Atlassian Username is StugaMachinery

Password is stored in the file


G:\IT Department\SourceTree BitBucket App Password.txt
...Sometimes, the password credentials are already stored and the password entry is not necessary

Étape 8 - Add The tc3Multi then PLC_Reset Project

  1. Right click PLC
  2. Select Add Existing Item
  3. Navigate to the repository you have created in Step 6 c:\TwinCAT\Stuga\BuildNo\source\tc3Multi\tc3Multi.plcproj
  4. Repeat for the PLC_Reset project



Étape 9 - Check PLC Ports 851 and 852 correct

Check that

tcMulti - Port 851

PLC_Reset - Port 852


If not you can change the port assignment by right clicking the PLC project - you will need to change one to a "spare" port 853 first


Étape 10 - Ensure Correct Machine Commented in tcMulti project


  1. Navigate to tcMulti project->POUs->MAIN
  2. Scroll down to the machine types. The "comment State" can be toggled on and off by right clicking next to the step number on the left
  3. Your goal is to ensure the correct machine is highlighted and the incorrect ones are commented out (in green)
  4. Click Save All
...Check the date next to the machine types - you will want the latest one



Étape 11 - Add TwinSAFE project

...From Z071 there is no twinSAFE project as the Estop circuit is hard wired

Étape 12 - Add the route to the Target System

If the front and back end PLCs are the same, the Target System is <Local>


If this is a separate Front End PC

  1. From Dropdown box select the Build number (If it does not exist we will need to add a new route)
  2. If there is a request for a platform change, click Yes
  3. On success, the Route dropdown will not read Error


Étape 13 - Scan for Devices

  1. Expand IO
  2. Right click on devices, Scan
  3. Click OK on the Hint:
  4. Untick RT-Ethernet
  5. Untick COM-Port
  6. Just have the EtherCAT ports
  7. Scan for boxes - Yes
  8. If there is a request for New Device Type, Click Apply to All, Click Yes


If the scan does not work, a potential root casue could be missing EtherCAT drivers for the network adapter. See Updating Realtime Drivers for EtherCAT


Étape 14 - Check EtherCAT validity

Check the Devices and boxes match the expected EtherCAT setup
...Check the green lights on the etherCAT boxes for connection status. Flickering Green means it is OK
Repeat steps 7 and 8 until the physical network matches the scanned network

You may need to Right Click->scan Boxes on the second device if the EtherCAT boxes do not appear


...If the boxes do not appear in the right order, there could be an EtherCAT In /Out crossover

Étape 15 - Name all EtherCAT devices according to network

...Do not start this step until the EtherCAT network is fully verified. You will waste a lot of time if you ignore this!


Click twice on each device (not double click) to enable the device to be renamed

rename to convention



Étape 16 - Map all IO References

Using the circuit diagrams, map all the IO ref numbers to the associated IO channels

  1. Double click a field-bus box or slice
  2. Ensure you can see the input / Output list (may need some screen resizing
  3. Double click an IO channel
  4. Enter the number in the search box
  5. Double click the associated IO Ref number from ibInputArray(inputs) or qbOutputArray(outputs)
...Click Save All regularly so you do not loose progress, as this process can take a considerable time

...Be very vigilant and ensure you only click on ibInputArray or qbOutputArray

Repeat for all IO

Étape 17 - Map Analogue Input references

Length and width sensors need to be mapped to their relevant EtherCAT boxes

  • Width Sensor on Machining centre is iAnalogueInputArray[0]
  • Length Sensor on Infeed table is iAnalogueInputArray[1]


Étape 18 - Double check all IO references with someone else

Any mistakes made will save hours if spotted here

Étape 19 - Install Drive Manager 2 Project

  1. Note which Device number has the drive in it
  2. Left-click on FILE. A new context menu open
  3. Move the mouse to Add.
  4. Left-click on New Project.
  5. Select TwinCAT Drive manager 2 on left
  6. Click on TwinCAT Drive manager 2 Project on right
  7. Save with filename "[BuildNo] Drive Manager" in the folder for the project (c:\TwinCAT\Stuga\[BuildNo])
  8. EtherCAT master will be the device that has the drive in from Step 1
  9. Leave the basic settings, click OK
  10. This should link up the drives set in previous steps to a Drive Manager project

Étape 20 - Add Axis Task

A smooth setup will have detected the axes and added them under the MOTION tab already.


if not, an axis task may need to be added under the MOTION tree:

  1. Add New Item
  2. NC/PTP Configuration
  3. Leave the Name as default


Étape 21 - Add Axes

...This step may not be necessary if the Device scan added them automatically

If the axes do not exist under MOTION->NC Task->Axes, add them

  1. Right Click Add axis
  2. Name to convention nn Axis


Repeat for each axis on machine

Axis naming and configuration for different machines can be found here


Étape 22 - Map Axes

...This step may not be necessary if the Device scan added them automatically
  1. Double click an axis
  2. Settings tab
  3. Click Link To IO
  4. Connect to associated Drive
  5. Click Link to PLC
  6. Use the reference here to get the Axis Numbers


Repeat for each axis

...Make sure you select the correct channel number / letter is it is a dual drive

Étape 23 - Add PLC_Reset to tc3Multi Link

...An output from tcMulti needs to be set up to an input on PLC reset to allow the PLC to reset itself. This is linke a physical wire between two PLCs but just exists in the software
  1. Expand PLC_Reset Instance to get to ibResetPLC
  2. Double Click ibResetPLC to open the properties
  3. Link to qbResetPLC (this is very far down the list)
  4. Activate configuration


Étape 24 - Activate configuration



Étape 26 - Add The PC types to Monday Log

The board "Control Systems Log" is setup to log all machine setups

https://stugaltd.monday.com/boards/304269981


Commentaires

Draft