Skip to content

benhar-dev/ads-boot-mode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

ADS Control of TwinCAT Boot Mode

Disclaimer

This is a personal guide not a peer reviewed journal or a sponsored publication. We make no representations as to accuracy, completeness, correctness, suitability, or validity of any information and will not be liable for any errors, omissions, or delays in this information or any losses injuries, or damages arising from its display or use. All information is provided on an as is basis. It is the reader’s responsibility to verify their own facts.

The views and opinions expressed in this guide are those of the authors and do not necessarily reflect the official policy or position of any other agency, organization, employer or company. Assumptions made in the analysis are not reflective of the position of any entity other than the author(s) and, since we are critically thinking human beings, these views are always subject to change, revision, and rethinking at any time. Please do not hold us to them in perpetuity.

Overview

This is a simple how-to guide, showing two possible ways to control the TwinCAT boot mode. I.e. The settings which controls if an IPC will boot in to Config, or boot in to Run following a power-on.

Using ADS

Boot mode can be changed by setting it's parameter using ADS. Writing either the 4-Byte value 5 (Run Mode) or 15 (Config) to ADS Port 10000, Idxgrp 220, IdxOffs 1.

// Example in C#
// -------------------------------------------------------------------------
// Create an instance of the AdsClient class
using(AdsClient adsClient = new AdsClient()) {

  // Connect to the target AMS address and port
  string amsNetId = "x.x.x.x.1.1"; // Replace with your actual AMS Net ID
  int port = 10000;
  adsClient.Connect(amsNetId, port);

  // Define ADS Index Group and Offset
  uint indexGroup = 220; // Index Group 220 (0xDC)
  uint indexOffset = 1; // Index Offset 1

  // Define the 4-byte value to write (e.g., 5 Run Mode or 15 Config Mode)
  int value = 5; // Change this to 15 if needed
  byte[] data = BitConverter.GetBytes(value);

  // Write the value to the specified Index Group and Offset
  adsClient.Write(indexGroup, indexOffset, data);
  Console.WriteLine($"Parameter set to {value}");

  // Ensure the connection is closed and resources are released
  adsClient.Dispose();
  Console.WriteLine("Connection closed.");

}

Using Powershell

# Get Registry value
$StartupState = (Get-ItemProperty -Path HKLM:\Software\WOW6432Node\Beckhoff\TwinCAT3\System).SysStartupState

# Show the current state before the change
Write-Output "State: $StartupState"

# Set Registry value (Start in Run mode: 0x5, Start in Config mode: 0xf)
Set-ItemProperty -Name SysStartupState -Path HKLM:\Software\WOW6432Node\Beckhoff\TwinCAT3\System -Type DWORD -Value 15

# Show the current state after the change
$StartupState = (Get-ItemProperty -Path HKLM:\Software\WOW6432Node\Beckhoff\TwinCAT3\System).SysStartupState
Write-Output "State: $StartupState"

Need more help?

Please visit http://beckhoff.com/ for further guides

About

This is a simple how-to guide, showing two possible ways to control the TwinCAT boot mode. I.e. The settings which controls if an IPC will boot in to Config, or boot in to Run following a power-on.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors