///// START OF VIDEO SCHEMA ///// ///// END OF VIDEO SCHEMA /////

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

Automate your PLC firmware updates with the ControlFlash Plus API.
ControlFlash Plus - thumbnail
Listen to this article

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.

A Visual Studio project setup screen showing the selection of the .NET Framework 4.8 for a PLC firmware update application.

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

The Solution Explorer in Visual Studio showing the "RA.CFPlus.SDK" reference for a PLC firmware update project.

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.

A Visual Studio code screen showing the declaration of variables, including target path and target revision.

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.

A Visual Studio code screen showing the initialization of the ControlFlash Plus SDK and error handling for updates.

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.

A Visual Studio code screen showing the generation of a path list for a PLC update with error handling for devices.

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

A Visual Studio code screen showing the generation of a firmware list with error handling and displaying firmware package details.

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.

A Visual Studio code screen showing firmware validation with the target device, including error handling and compatibility check.

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.

A Visual Studio code screen showing the flashing of a device with status checks, including success and error handling.

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

A Visual Studio code screen showing the termination of ControlFlash Plus services with error handling before exiting.

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.

An illustration showing a laptop connected to two Allen-Bradley PLCs, with a batch file used for firmware updates.

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.

FAQS

Frequently asked questions

What is an API?
What is firmware in a PLC?
Why do PLCs need firmware updates?
Can firmware updates be automated?
What is ControlFlash Plus?
How are batch files used in industrial automation?

Learn from Industry Experts

Start your learning journey today!
With a 7-day trial, then 35/month
Start Learning for Free