How to Update a PLC’s Firmware with the ControlFlash Plus API

An Application Programming Interface, or API, provides a way for applications to interact programmatically. That’s a fancy way of saying that one application can talk to another application. Some Rockwell Automation products come with APIs that let you automate repetitive tasks. In this article, I’ll show you how to use the ControlFlash Plus API to automatically update the firmware of a PLC.
Automating tasks is a great way to free up engineers’ time. This time can be used to do high-value work or training to learn the skills that they need to work effectively.
Visual Studio
Let’s start by looking at the Visual Studio project that I have written to update a PLC’s firmware.
In Visual Studio, I have created a project that targets version 4.8 of the .NET Framework.

I have also added a reference to the ControlFlash Plus SDK, which was installed with ControlFlash Plus on my computer.

In the project’s code file, I have hardcoded some input parameters that define how the project will behave.
Specifically, I have defined the path to the controller, the firmware revision that I will use for flashing, and the path of the communication driver to be used.
In a production environment, these parameters would be passed in as command-line parameters so that the application’s behavior is dynamic.

The first thing that we have to do is to create an instance of ControlFlash Plus. We do this by calling the Init method in the ControlFlash Plus API, as shown here.

Next, we create the path list using the PathList method. This is the list of devices that are accessible through the communication driver.
If we wanted, we could allow the user to select a device to target from this list.

Then we check what firmware is available on our computer using the FindAllFirmwares method. The list is printed to the console.

If we wanted, we could allow the user to select a firmware revision from this list.
Then we use the Validate method to check if the firmware is compatible with the device that we are targeting.

After doing these checks, we are ready to flash the firmware of the PLC.
We do this by using the FlashDevice method. The progress of the flash is printed to the console while the method is executing.

Finally, once the flash is complete, we close the instance of ControlFlash Plus that we have been using.

Now that we have seen the structure of the application, let’s see what happens when we run it.
The application executed as expected by creating an instance of ControlFlash Plus, creating the path list, creating the firmware list, validating the operation, and flashing the PLC.
The end result is that the PLC has been flashed successfully without any manual interaction.
Automating updates
In this example, we used hardcoded values to define how the application behaves.
In a production environment, you could update the application to have dynamic behavior based on user input. This input could come from command line arguments, which are additional inputs that are given to the application when it runs.
The advantage of using command line arguments is that they can be configured in a batch file. If you had to update a fleet of controllers, you could easily create a batch file that calls the application multiple times with different command-line inputs for each PLC.
This would allow firmware updates to be rolled out automatically with no manual intervention required.

If you want to learn more about PLC programming, check out realpars.com. Under Courses, choose PLC Programming as the skill path. We have several courses in this skill path, so you can find the courses that will help you take your skills to the next level.
For example, if you want to learn about Allen Bradley Logix PLCs, under Brands, filter for Allen Bradley and start with the first course in the Learn Logix series, called Learn Logix 1 - The Logix 5000 Product Line.
Wrap-Up
In this article, I showed you how you can use the ControlFlash Plus API to automatically update the firmware of a PLC.
I also explained how you could extend this application by using command-line inputs and batch files to automate the process of updating many PLCs.
This is one example of how you can automate repetitive, boring tasks to free up engineers’ time.
With this time, they can focus on high-value work or on developing the skills that they need to do their work productively.
If you want to learn more about how you can train your teams in an effective and cost-effective way, check out realpars.com/business.
Frequently asked questions
An API (Application Programming Interface) lets one program talk to another to get things done automatically.
Firmware is the software inside a PLC that controls how it works. It can be updated to fix bugs or add features.
Just like your phone or computer, PLCs need updates to stay secure and work better with new features.
Yes! Instead of doing it manually, you can use tools like the ControlFlash Plus API to do it with code.
ControlFlash Plus is a Rockwell Automation tool that helps you update firmware on PLCs.
They let you run the same command on many machines automatically—like updating PLC firmware—so you don’t have to do it one by one.
Learn from Industry Experts
With a 7-day trial, then €35/month