How the TwinCAT state is controlled
TwinCAT can be set to Config mode using DTE commands; the FreeRun state can be toggled, and the current start state can be queried via the interface.
Requirements
- A Visual Studio / TcXaeShell DTE connection is active.
C# sample
// Switch TwinCAT to config mode
dte.ExecuteCommand("TwinCAT.RestartTwinCATConfigMode");
// Switch TwinCAT to run mode
dte.ExecuteCommand("TwinCAT.RestartTwinCATSystem");
// Check if TwinCAT is started (config or run mode)
bool isRunning = sysManager.IsTwinCATStarted();
PowerShell sample
# Config mode
$dte.ExecuteCommand("TwinCAT.RestartTwinCATConfigMode")
# Toggle FreeRun
$dte.ExecuteCommand("TwinCAT.ToogleFreeRunState")
# Check status
$isRunning = $sysManager.IsTwinCATStarted()
Write-Host "TwinCAT läuft: $isRunning"
![]() | The TwinCAT state can be controlled not only using the DTE commands shown here, but also directly via ADS (TwinCAT system service, ADS port 10000). |
![]() |
|
