Generic programming rules

Programming involves the entire process of design, coding, debugging and maintaining software. A computer program is a series of instructions that tells a computer or microprocessor to perform certain tasks. Regardless of the software development platform, the final program must satisfy some basic requirements.

10/20/2014


This is an excerpt from Industrial Automation: Hands On that applies to all programs, not just ladder (6.1.1 - Programming Concepts): "Programming involves the entire process of design, coding, debugging and maintaining software. A computer program is a series of instructions that tells a computer or microprocessor to perform certain tasks. In the automation field, the processor of these instructions may be a controller, such as a PLC, DCS, embedded processor or robot controller. A computer may also execute instructions for data acquisition and display, database operations or control functions. Programs may be written in a low level, machine-specific language or in a high level machine-independent language.

In automation, digital values of "On" and "Off," True or False, or 1 and 0 represents inputs and outputs. Conditional statements such as "If," "Then," "Else," "And," and "Or" are used in combination with variables to make statements that create the desired result. Variables are names that may represent physical I/O, data values in string, number or Boolean form or internal data. Variables may be as simple as a single letter, as in the statement "IF X AND Y, THEN Z," or they can be more descriptive, such as in "IF Motor_On AND Button_Pressed, THEN Conveyor_On." Descriptive variables, such as those stated in the previous sentence, are known as tags. In a dedicated controller, such as a PLC or DCS, there are usually registers dedicated to different types of data. Tags may then represent different types of data, such as bits, integers, floating point or REAL, timers and counters. Some PLC platforms allow the programmer to choose which registers are used for which data type and size memory accordingly.

The representation of a program may be text-based, using alphanumeric characters, or graphical in nature. Ladder logic, used in PLC programming, uses representations of electrical components, such as contacts and coils. Some software uses blocks similar to flow charts to program. The code inside of these blocks may take another form, such as text or ladder logic. HMI and other visual programs have a graphical representation of the screen that will be displayed to the user. Entering the tag or variable it interfaces with configures objects on that screen. Logical functions are sometimes embedded in the objects to execute when the user activates them.

Regardless of the software development platform, the final program must satisfy some basic requirements. The program must be:

  • Reliable: algorithms must produce the correct results, resources, such as buffer and data allocation size, should be correctly used, and there should be no logic errors.
  • Robust: the program should anticipate problems not due to programmer error, such as incorrect input and corrupted data.
  • Usable: textual, graphical and even hardware elements should improve the clarity, intuitiveness and completeness of the user interface.
  • Portable: software should be able to run on all of the hardware and operating systems for which it is designed. Some software development programs only operate for the manufacturer's proprietary hardware.
  • Maintainable: present or future developers should be able to easily modify the code for improvements or customizations, fix bugs or adapt it to new environments. Good practices and documentation during initial development help in this regard.
  • Efficient: the code should consume as few resources as possible, memory leaks should be eliminated and unused code deleted.

After talking to a lot of software companies in the Nashville area I have decided to try and develop the prototype myself in Microsoft Excel. Much of the code supporting the application will therefore be in VBA (Visual Basic for Applications). The above rules certainly apply in this case.



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