Automated Code Generation


Thread Starter

Paul Marriott

Has anyone had experience of using automated code generation tools for the production of PLC ladder logic programs in the process industries, specifically in the area of re-use of existing modules of code. If so did they purchase the tool from a software supplier or did they develop the
tool themselves. If the tools were developed 'in-house' were they based on using VB or another language. What were the typical savings of using this method, and were there certain tasks that couldnt be effectively automated.

Ranjan Acharya

I once saw a Wonderware application that developed TISOFT ladder logic at a customers' facility. When I looked at the ladder well .......

Not to say that there are not excellent routines out there that can be re-used. That was, after all, the original purpose of IEC 61131.3 :)

We re-use code whenever possible and we have standard templates. They tie in with customer standards for things like code layout, HMI layout, I/O labelling and so on. Machine builders I work with re-use as much as possible based on a divide and conquer approach - e.g., the pusher always works the same way so use the same few rungs over and over.

No on has yet showed me a "CASE" tool that is going to replace all the PLC programmers.

I have not used any sort of code generator for PLC code. I have copied existing standard code for new machines though. Most of the PLC code I write is too unique to be created automatically.

I do have a couple of systems where our CNC programmers are generating code automatically. These programs I wrote in VB. They take a default G-Code program and modifies to create a new G-Code program based on the parameters the programmer has entered. This works well for standard products and recipes.

Hope this helps.

Scott VanDelinder

I have done this for RSLogix software using a VB program that I wrote. The program generates as many modified copies of code as needed. This allows for easy code reuse and quicker implementation of repetitive code.

Timesavings using this method varies depending on how much repetition you have in a given project. I used it for a project where we had 6 new conveyors, 9 new gates, 4 new dust systems, and some other stuff. In each instance I was able to use a common code base for the equipment, and then make changes for the differences later. Using the VB program I was able to save about 4-5 days of programming time over the course of the whole project. Plus, since I had a nicely structured data table and used math to do the offsets, I didn't have to worry about making fat finger errors.

The only scenarios where I can't see this being worth while is when you don't have several pieces of the same type of equipment to control in your project.

If you have questions about my program you can email me ( "[email protected]", mailto:[email protected] ).


Scott VanDelinder
Concept Systems Inc.

I recently began working with a package from EZSoft called ControlBuilder which runs on AB PLC5 and SLC500 processors. Very slick package that actually writes almost all of the code for you from a simple configuration process. There are some manual entries for completing a system, but very easy once you learn. This package has a pre-configured template for ladder files and data files that is carried over to all projects, which forces a standard format for all equipment you design. This was especially attractive to me for standardization that helps our maintenance crews because every system has the same file formats. Check out their web
site at "": .

Rockwell Automation is now offering RSLogix 5 and 500 Professional versions that include VBA. You will have to write your own VBA scrip, but
it will allow you to automatically create ladder code.

Bob Peterson

All of this functionality is already built in to RSLogix via its library utility. Its a good way to deal with repetitive code but not as nifty as user defined function blocks would be. :)

It has no way to go in and cleanup old code so you have to make sure your library is made from a chunk of code that actually works before copying the code 20 times. Also, it does not deal well with descriptor/symbol changes seperate uses. Its best to handle this in an external spreadsheet and just import them after you import the library file into your program.

In a very few cases, I have used AB subroutines, but they suffer from difficulty in debugging an individual instance of the subroutine use, since they all use the same addresses within the subroutine. But this approach once saved me an enormous amount of time when I was working on a machine where the sequence seemed to change hourly. I could never have kept up with the changes without doing it this way (at least in AB logic).

Bob Peterson

Dave Campain

The company I work for has an in-house tool for code generation. I am a user,not the developer of the tool so I can't answer to questions of
language, or time of development of the original code. The savings are difficult to quantify because it varies by project, depending on the
degree of customisation and size. I would expect that the payoff is huge on a large standard project, based on experience of using the generator versus doing it all by hand. There is also an increase in quality if the code is generated automatically since it reduces the effect of typos. The limit on what can be automatically generated would be only if the
target language can not represent all ladder instructions in text form. The practical limit is how often is the code to be reused. A standard
object like a motor is perfect for generation, but a one off hydraulic unit would be better done by hand.


Asif Khokher

In the recent years, we have developed systems for our integration purposes in which complete database including Ladder Logic code is prepared in Microsoft Excel. This comprehansive database starts from a detailed I/O list and a sheet of basic objects. Objects consist of complete database (Tags) for both PLC and HMI end, and are definitions of basic functionalities to be performed at HMI and PLC. It consist of PLC code,
which is pasted manually afterwards in the RSLogix like softwares, which is text representation of Ladder Logic (if you click at left side of Ladder in the software). So actual magic lies in the capabilities of Ladder Logic
Editor and database import/export facilities available in the PLC and HMI softwares. Macros developed in the VBA then takes up input from the I/O list and Basic Objects sheet to generate whole system database depending upon the requirements of each loop or I/O.

An important advantage we get here is one-to-one correct tie of PLC and HMI tags. This AUTOMATION for AUTOMATION has drastically reduced Engineering
hours and raised the quality with zero error Engineering.

You can even use Access to perform the same functions depending upon your and customer requirements. Microsoft Access also comes with VBA to help and easy out the Macros making.

Asif A. Khokher
Sr. Design & Applications Engr
INTECH Process Automation Inc.

Andrew B. Chambers

Yes, I have developed this tool for my company. I use a Microsoft Excel front end with Visual Basic Code. It is not all that hard. I can generate Process system and Packaging system PLC, SLC, ControlLogix code with complete documentation. In addition we have added the ability to automatically generate motor and valve control screens in WonderWare. I have a list of about 30 improvements I want to make to my tool, but have not had time to do so yet.
Thanks for the reply andrew, I have a few further questions:

1) What sort of projects have you used the CASE tool on e.g. Batch Plants, Continuous Process Control, Sequencing/Machinery, Packaging?

2) How much of the code & documentation, for a complete PLC programme, did you produce using the CASE tool?

3) How much of the PLC code is made from standard modules, and how much is project/application specific?

4) In your opinion approx how much time did you save using the CASE tool?

Again thanks for the reply
I would higly appreciate your email address so you we can exchange some information about this project.