How simulation helps automation and controls

The controls often must be programmed for automated machinery and systems before hardware exists, but controls engineers can use simulations to test syntax, proper tag linking and addressing, and code functionality.

By Frank Lamb March 29, 2019

When building automated machinery and systems, a controls program often must be written long before there is hardware to test it on. Controls engineers use various kind of simulation to test syntax, proper tag linking and addressing, and functionality of the code.

If the programmer is working with other engineers, they often will use a shared spreadsheet for program tag names and addresses. As long as the spreadsheet is kept up to date when changes are made, multiple programmers should have no problem coordinating.

Error testing

Programmable logic controller (PLC) and other programming software have utilities that check the program for syntax errors; if illegal operations are performed, the software should catch them. Unfortunately, there are many programming errors that aren’t syntax- or format-related. For instance, operators might put illegal numbers into data registers via an HMI, causing overflows or access data registers that don’t exist. Data entry values need to be limited or protected either in the controller or in the operator interface. Most human-machine interface (HMI) software has a method of linking an application to a PLC program before downloading it to hardware. This allows tag addressing to be checked and catches typographical and formatting errors.

PLC software usually has simulation packages that will run code without a real PLC. When this is used, there are no physical inputs and outputs connected, so virtual addresses need to be substituted for real ones. “Aliasing” (linking) tags to other addresses is possible on some platforms, or routines also can be written that map one address to another. These routines can be disabled or deleted when simulation is complete.

Even when this is done, it is difficult to make simulated input/output (I/O) values react like real devices by toggling bits and changing numbers by hand. Because of this, simulation routines are often written to provide feedback like “real” I/O.

Machine vision simulators

Machine vision has had software simulators that process saved images without a physical camera for a long time. Programmers can use this to set up tools sensors before implementing the system. Images should be captured under a variety of lighting conditions and in various positions.

Figure 2: In this timer simulation, when the output is activated, it is linked to a tag named “Digital_OutputCard_Pt.3” which can drive the simulation code. Courtesy: Automation Consulting[/caption]

Another method of simulation is to build small models representing a machine complete with sensors and actuators, such as with a conveyor and pneumatic pushers, where a simulator might sort colored blocks into bins.

As with writing simulation routines, this is not often done to simulate production machinery, but it is useful in training.

Robotic software usually has software simulations to ensure axes can make it to different positions without cables and hoses “wrapping” or breaking, but, again, it is rare full simulations are done with tooling and products modeled.

Simulation can be an important tool in the arsenal of an automation professional, but it is no substitute for the debug process on actual machinery.

Frank Lamb is founder, owner, and manufacturing and automation business consultant at Automation Consulting LLC. Lamb is a Control Engineering Editorial Advisory Board member and Automation Primer is a Control Engineering content partner. Edited by Mark T. Hoske, content manager, Control Engineering, CFE Media,

KEYWORDS: Software simulator, programmable logic controller, error testing

Automation programming can simulate machine functions to test helping programmers write better code.

Writing a simulation can be as complicated as writing the original program

Simulation code can show how a sequence operates.


How could your control code be improved with simulation?

Author Bio: Frank Lamb is founder and owner of Automation Consulting LLC and member of the Control Engineering editorial advisory board.