Textual computation models

Early computer systems were manually programmed using physical switches to configure the address, data and control lines of the machine. To enter data into memory, each instruction was converted into bit patterns and then the appropriate address, data and command switches were set based on these patterns.


Early computer systems were manually programmed using physical switches to configure the address, data and control lines of the machine. To enter data into memory, each instruction was converted into bit patterns and then the appropriate address, data and command switches were set based on these patterns.

To avoid the error-prone process of converting instructions into a computer’s numeric machine code, the first of many instruction list (IL) textual languages, or assembly language, emerged. Assembly language stands as the oldest non-machine language, allowing for the development of programs in human-readable format. Code in IL consists of a sequence of instructions separated by lines, each with one operator, one operand, and one optional modifier, respectively:






ST A_X43

Assembly languages encompass data types and program structures that are directly implemented on the underlying hardware. Because these languages are hardware-specific, they require in-depth knowledge of a processor’s architecture and instruction set, and they introduce code reuse challenges for multiple computer architectures.

To address these challenges, higher-level, structured text languages were developed to be generally platform-independent by abstracting the hardware layer. Because of the introduction of at least one additional layer of abstraction, it is generally accepted that structured text languages trade speed and memory for the sake of decreased development time and increased code portability. These development benefits elevated high-level textual languages over low-level instruction list languages for widespread software development.

Structured Text (ST) is a high-level textual language. It has well-defined syntax to represent data types, assign values to variables, define and call functions, and create complex algorithms involving decision making. The structured text language is similar to Pascal and uses well-defined constructions, such as if-then statements to control program execution.

Large programs are usually broken down hierarchically into smaller functional elements that define program organization. Developers commonly use a top-down or bottom-up approach when creating software using a textual language. Specifically, in a top-down approach, they spend the initial development time defining the top-level application framework and interfaces between smaller sections of code, commonly called subroutines or functions. In contrast, in a bottom-up approach, developers start by creating a variety of subroutines to perform specific tasks and using the resulting library of functions to implement a larger application.

With complex applications, there is usually a requirement to group data together as a structure. This is a standard feature in most high-level textual languages such as Pascal, Fortran and ANSI C. For example, a programmable logic controller (PLC) hardware I/O management system may require complex response mechanisms when an event happens. All the information associated with a sensor should ideally be stored as a single structure that can be addressed using a common unique name. For instance, a pump controlled by a PLC may have a status bit defining whether it is operational, an analog input defining desired speed and an analog output defining the current speed. All of these data elements can be defined as a single “pump” data structure and later referenced as a unit. In comparison to ladder diagrams, the support of structures improves program readability and reduces data access errors. As an extension, object-oriented textual languages, such as Java and C++, include support not only for creating custom data types but also for defining specific methods that work on that data.


Highly portable, extensive code reuse tools. Textual languages feature constructions such as loops and functions to help programmers implement reusable logic modules. By reducing the amount of repeated logic in an application, these constructions reduce program size, so programmers can quickly isolate errors in code and produce programs that are easier to maintain.

Strong integration with IT . As the trend of connecting industrial measurement and control systems to higher-level server applications continues its upward climb, developing applications using software tools that support Web and network connectivity is even more important. Many textual languages have built-in database-logging capabilities including Structured Query Language (SQL) database searching, source-code control features to maintain software integrity across multiple developers and Internet connectivity to incorporate functionality created by a growing Web services community.

Natural design for algorithms. Traditionally, everything in the field of mathematics, from linear algebra to vector calculus and discrete mathematics, has been represented in textual format. Therefore, textual languages provide a natural math and signal processing development experience. Many general-purpose textual development environments, such as Microsoft Visual C#, provide additional out-of-the-box functionality on top of the standard programming language functions. In addition, industry-specific textual development environments, such as NI LabWindows / CVI, also provide functionality commonly used in vertical application areas, including extensive analysis libraries such as signal ramps, filters and PID control algorithms.

Powerful low-level code optimization. Because ST languages often provide direct access to operating system or hardware-specific function calls, programmers have a greater ability to control which specific operations and how many operations are performed at the machine level. Optimized compilers and the ability to call assembly code from an ST language also help programmers control program size and execution speed.


