
Dahlke.TwinCAT.Ads
A .NET library for TwinCAT ADS with typed reads and writes, stable connections, live subscriptions, PLC alarms, and a simulation mode for tests.
Description
Dahlke.TwinCAT.Ads is a .NET library that talks to Beckhoff TwinCAT PLCs over ADS. It gives you a simple, typed way to read and write PLC values, keep connections alive, and react to changes. You do not have to write the low-level ADS code yourself.
The main idea is that you work with normal .NET types. You ask for a value by its symbol name and get back an int, a float, a bool, or your own struct. PLC structs, function blocks, unions, and arrays map onto records, classes, and structs by member name.
What it does:
- Typed reads and writes: Read and write with
ReadValueAsync<T>andWriteValueAsync<T>. WithPlcSymbol<T>you name a symbol and its type once, instead of repeating the path at every call. - Stable connections: One object stands for one PLC. If the link drops, it reconnects on its own and you keep the same handle. Calls wait for a connection up to a timeout and then fail with a clear error, so you never get a false “all good”.
- Live subscriptions: Get told when a value changes, and keep getting told after a reconnect. An optional Reactive package turns these into
IObservable<T>streams. - PLC alarms: An optional package keeps a live list of open alarms, sends you the changes, and acknowledges them through the PLC’s own method.
- Batch, RPC, and raw access: Group many reads or writes into one round trip, call PLC methods, read enum names, and reach addresses the symbol API cannot, like an EtherCAT master.
- Simulation and testing: Put a target in simulation mode and run without a PLC. A small test helper records what your code wrote, so tests need no TwinCAT install.
- Runs anywhere: Use it with ASP.NET Core, or in a console, WPF, or WinForms app with no host. Health checks and startup config checks are built in.
The same repo also ships three EtherCAT packages: master and slave diagnostics over ADS, an ESI device catalogue, and CiA-402 drive decoders.
Every package targets net8.0, net9.0, net10.0, and netstandard2.0, so it also runs on .NET Framework 4.8.
GitHub: https://github.com/patdhlk/Dahlke.TwinCAT.Ads
NuGet: https://www.nuget.org/packages/Dahlke.TwinCAT.Ads
Used Tools and Technologies
- C# / .NET
- TwinCAT ADS
- ASP.NET Core
- Reactive Extensions (Rx)
- EtherCAT
- NuGet
- netstandard2.0 / .NET Framework 4.8




