Académique Documents
Professionnel Documents
Culture Documents
Chapter 8
Software
Development
Issues
A Summary...
A short chapter covering the basic issues regarding the development and selection of
software for interfacing problems. Real-time operating systems, multi-tasking, multiuser systems, windows environments and their relationship with object-oriented
programming (OOP). The user interface.
Digital Voltages
Analog Voltages
Digital to
Analog
Conversion
Scaling or
Amplification
Isolation
Energy
Conversion
External
System
Computer
Analog
to Digital
Conversion
Protection
Circuits
Scaling or
Amplification
Isolation
Energy
Conversion
320
8.1 Introduction
Those who relish the development of electronic hardware often place insufficient
emphasis upon the software that needs to drive that hardware and conversely, those
who specialise in software development tend to place insufficient emphasis on the
functionality of the total system. The development of a modern mechatronic system
requires a balanced approach and a recognition of the obvious point that the end system
must be a cohesive union of electronics, mechanics and software.
Most modern computers are themselves mechatronic systems and in Chapter 6,
we began to look at the interrelationship between the electronics (digital circuits),
mechanics (disk-drives, key-boards, etc.) and software (operating systems, executable
programs, etc.) that are combined to generate a very effective development tool.
However, as we now know, the computer can often become a single building block
within a larger mechatronic system involving other devices such as motors, relays, etc.
In this chapter, we will examine the software aspects of mechatronic design. We begin
by reviewing two of relevant diagrams from Chapter 6. Figure 8.1 shows the basic
hardware and software elements that are combined to form a modern computer system.
Assembler
Executable
Program 1
Executable
Program N
Operating System
Address Bus
Data Bus
ROM
(BIOS +
Bootstrap)
Keyboard
Interface
Graphics
Controller
Disk-Drive
Controller
Memory
CPU
Interrupt
Controller
Clock
Disk-Drive
Keyboard
Monitor
Figure 8.1 - Basic Hardware and Software Elements Within a Computer System
321
Figure 8.2, also reproduced from Chapter 6, shows the interrelationship between
software entities in a little more detail.
Assembler
Executable
Program 1
Executable
Program N
Software
EndUser
Operating System
Software/
Hardware
Interface
Disk-Drive
Controller
CPU
Graphics
Controller
Keyboard
Memory
Hardware
This chapter is really about the decision making process that one needs to
develop before selecting various software elements that are required for a mechatronic
application. This is not a chapter designed to teach you computer programming or
about all the intricacies of a particular operating system - there are countless good text
books on such subjects already.
In order to set the framework for further discussions, we need to develop some
sort of model for the type of systems that we will be discussing. Figure 8.3 shows the
basic arrangement with which many will already be familiar. For any given set of
computer and interface hardware, one is left with the software elements that need to be
selected:
This is not to suggest that these issues should be decided upon independently of the
hardware selection. In fact, although the hardware is most likely to be implemented
first, both software and hardware should be jointly considered in preliminary design
stages.
322
Computer
Application Software
Operating
System
External
System
Interface
Software
Interface
Hardware
If one was designing a system of the type shown in Figure 8.3 during the 1970s,
then the hardware and software selection issues could be readily resolved fundamentally because there were few options from which to choose. A closed-loop
control system would have typically been implemented on a Digital Equipment
Corporation PDP-11 computer because it was one of few capable of providing
input/output channels - the choice of computer then defined the range of operating
systems, the operating system defined the types of programming languages available
and the interface cards were normally provided by the computer manufacturer, thereby
defining the software interfacing. However, in recent times, the number of options has
expanded quite dramatically and so one has to ensure that the broad range of
possibilities is examined before committing to one particular hardware/software
architecture.
323
324
325
The windows operating system approach tends to unify the user-interface side of
the applications that run within the environment. It does so because it provides
considerably better development tools to software houses. Older operating systems
provided only bare-bones functions - that is, the basic interface between the computer
hardware and the human user. Windows operating systems provide the basic interface
and additionally, an enormous range of graphical, windowing and interactive text and
menu functions that are not only used by the operating system, but can also be used
called up from libraries by user programs. Thus, the source code for a high-levellanguage program developed for a windows environment is likely to be shorter than an
equivalent piece of code for a non-windows environment - the windows program makes
use of standard user-interface libraries while the latter requires the complete set of
routines to be developed. As a consequence, windows based programs all tend to have
a familiar appearance and operation, thereby minimising the learning curve.
The Microsoft corporation endeavoured, in the late 1980s, to transfer the benefits
of the windows environment to PC level. It did so by superimposing a package, which
it named MS-Windows over the top of the executing DOS system. This was a
significant step because it provided a migration path for the enormous DOS market to
move to a windows environment. The MS-Windows system took the single-taskingsingle-user DOS system and converted it into a multi-tasking-single-user system. As
one can imagine, this was a substantial achievement but it could only be seen as an
intermediate measure, designed to wean users and developers away from DOS, to the
extent where DOS could be removed from beneath the windows environment. This is
certainly the case with the more modern windows operating systems for PCs, which
more closely resemble workstation operating systems (ie: UNIX based) and can, in fact
be ported to a range of different hardware platforms.
At the same time, it has become evident that the lifespan of the mainframe
computer system is now very limited. Advances in processor performance, networking
and operating systems have considerably lessened the need for high-cost mainframe
systems, to the extent where they are gradually being phased out. The end result is that
for the next decade, we will live in an era where similar or identical operating systems
will reside on a range of different hardware platforms and those operating systems will
provide a much greater degree of functionality for end-users and user-interface support
for software developers.
It is important to keep this historical perspective in mind in terms of selecting an
operating system for control purposes. Certainly, there are short-term and direct
requirements such as real-time performance that cannot be overlooked. However, there
are also political factors, such as the widespread support of the operating system in
terms of development tools and so on that need to be considered.
326
In a control environment, there are typically a number of tasks that need to run
concurrently and this tends to limit the choice of operating system. In particular,
referring to Figure 8.3, a number of tasks can make up the final application:
(i)
A task that takes in data from the hardware interface and places it into
memory (variable storage locations) where it can be used by other tasks the same task may also take data from memory (variable storage locations)
and transfer it to relevant registers that cause the interface to output the
information
(ii)
A task that reads the input variables acquired by (i) and processes them
through a control algorithm, thereby generating output variables which are
passed back through (i)
(iii) A task that is responsible for interacting with the system user, displaying
system state and enabling the user to change parameters or stop the system
as and when required.
Over and above these tasks, there are other tasks which the operating system may be
running for general house-keeping or because they are initiated by a system user. Since
computers only have a limited amount of memory, and most multi-tasking operating
systems use paging, it is possible that any one task will be switched out of memory and
placed onto disk for a short period of time.
A number of issues need to be resolved before the operating system can be
selected to perform such a control task. The questions that need to be resolved are:
Following on from the point above, is there an accurate system clock that
can be read on a regular basis to ensure appropriate timing? In generalpurpose operating systems, when a program makes an operating system call
requesting the current time, the actual time is not passed back to the
program for a lengthy (in control terms) period, thereby making the figure
meaningless
Can tasks (i) - (iii) be allocated relative priorities in the overall operating
system, so that they always receive a fixed proportion of the CPU's time?
327
328
The polling and interrupt programming techniques have already been discussed in 6.7
and have both been widely used in control systems development based upon PCs. The
distributed control technique has arisen because of the ever decreasing cost of
processing power that enables interface cards to be developed with on-board
processors. This sometimes means that the personal computer provides little more than
a front-end user-interface, while the bulk of the control work is done by microprocessor
or DSP based interface cards. A typical scenario is shown in Figure 8.4. In effect
however, the system is actually multi-tasking because each intelligent interface board is
running one or more tasks (eg: PID control loops as shown in Figure 8.4).
Personal Computer
SingleTasking
Operating
System
Application
Program
(User I/F)
Intelligent
Interface 1
(PID Control)
External
System 1
Intelligent
Interface N
(PID Control)
External
System N
329
Moreover, the user-interface can affect the operation of the system because it assists in
the accurate entry of data. There are essentially five different types of user interface,
reflecting different phases of computer development since the 1960s. These are:
(i) Holorith punch card input and line-printer output
(ii) Line-oriented input via keyboard and output via text screen
(iii) Simple menu selection input via keyboard and cursor keys and output using
text or graphics screen
(iv) Pull-down menu selection input via keyboard, cursor keys and mouse and
output using text or graphics screen
(v) Full interactive graphics environment with pull down menus, graphical
icons, etc. - input via mouse, keyboard and cursor and output via graphics
screen using multiple window formats (as exemplified in Figure 8.5).
Figure 8.5 - Typical Screen from Microsoft Corporation Word for Windows
330
The Holorith card system has effectively been obsolete since the late 1970s and is
no longer in use. The line-oriented text input/output system was originally used on all
levels of computer but is now becoming obsolete, although still used in some
mainframe applications. User interface types (iii) to (v) have all been used extensively
on PCs and workstations, with type (v) interfaces currently the industry standard.
The major difference between the type (v) user interface and all the others is that
the framework for the interface and the executable code for many of the functions is
becoming an integral part of modern "window" operating systems. Those developing
software in the windows formats often do so with cognisance of other common
packages. This enables people to keep common features (such as file handling)
operating in a similar way over a wide range of different software applications. For
example, Figure 8.5 shows the user interface from the Microsoft corporation's Word for
Windows version word-processing system. Figure 8.6 shows the user interface from
Borland International's Turbo Pascal compiler for Windows. Note the similarity
between common functions such as File, Edit, Window, Help, etc. The tools provided
by various windows environments to create such software don't restrict the software
developer to such formats but they do make it easier for the developer to create similar
functions - particularly file handling, help, scrolling, etc.
Figure 8.6 - Typical Screen from Borland International Turbo Pascal for Windows
331
332
If we refer back to Figure 8.3, we can see that for a general mechatronic control
application, there are several levels of software that need to be written:
The interface between the hardware (interfacing card) and the main
application - the I/O routines
The user interface
The control algorithm.
This leaves us with the problem of deciding upon various levels of programming and
possibly, programming languages.
The software that couples the hardware interface card to the main application is
one most likely to be written in an assembly language, native to the particular computer
processor upon which the system is based. Traditionally, most time critical routines
(normally I/O) were written in an assembly language to maximise performance.
Additionally, many routines that directly accessed system hardware (memory locations,
etc.) were also coded in assembler. However, there are two reasons why many
developers many not need to resort to assembly language programming. Firstly, most
modern compilers are extremely efficient in converting the high-level source code
down to an optimised machine code and there is generally little scope for improving on
this performance by manually coding in assembly language. Secondly, many
manufacturers of I/O and interfacing boards tend to do much of the low level work for
the developer and provide a number of highly efficient procedures and functions that
interface their hardware to high level language compilers such as Pascal and C.
Given that the choice of interface software has largely been determined by the
board manufacturer, a system developer is still left with the problem of selecting a high
level language for implementation of the control algorithm and user interface. Contrary
to the opinions of many computer scientists, from an engineering perspective, the
choice of a high level language is largely irrelevant and is best decided on a political
basis rather than a technical basis - in other words, issues such as:
333
are far more important than the actual syntax differences between Basic, C, Fortran and
Pascal. In fact, viewing the process with an open mind, one would probably find that
most modern compilers satisfy the above criteria.
In the 1970s and 1980s there was much ado about the deficiencies of the Basic
programming language. Many of these were valid because the language at that time
was largely unstructured (ie: was based on GOTO statements) and was often interpreted
(converted to machine code line by line) rather than compiled (converted in its entirety
to an executable binary code). This meant that Basic was very slow and programs
developed in the language were often untidy and difficult to maintain. However,
modern versions of Basic contain the same structures as the other languages, including
records, objects, dynamic data structures, etc. Provided that one has the discipline to
write structured, modular code, with no procedure, function or main program greater
than the rule-of-thumb "30 lines" in length, then the differences between modern Basic
and C become largely syntactic.
Fortran is another language that appeared to be in its final days in the 1980s but
has since had a recovery. Fortran was originally the traditional programming language
for engineers because of its ability to handle complex numbers and to provide a wide
range of mathematical functions. An enormous number of engineering packages were
developed in Fortran, particularly older control systems, finite element analysis
packages and so on. When these advantages disappeared as a result of the large
number of third-party development tools for other languages, it seemed as though C
would become the dominant new language in the 1980s. However, the availability of
Fortran compilers, complete with tool-boxes for the windows environments has slowed
the conversion of older programs from Fortran to C and has encouraged continued
development in Fortran.
Pascal, originally considered to be a language for teaching structured
programming, came into widespread use in the 1980s as a result of the Borland
International release of Turbo Pascal. This low cost development tool sparked an
enormous range of third-party development packages and particularly encouraged
interface manufacturers to provide Turbo Pascal code for their hardware. Again, as a
result of windows development tools for the language, it is evident that it will remain
viable for some years to come.
334
String [12];
String [25];
String [7];
Integer;
A variable of type Patient_Details then contains the fields of Name, Address, Phone
and Age which can either be accessed individually or as a record group.
An object combines a group of variables and the functions and procedures (subroutines) that handle those variables. For example:
Patient_Details = Object
Name:
String [12];
Address: String [25];
Phone:
String [7];
Age:
Integer;
Procedure Enter_Name;
Procedure Enter_Age;
Procedure Write_Name;
Procedure Write_Age;
:
End {Object};
335
Although the concept of combining variables with the functions and procedures
that handle those variables may not seem to be of importance, it becomes far more
significant because objects are permitted to inherit all the characteristics of previous
objects and to over-write particular procedures and functions:
Special_Patient_Details = Object (Patient_Details)
History: String [100];
Procedure Enter_Name;
Procedure Enter_History;
:
End {Object};
In the above piece of code, variables of the type "Special_Patient_Details" inherit
all the fields of variables of type "Patient_Details" - moreover, they have an additional
field (History) and procedure (Enter_History) added and a new procedure
(Enter_Name) which over-writes the other procedure of the same name.
Most modern programming is based upon the principles of OOP - particularly for
windows environments. All the basic characteristics of the windows environments,
including file handling, window and screen handling, etc. are provided to developers as
objects. The developer's task is to write programs where the basic attributes are
inherited and relevant procedures and functions over-written to achieve a specific task.
The problem with the concept is that there are so many objects, variables and
procedures provided in the windows environment that it is difficult to know where to
begin and hence the learning curve is much longer than for older forms of programming
- however, the end-results should be far more professional in terms of the user interface
and in the long-term, programmers can devote more time to the task at hand rather than
the user interface.
The other major programming difficulty that people tend to find with the
windows environments is the event-driven nature of such environments. This presents
a significant departure from the traditional form of programming. In windows
environments, any number of events should trigger some routine in a program - for
example, the pressing of a mouse button, the pressing of a key on the keyboard, the
arrival of a message from the network, etc. In essence then, the task of developing a
program for a windows environment dissolves into "WHEN" type programming. In
other words, we need to develop a procedure for "when the left mouse button is
pressed" and "when a keyboard button is pressed" and so on and so forth. This is not
as easy a task as one might imagine, particularly given the number of events that can
occur and also because of the general complexity of the environment in terms of the
number of objects and variables. Consider, for example, how many events can occur at
any instant for the environment of Figure 8.5 - and these events are only for the user
interface. In a control system one also has to deal with the dynamic interaction with
hardware interfaces.
336
It appears that both OOP and windows environments based on OOP will remain
as a major entity in computing throughout the 1990s and so the issues of development
complexity must be tackled in modern mechatronic control systems. While the
windows environments have provided considerable benefits for software houses
developing commercial programs, they have (because of the extended learning curves)
also provided new problems for engineers that only need to develop specialised
programs on an infrequent basis.
It is evident that many modern compilers, even those with OOP, have still made
the software development task somewhat difficult because there have been few
attempts at simplifying the problems associated in dealing with windows environments.
However, it is also apparent that newer compilers will address the shortcomings of the
windows development process for infrequent programmers. In particular, the most
recent trend in compilers has been to provide a much simpler interface between the
infrequent programmer and the complexity of the windows environment. This has
important ramifications for engineering users who are unlikely to exploit more than a
small percentage of the functionality of a windows environment, as opposed to the
general-purpose software developers that may require the broad spectrum of functions.
337
Through the use of embedded or macro languages built into the application
itself.
338
The answer to the latter question is not always intuitively obvious. For all the
benefits involved in modifying an existing "engine", there are also shortcomings, most
notably, the fact that the performance of such a system may not be compatible with
real-time requirements. On the other hand, if one examines the rapid escalation of
processing power and the rapidly diminishing cost of both the processing power and
peripheral devices (memory, disk storage, etc.), one is left with the conclusion that in
the long-term, the use of software engines in a range of engineering applications will
become significant.
Another shortcoming of the software engine approach is that it does not
necessarily diminish the need for the developer (or more appropriately, modifier) to
understand the intricacies of both the operating system in which the application runs
and the programming language which can be used to adapt the original software engine.
On the contrary, those contemplating the use of software engines may well need to be
more familiar with the entire software picture than those developing applications from
first principles.
339
Both of these development strategies have tried to emulate some of the human thought
processes and brain functions. However, both also suffer from the same problem, born
from the adage:
"Be careful what you wish for - you may get your wish"
Novices in the field of computing always have problems in learning programming and
wish for better development tools because they think that the computer is too complex.
However, as we have seen, the computer is not at all complex, relative to humans, and
its logic processes are incredibly simplistic. The problem in coming to terms with
computing is that the uninitiated view the computer as some form of electronic brain,
with an intelligence level similar to that of a human. Few people however, realise the
complexities and, more importantly, the inconsistencies and anomalies in the human
thought process. If one therefore wishes to have software that emulates human thought
processes then one must also be prepared to endure the anomalies and inconsistencies
of the process.
340