As machine controllers take on more responsibility beyond traditional control tasks, systems are expected to handle motion control, data processing and decisions in one platform. How can control architectures enable advanced functionality on the controller? How integrated programming helps real-time performance and system design?

Using C++ in motion control insights
- Modern industrial controllers can handle both motion control and data-driven tasks directly at machine level, without relying on an external PC
- Learn how task timing, controller resources, and execution models affect performance when running real-time data queries
- Understanding how C++ extends IEC 61131-3 logic by enabling more sufficient handling of complex algorithms and larger datasets
Industrial control platforms continue to grow in performance and capabilities to provide more than just the execution of ladder logic or simple input/output (I/O) functions, including the use of C++ programming for motion control.
Programming language use in automation
Modern automation systems simultaneously provide deterministic motion control, process control, and data analysis. The introduction of IEC 61131-3 control programming languages in 1993 empowered engineers to achieve real-time control and advanced functionality in one platform. As automation needs grew, engineers increasingly turned to C++, where a wealth of open source and paid libraries provide solutions for computational and memory intensive algorithms. Most machine builders and programmers traditionally relied on an external device or PC when needing to incorporate C++ into a machine, but modern controllers now offer this capability natively. Earlier generations of motion platforms typically lacked built-in support for higher-level languages. Newer architectures include this functionality as part of the controller, giving engineers greater flexibility in how they design and execute complex operations. The progression of machine controllers over the last 50 years conveys the shift toward fully integrated systems that can process more information and respond in real time.
Data-driven automation expands manufacturing efficiencies
Today’s global leaders in automation and manufacturing rely heavily on data. Engineers expect their machines to provide substantial, tangible results often through I/O devices or working with large datasets such as order files and part catalogs. Meeting these expectations often requires a controller that can process information locally while still maintaining reliable motion performance. A practical example is a barcode-driven process in which a vision sensor reads a code, the system retrieves details from a database file, and then applies that data to motion logic. In many applications, distributed I/O modules also support data retention at the machine level, ensuring that sensor and device information is available to the controller without delay. As production lines continue shifting toward more connected and data focused operations, it has become increasingly important for controllers to handle these workloads internally rather than relying on an external PC.

C++ routines with PLC logic: Deterministic cooperation
As controller architectures continue to evolve, manufacturers have flexibility when integrating C++ into real-time environments through various execution models, allowing advanced algorithms to run alongside PLC logic without disrupting deterministic control. One approach allows C++ routines to run asynchronously from the main control cycle, enabling tasks such as data processing or peripheral management to execute without affecting deterministic motion behavior. Developers can run these tasks under different controller states and exchange data with the application as needed. In contrast, a second approach supports synchronous execution, where C++ routines run at user-defined task rates in coordination with the controller’s real-time execution manager. This method is used when precise timing and deterministic data exchange are required, such as for control algorithms or high-frequency calculations. In many ways, the synchronous model acts as an extension of IEC 61131-3 logic, providing additional computational power and flexibility while remaining integrated within the main control loop.
When using C++ in a real-time controller, external libraries must be compiled directly into the project to ensure deterministic execution. This typically requires the library’s full source and header files, along with updates to the build configuration. One common example is using SQLite (SQLite Consortium) as an embedded database engine. SQLite is a popular choice for these applications because it provides a lightweight, file-based database engine that can run locally on the controller. This platform excels in speed and efficient operations while being exceptionally portable to eliminate complexity when managing multiple systems.
Data organization tips for motion, machine control
SQLite allows the controller to open database files, perform targeted queries and return results with minimal overhead, making it suitable for order lookup, configuration tables and other machine-level data tasks.
To better understand how a modern motion controller can manage database activity, a sample SQL test project was created (Figure 1) using three different file sizes. The goal of the testing was to evaluate how quickly the controller could open a local database file, complete its initial query, and then run subsequent queries once execution plans and caching were established. Throughout the test, parameters such as database size, task rate and thread idle time were adjusted to observe their effect on total query time and CPU load.