Execution traceability. The inherent top-down nature of ST languages hinders tracing logical branches during code execution. Even though textual programming environments often include debugging tools such as breakpoints to temporarily stop execution and continue line by line, it is often difficult or impossible to predict which line of code will execute next, especially if subroutines are defined at the end of a source file or reside in precompiled modules, such as dynamic link libraries (DLLs).

Parallel execution. Multithreading was a key advance in the history of textual languages. With the ability to virtually execute multiple function calls at once, it is feasible to create rich user interfaces that seamlessly perform file I/O, database logging and hardware control without a performance decrease. To realize this benefit, however, programmers need to use specific threading and timing libraries to arrange the scheduling of different sections of code.

For instance, when developing an application that performs PID control while displaying a user interface, programmers must create at least two application threads to maintain the consistent execution timing required for PID control and allocate enough resources to maintain a smooth and responsive user interface. Also, a programmer must be careful when accessing global data, and be proficient in the use of specific multithreading constructs, such as semaphores and locks, to make sure data is not accessed from multiple threads at the same time.

Development time. In comparison to graphical development models, the “time to measurement”—the development time to create a fully functional application—is significantly higher. The strict nature of textual syntax requires that all functions and variables be declared, and often times initialized, before being used in the rest of the application. Also, ANSI C is case-sensitive, so misspelling “readfile()” as “readFile()” would return an error. While Microsoft Visual Basic protects the programmer from this scenario, the developer still needs to know the exact name of the function that performs a certain behavior, and pass the correct parameters in the appropriate order so that the desired behavior can be achieved.

There are many commonly used textual languages, spanning from low-level assembly to C-based languages to object-oriented implementations such as Java and C++. ST languages are well-suited for developing applications with strict space and performance requirements, or applications involving extensive signal processing and analysis.

Specifically, device drivers, embedded systems and real-time applications benefit from the increased speed and processing available in ST languages. However, there are significant challenges introduced when creating multithreaded applications in these languages. Also, the reduced level of abstraction apparent in textual languages can negatively affect coding efficiency.

Author Information

Wendy-Kay Logan is the product engineer for LabWindows/CVI and Measurement Studio at National Instruments.

Programming methods series

Textual computation models is the second in a series of articles exploring different software programming methods. The first article (available at www.controleng.com/archives under March 2007) looked at ladder logic. Future articles will cover function block/data flow, state chart, and simulation/modeling methods.

No comments
The Engineers' Choice Awards highlight some of the best new control, instrumentation and automation products as chosen by...
The System Integrator Giants program lists the top 100 system integrators among companies listed in CFE Media's Global System Integrator Database.
Each year, a panel of Control Engineering and Plant Engineering editors and industry expert judges select the System Integrator of the Year Award winners in three categories.
This eGuide illustrates solutions, applications and benefits of machine vision systems.
Learn how to increase device reliability in harsh environments and decrease unplanned system downtime.
This eGuide contains a series of articles and videos that considers theoretical and practical; immediate needs and a look into the future.
Controller programming; Safety networks; Enclosure design; Power quality; Safety integrity levels; Increasing process efficiency
Additive manufacturing benefits; HMI and sensor tips; System integrator advice; Innovations from the industry
Robotic safety, collaboration, standards; DCS migration tips; IT/OT convergence; 2017 Control Engineering Salary and Career Survey
Featured articles highlight technologies that enable the Industrial Internet of Things, IIoT-related products and strategies to get data more easily to the user.
This article collection contains several articles on how automation and controls are helping human-machine interface (HMI) hardware and software advance.
This digital report will explore several aspects of how IIoT will transform manufacturing in the coming years.

Find and connect with the most suitable service provider for your unique application. Start searching the Global System Integrator Database Now!

Infrastructure for natural gas expansion; Artificial lift methods; Disruptive technology and fugitive gas emissions
Mobility as the means to offshore innovation; Preventing another Deepwater Horizon; ROVs as subsea robots; SCADA and the radio spectrum
Future of oil and gas projects; Reservoir models; The importance of SCADA to oil and gas
Automation Engineer; Wood Group
System Integrator; Cross Integrated Systems Group
Jose S. Vasquez, Jr.
Fire & Life Safety Engineer; Technip USA Inc.
This course focuses on climate analysis, appropriateness of cooling system selection, and combining cooling systems.
This course will help identify and reveal electrical hazards and identify the solutions to implementing and maintaining a safe work environment.
This course explains how maintaining power and communication systems through emergency power-generation systems is critical.
click me