Git Product home page Git Product logo

boot-folder-swap-from-plc's Introduction

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.

boot-folder-swap-from-plc's People

Contributors

mattklev avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.