Using SQL on a controller? Ask three questions
Engineers commonly ask practical questions when considering SQL on a controller, such as:
1. Are there size limitations when storing and accessing a database locally?
2. Can the controller retrieve specific records fast enough for machine-level decision making?
3. Is sub-second query performance achievable under realistic operating conditions?
The test scenario below was designed to explore these questions and provide measurable data on real-time SQL behavior within a controller environment.
Reading and performing an SQL query with various file sizes
- Small file: 2.7 MB, 1000 rows, 12 columns
- Medium file: 19.5 MB, 40,000 rows, 12 columns
- Large file: 61.2 MB, 400,000 rows, 12 columns
Impact on CPU load when performing multiple SQL queries
- Three file sizes: Small, Medium, and Large
- Task rates used: 1ms, 8ms, 100ms
- Interval between queries: 8ms, 200ms, 500ms.
Lower thread idle time has an impact on CPU load. The values in each cell (Table 1) are portrayed as three numerical values to show the CPU load on the controller’s three cores, listed in order from Core 1 to Core 3.
Time to perform a task is constant regardless of idle time and task update, however values are updated on the controller at task rate. Note: The 1ms idle time test case represents a scenario that is an atypical machine setting. It was intentionally included to reveal performance boundaries and provide a clear view of how the controller behaves under stressed conditions.
The SQL testing demonstrates how a modern motion controller can open a local database file, run an initial query and repeatedly retrieve data across multiple file sizes. Invariably, file access occurred within a few milliseconds, and while the first query took longer on larger databases due to execution plan creation and caching, each dataset’s subsequent queries returned results, in well under one second once initialized.
Tests to measure CPU load for motion control

To obtain a better understanding of how timing parameters affect performance, additional tests were run to measure CPU load and query timing at different thread idle settings (Table 3). This helps provide a picture of how often a controller updates data and how these rates influence resource usage. The results reveal that shorter interval times increase CPU activity, while longer interval times reduce it, aligning with expected behavior across real-time systems. Query timing remained predictable across all file sizes.
The larger the file size, the more impact small query intervals have on CPU load. For medium and small files, there is less of a change in CPU load due to query intervals (CPU load ranges above are due to different thread idle times).
Working around practical limitations of IEC 61131 logic
Handling large data files using only IEC 61131 logic is possible, but not the most efficient path forward. For example, reading CSV files can result in read times ranging from a few seconds to tens of seconds. Due to unique customer datasets, users will have to program custom sorting and search algorithms. Thus, query times will vary based on the task rate and amount of additional logic. Memory management can also become more challenging as file sizes grow. In contrast, running C++ inside the controller offers a way to isolate heavier processing on a separate core while taking advantage of open-source tools when needed. This allows developers to handle large datasets, work with structured database formats, and use search libraries without adding custom, complex PLC-based logic.
Machine builders continue seeking ways to bring more intelligence into the controller as automation systems become increasingly data driven. Platforms that support IEC 61131-3 programming and native C++ make it possible to combine deterministic machine control with higher-level data processing without relying on an external device or PC. This amalgamation allows machines to respond quicker, manage larger datasets and support more sophisticated decision-making at points where work is being performed. As these architectures evolve, distributing intelligence across the controller and its associated I/O hardware has proven to improve efficiency and system responsiveness. By offloading tasks closer to the machine and leveraging more powerful computation through C++ where needed, engineers obtain flexibility when designing systems that can handle the growing demands of the industrial automation industry.
Daniel Hollman is product specialist – Motion division, Yaskawa America Inc., Waukegan, Illinois; Edited by Mark T. Hoske, editor-in-chief, Control Engineering, WTWH Media, [email protected].
Keywords
Motion control, using C++ in drives, modern VFD programming, motion control datasets
Consider this
Are you using modern programming and datasets for motion control?
You also might like
Also from Yaskawa, see:
How to select, apply VFDs: Medium-voltage motor-starting application tutorial
Control Engineering provides more on motion control topics