---
title: "Activate and download to TwinCAT"
---

# Activate and download to TwinCAT

Activate a configuration, log in and download, start, stop, log out and generate the boot project on a TwinCAT controller through the engineering host, each action confirmed and logged.

**State:** modelled. Built in the Editor and tested on Linux through the real client and services against a model of the engineering host that checks every confirmation as the protocol requires. Nothing has run against TwinCAT, the engineering host on Windows or a controller. Use these commands on a bench controller only, never on a machine or a plant network.

## Commands

Command Palette (Neural Inverse PLC), the **TwinCAT Projects** view's title menu (under "..."), or the context menu of a project row (all six) or a PLC project row (all but Activate Configuration). No key runs any of them.

| Command | What changes |
|---|---|
| Activate Configuration... | Activates the TwinCAT project on the target and restarts TwinCAT; the PLC program is replaced and the outputs may change |
| Login and Download... | Logs in and downloads; the PLC program is replaced and the outputs may change |
| Start PLC | The PLC runtime starts |
| Stop PLC | The PLC stops executing |
| Logout | Logs out |
| Generate Boot Project... | Sets autostart in the project and generates the boot project |

While an action runs, the status bar shows **PLC Controller Action**.

## Run an action

1. Run the command. Pick the TwinCAT project, the stored TwinCAT target (added with **Connect to TwinCAT Target**, see [Connect to controllers](https://neuralinverse.com/docs/modules/plc/targets/)) and, for the PLC actions, the PLC project. The PLC project whose AMS port is the target's is offered first. Each is asked only when there is more than one and the command was not started from a row.
2. Read the confirmation. It names:
   - the target (host, AMS Net ID, AMS port);
   - the controller's state read over ADS just now (device, version, ADS state, device state) when the Editor is connected to that target, or that it was not read and why;
   - the project with the number of its files and a fingerprint of their contents, and the PLC project with the AMS port of its runtime;
   - for an activation, the controller the project file names as its target and, when it is another, "This project targets X; activating retargets it to Y.";
   - that the action runs in the TwinCAT session that builds the project;
   - what changes, and that the action is logged with the operating system's user name.
3. Confirm with the action's own button, or cancel. Cancelling sends nothing.
4. Read the outcome in the notification (below) and in the **PLC** log.

Login, start, stop and logout act on the PLC runtime at the AMS port the PLC project names (`AmsPort` in the `.tsproj`). They are refused, with nothing sent, when the PLC project names none or another port than the target's: add a target with that port. A start of a runtime that already runs, and a stop of one that is stopped, are refused before anything is sent. No second TwinCAT starts: the actions run in the project's resident engine session, the one Build Project uses.

## Read the outcome

The notification names the action and the target, with one of four outcomes:

| Outcome | Meaning |
|---|---|
| Succeeded | A read of the controller showed the change: the runtime moved to run after a start, to stop after a stop; TwinCAT was seen not running and then running after an activation |
| Sent, its effect not observed | The request went through but nothing shows its effect: a login to a runtime that already ran, a logout, the boot project (its autostart is read back from the project, not from the controller). The result never says "confirmed" then |
| Did not run | Only when the failure says nothing was sent: refused, stale, not installed, or an error before the first call that can change the controller |
| Not known whether the controller changed | Every failure from the first call that can change the controller on, a timeout, a crash, a cancellation after sending. Check the controller before trying again |

A late answer after a timeout or cancellation is shown when it comes. See [Approvals and audit](https://neuralinverse.com/docs/modules/plc/approvals-and-audit/) for what the confirmation binds and what the PLC log records.

## Login without download

Only Login and Download is offered: the Automation Interface, as researched, cannot forbid the download. A TwinCAT User Mode Runtime started outside the Editor may be reachable as an ADS target; this has not been tried. Other TwinCAT online functions are on [What's next](https://neuralinverse.com/docs/modules/plc/whats-next/).

## Not verified

- Every action against TwinCAT XAE and a controller.
- Whether a login to a runtime that held no program reports run or stop, and whether TwinCAT's restart after an activation can be seen; an activation whose restart is not seen is reported as not known.
- Timing of activation and download on real projects.
