Skip to content

Making use of variant manager boot folders. Change between a variant during runtime, by swapping out the TwinCAT boot folder.

License

Notifications You must be signed in to change notification settings

Beckhoff-USA-Community/Boot-folder-swap-from-PLC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

About This Repository

This is an example on how to use the TwinCAT variant manager, _Boot folders and switch between a variant at runtime.

Background information:

When a TwinCAT project is successfully compiled, all necessary runtime files are stored in the solution folder under Solution -> TwinCAT project -> "_Boot".

Upon activation image, the files in this folder are copied to the target's Boot folder (C:\TwinCAT\3.1\Boot) and then the TwinCAT system is restarted. After a restart, the TwinCAT system loads the files from the boot folder into memory and starts to execute them.

More information about this process is also found here TwinCAT 3 | Machine update at file level.

Summary of the code:

  1. In the TwinCAT project two variants have been defined: RevA and RevB. image

The difference in the two variants of this example is that RevA uses an EL2809-0000 and RevB uses an EL2809-0015. In RevA, the EL2809-0015 is disabled, while in RevB, the EL2809-0000 is disabled.

image

Please see the variant manager documentation for further details about features and workflow.

  1. A helper PowerShell script and .bat file are used for copying files around from the PLC at runtime. Please see the scripts folder of this repository. These two files are called from the PLC using NT_StartProcess at runtime.

  2. The deployment properties of the PLC were modified. Two actions were added. Upon activation, the helper scripts folder is copied to the target, as well as all variant boot folders.

image

The PLC code sequence

  1. On startup, the EtherCAT topology is scanned in.
  2. The Vendor, product, and revision number of each slave is stored in an array and then stored into a file for later reference.
  3. The actual EtherCAT configuration is also read in.
  4. The actual EtherCAT configuration is compared against the scanned-in topology. If the two match, a message is sent informing that the scanned topology and the actual configuration match. No further steps need to be taken if this is the case.
  5. If the scanned-in topology doesn't match the actual configuration, it is then compared against all other variants to see if there is a match.
  6. If a match is found, a message is sent indicating that the "X" variant matches and that you should consider loading it.
  7. Knowing what variant now needs to be loaded, this information is passed to a PowerShell script to perform a swap for the appropriate boot folder.
  • The PowerShell script performs the following:
    1. Deletes all files from the boot folder (C:\TwinCAT\3.1\Boot), except the TwinCAT logged events (loggedevents.db).
    2. Copies all the files from the selected variant boot folder at C:\TwinCAT\3.1\Target\Resource\Variants\X to the boot folder (C:\TwinCAT\3.1\Boot).
    3. Reboots the PC. A TwinCAT restart could be sufficient as an alternative. See ADS PowerShell Module ->Set-AdsState, use ADS port 10000.

This sample is created by Beckhoff Automation LLC and is provided as-is under the Zero-Clause BSD license.

How to get support

Should you have any questions regarding the provided sample code, please contact your local Beckhoff support team. Contact information can be found on the official Beckhoff website at https://www.beckhoff.com/en-us/support/.

Further Information

TwinCAT 3 | Machine update at file level

TwinCAT 3 | Variant Management

TE1000 | TwinCAT 3 ADS PowerShell Module

Requirements

The following components must be installed to run the sample code:

  • TE1000 TwinCAT 3 Engineering version 3.1.4024.0 or higher
  • A copy of the PowerShell script and .bat from the scripts folder of this repo stored into C:\TwinCAT\3.1\Target\Resource.

About

Making use of variant manager boot folders. Change between a variant during runtime, by swapping out the TwinCAT boot folder.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published