Comparison
C# or Python for industrial PC software beside the PLC
Short answer
Write the Windows-side application in C#. The camera SDK ships only C# bindings and the vendor's own ADS implementation for Windows is the .NET library, so Python adds two maintained translation layers for no capability gain; keep deterministic sequencing in Structured Text on the PLC and keep Python for standalone utilities.
On this page
- What runs on the PLC and what runs on the PC
- The three routes compared
- What the .NET ADS library gives you that the Python wrapper does not
- Where Python still wins
- Worked example: counting translation boundaries on the gantry camera IPC
- Build order for the C# side
- The decision, case by case
- Questions asked
Write the Windows side in C#. Two facts decide it before preference counts: your camera ships only a C# library, and the vendor's own ADS client for Windows is the .NET library, while the Python option is a community wrapper over the vendor's C API. Choosing Python here means maintaining two translation layers to reach fewer features. Sequencing and interlocks stay in Structured Text on the PLC in every scenario, and Python stays the right tool for standalone utilities that never touch a C#-only SDK. What follows is the responsibility split, the three realistic routes, what each ADS library actually gives you, a boundary count for your gantry machine, and a build order that keeps C# supportable for a Python-fluent team.
What runs on the PLC and what runs on the PC #
The language question only exists for the non-control code, so draw that line first. Anything deterministic — interlocks, machine states, motion acceptance, sequence steps — belongs in Structured Text on the PLC. Everything else comes off the controller.
| Responsibility | Owner |
|---|---|
| Interlocks, machine states, critical sequencing | PLC, in Structured Text |
| Accepting or rejecting motion and command requests | PLC |
| Camera acquisition, image handling, live display | C# application on the PC |
| Operator screens and command requests | C# HMI |
| Path planning and heavy non-control processing | Separate process on the PC side |
Treat every HMI write as a request the PLC may reject against machine state. A safe stop and every PLC-owned transition must complete with the Windows application crashed, closed or mid-update: PC-side process health is never a precondition for stopping the machine. If the operator station ends up as its own unit at the machine instead of sharing the gantry's IPC, an industrial panel PC is the class of hardware that hosts it.
The three routes compared #
Only three routes are realistic for the Windows side of this machine.
| Route | Camera access | PLC access | Type and struct handling | Best fit |
|---|---|---|---|---|
| C# application | Vendor SDK called directly | Vendor .NET ADS library | Internal type checks, struct handling, enum type definitions; grouped transfers | Any machine with a C#-only SDK in the data path |
| Python application | Wrapper you write and maintain | Community pyads wrapper over the vendor C API | Access methods that return different objects; struct auto-mapping varies by method | Standalone utilities, Python-only stacks, basic tag access |
| TwinCAT HMI | Only what the HMI environment can integrate | Native to the Beckhoff toolchain | Reported built-in controls for EtherCAT diagnostics, XTS and TwinCAT Vision | Screens that mainly surface those Beckhoff features |
Beckhoff documents TwinCAT HMI as integrating into Visual Studio with a graphical configuration editor; the diagnostics and motion controls are what practitioners report as its practical advantage. One shop that had to show more than 16 axis groups in a single top-down view, alongside a live camera feed, writes its HMIs in WPF instead — and the camera's C# library decided the language there exactly as it does here.
What the .NET ADS library gives you that the Python wrapper does not #
Beckhoff's .NET API is the full ADS client implementation for Windows, documented for reading and writing the process image and the symbolic access around it. The same vendor publishes an open C library aimed at ADS clients on non-Windows systems such as Linux, and pyads is a community wrapper over that C API — so the Python route stands two steps from the vendor's supported surface before the camera is even considered.
Documented on the .NET side: SumSymbolRead performs symbolic read access with automatic value marshalling, and paired with SumSymbolWrite it groups many symbolic operations into one call instead of leaving your application to manage them individually; the reactive extensions add symbol and state observables on top of the client. Reported by engineers who tested both libraries: stronger internal type checks, struct handling and reading of enum type definitions in C#, AdsSymbolicServer as a stand-in server for exercising client code without the production PLC, and a more capable soft router in the C# library for systems without TwinCAT installed.
Reported from production use of the Python wrapper: several ways to access variables, structs and symbols that return different objects with different capabilities; more than one automatic struct-mapping method, some supporting callbacks and some not; no Secure ADS; and a failed login returning garbled Unicode instead of a diagnostic. C# also rejects a type mismatch at compile time, where Python meets the same mismatch at runtime on the plant floor.
Where Python still wins #
None of this makes Python the wrong language in general. For data collection, analysis and engineering utilities that never touch a C#-only SDK, team fluency decides, and the working pattern is the same as running Python and Node-RED beside PLC code on an edge PC. One practitioner runs pyads permanently because the path-planning PC in the cell works under ROS, and reports it runs reliably around the clock once the application standardizes on a single access method. That is the honest shape of the Python case: pay the inconsistency list above only where an outside constraint — ROS, an existing Python stack, a Python-only team with no C#-only SDK in the path — forces it.
Worked example: counting translation boundaries on the gantry camera IPC #
Inputs, each with its source:
- Vendor interfaces the Windows application touches: 2 — the camera SDK and one ADS route to the PLC runtime.
- Camera SDK bindings: C# only, per the camera vendor's own documentation.
- ADS on the Windows side: the vendor's .NET library, called directly from C#; pyads reaches the same protocol through the vendor's C API.
- Your alternative: a Python wrapper around the C# camera SDK, written in-house.
Rule in words: a translation boundary is any maintained layer standing between your application code and a vendor library; count one per vendor interface on each route.
Arithmetic:
- C# route: camera SDK called directly = 0 boundaries; ADS .NET called directly = 0 boundaries; 0 + 0 = 0.
- Python route: in-house wrapper around the camera SDK = 1 boundary; pyads over the C API = 1 boundary; 1 + 1 = 2.
Result: the Python route carries 2 maintained boundaries, the C# route 0.
Decision: with two vendor interfaces and one C#-only SDK you are past the threshold. Two boundaries means two layers rebuilt after every SDK update, set against a one-time learning curve, so the Windows side is C#. The threshold in one line: a C#-only SDK anywhere in the data path decides the language; with zero C#-only SDKs, stay with Python. Each boundary is also toil someone pays for on call, which is the same case made for reducing toil and defining team boundaries in any automation codebase.
Build order for the C# side #
- Write the interface contract before any screen: every command, acknowledgement, state value, structure and enum that crosses ADS.
- Build the Structured Text state machine with explicit acceptance conditions for each external command.
- Stand up a minimal C# client: connect over ADS, read one scalar, write one non-critical test command, confirm the PLC acknowledgement.
- Add struct and enum mappings, and fail startup with a clear diagnostic when the deployed PLC symbols do not match the application's model.
- Group larger transfers with SumSymbolRead and SumSymbolWrite rather than managing individual calls.
- Integrate the camera through its SDK as its own module, with acquisition state tracked separately from the ADS connection state so one failure cannot mask the other.
- Bind screens to application state instead of calling ADS or the camera from UI event handlers.
- Test command validation, type conversion, disconnection, reconnection and malformed data, using AdsSymbolicServer where the test boundary allows it.
- Write down the project layout, build, deployment steps, ADS route and camera configuration so Python-first coworkers can support the result.
The Windows host then runs unattended next to the machine, and the practices for running a compact industrial PC as an always-on server apply to it unchanged.
The decision, case by case #
- Your machine — a camera with C#-only bindings, ADS to the PLC, a custom HMI with a live feed: one C# application for the whole Windows side, all sequencing in Structured Text on the PLC.
- No C#-only SDK anywhere in the data path and a Python-first team: Python, standardized on one access method for variables and structs.
- Screens that mostly surface EtherCAT diagnostics, XTS or TwinCAT Vision: evaluate TwinCAT HMI first. The moment a screen must show a live camera feed or a custom multi-axis view, you are writing custom presentation code, and the camera's library has already picked the language.
Questions asked
Can I keep the camera C# code small and write the rest in Python?
Yes, by putting the camera SDK behind one small C# service that publishes images and results to the rest of the system. Only that service is C#. It works when the camera is your only C#-only interface; on this machine the ADS side points the same way, so a single C# application is the simpler shape and avoids a third moving part between the HMI and the camera.
How do I test C# ADS client code without the machine connected?
Use AdsSymbolicServer. Engineers who tested both libraries describe it as a stand-in ADS server for exercising client code without coupling tests to the production PLC application; it is available for C# across operating systems or as a C++ DLL import on Windows. The Python wrapper has no equivalent, which matters once you start unit-testing reconnection and malformed-data handling.
Where should image processing and path planning run?
Off the PLC. Anything that is not deterministic machine control belongs in a separate layer on the PC side: the C# application for acquisition and display, and a heavier processing step in its own process if the pipeline demands it. The PLC keeps interlocks, machine states and sequence acceptance, and must complete a safe stop whether or not the PC application is running.
Our whole team knows Python. Is the switch still worth it?
For this machine, yes: two vendor interfaces and one C#-only SDK give Python two translation layers you maintain yourselves. Where those conditions do not hold, stay with Python and standardize on a single access method for variables and structs, because most reported reliability problems come from mixing the wrapper's several access styles. Budget the learning curve once, and document the build and deployment so the team can support it.
When is TwinCAT HMI the better pick over a custom HMI?
When you already lean on the Beckhoff ecosystem: the HMI integrates into Visual Studio with a graphical configuration editor, and users report built-in controls for EtherCAT diagnostics, XTS and TwinCAT Vision. If your screens need a live camera feed or a custom top-down view of many axes, you are writing presentation code either way, and the camera library already decides the language.