Online Changes and Runtime Patching on B&R Automation
A comprehensive guide to modifying running PLC programs on B&R (ABB) Automation platforms using Automation Studio, covering safe production techniques, limitations, and best practices.
Table of Contents
- Modifying a Running PLC Program Without Stopping the Machine
- Online Force/Override Techniques in Automation Studio
- Changing Setpoints, Timers, and Parameters at Runtime
- Saving Modified Programs Back to the CF Card for Persistence
- Online Change Limitations: What Can/Cannot Be Changed Online
- Hot-Connecting: Adding/Removing Hardware at Runtime
- Using PVI/OPC-UA to Write Variables on a Running PLC
- Runtime Parameter Modification from HMI
- Online Monitoring and Cross-Reference
- Rollback Procedures if an Online Change Causes Problems
- Change Management for Safety-Critical Systems
- Using mapp View for Runtime Parameter Changes
1. Modifying a Running PLC Program Without Stopping the Machine
Online Program Modification Overview
B&R Automation Studio supports downloading modified program code to a running controller without requiring a full machine stop. This is one of B&R’s key production-engineering capabilities, allowing engineers to push bug fixes, logic adjustments, and parameter tuning to machines in active production.
How Online Download Works
Automation Studio communicates with the target controller over Ethernet (or USB). When you trigger a download to a running system, Automation Studio evaluates whether the change requires only an online change (hot swap of code/data in memory) or a warm restart (reinitialization of variables and tasks). The download dialog indicates this with a red exclamation mark when a warm restart is needed.
Key mechanism:
- Automation Runtime (AR) keeps track of the memory layout of all tasks, programs, and libraries.
- When new code is downloaded, AR patches the in-memory binary of affected programs without stopping the cyclic tasks that are not impacted.
- Tasks that are impacted may be briefly suspended, reloaded, and resumed.
When Online Download is Possible
Online download (no restart) is possible when:
- Only program logic within existing function blocks or programs changes.
- Constant values (e.g., timer presets, setpoints declared as
VAR CONSTANT) are modified. - Internal variable initial values change, but the variable’s data type and scope remain the same.
- The AR version is >= G4.33 (transfer configuration options were significantly improved starting from this version).
Prerequisites
- The project in Automation Studio must match the installed configuration on the PLC (same hardware tree, same task structure).
- The controller must be in RUN or SERVICE mode.
- An online connection must be established via the Online Settings dialog
(configured under
Tools > Options > Online Settingsor via the project’sLogical View > Controller > Online Settings). - Ensure the correct PVI line (TCP) is configured pointing to the controller’s IP address.
Download Procedure
- Make the desired code changes in Automation Studio.
- Compile the project (
F7). Resolve any compilation errors. - Open the Transfer to Target dialog (
Application > Transfer to Targetor the toolbar icon). - Select the target controller and check the transfer options:
- Transfer Configuration: Available from AR >= G4.33, this lets you configure whether a change requires a warm restart, an INIT cycle, or if it can be applied fully online.
- Look for the red exclamation mark (
!) in the download window. If present, Automation Studio is warning that a warm restart will occur. - Click Transfer to begin the download.
Risks and Caveats
Online download to a running system carries risks, primarily page faults (memory access violations) that can crash the controller. Key risk areas identified by the B&R community:
- Pointer-based code: If code uses pointers to absolute memory addresses, those addresses may shift when new code is loaded, causing invalid memory access.
- Global variables shared across tasks: If a global variable is written by one cyclic task and read by another with different cycle times, an online change that shifts the variable’s memory location can cause corrupted reads.
- Library changes: Downloading after modifying a library without a full rebuild is risky. Always perform a Rebuild All before downloading to a running system.
- String manipulation: String concatenation and buffer operations can overflow if buffers were resized or relocated during the transfer.
- Communication cleanup: Protocols like OPC UA clients must be correctly handled in the task’s EXIT routine to prevent orphaned connections during online code replacement.
Mitigation Strategies
- Use the IECCheck library in your project. It provides runtime checks for pointer access, division by zero, array bounds violations, and other common errors, stopping the PLC gracefully before a page fault can cause uncontrolled behavior.
- Refresh pointers every cycle or protect shared data with semaphores (B&R provides the
AsSemlibrary for this purpose). - Avoid writing to the same global variable from multiple tasks without synchronization.
- Always perform a full Rebuild All (not just Build) before downloading to a running system, especially when library changes are involved.
Remote Online Downloads
Online downloads can be performed remotely over a VPN or plant network. The procedure is identical; the only difference is that the PVI line configuration must reference the controller’s remote IP address. Ensure network latency is acceptable (preferably < 50 ms) to avoid transfer timeouts.
2. Online Force/Override Techniques in Automation Studio
Force/Override Techniques Overview
Forcing (also called overriding) is the technique of overriding the logical value of a variable in the PLC, regardless of what the program logic computes. This is essential for troubleshooting, testing, and temporarily overriding sensor states or outputs without changing the program code.
Forcing in the LAD Monitor
Automation Studio’s Ladder (LAD) Monitor provides a built-in force function:
- Open the LAD Monitor for the program you want to debug (
Online > LAD Monitor). - Locate the variable you want to force (e.g., a digital input contact).
- Right-click the variable and select Force.
- Set the forced value (TRUE/FALSE for booleans, numeric values for integers/reals).
- The variable will now hold the forced value regardless of the program logic driving it.
The forced state is visually indicated in the LAD diagram — forced contacts and coils are typically shown in a distinct color or with a force icon overlay.
Forcing in the Watch Window
The Watch Window is the primary tool for forcing variables in B&R:
- Open the Watch Window (
Online > Watch Window). - Add variables by dragging them from the program editor or typing variable names.
- Each variable row shows:
- PV Value: The current process value (what the PLC logic computed).
- ForceActivated: A checkbox to enable/disable forcing for this variable.
- ForceActivated Value: The value to force the variable to.
- To force a variable:
- Check the Force On checkbox (or right-click and select “Force On”).
- Enter the desired value in the ForceActivated Value column.
- The variable will now be overridden.
- To release the force, right-click and select Force Off, or use Force All Off to release all forced variables at once.
Important: The “Force On” button is context-sensitive. If a variable is already forced, the button appears greyed out and only “Force Off” and “Force All Off” are active.
Prerequisites for Forcing
- The project in Automation Studio must match the program installed on the target PLC. If there is a mismatch, the PV Value column shows an error indicator (warning triangle), and forcing may not work correctly. Perform a Transfer to Target to synchronize the project before attempting to force.
- An active online connection to the controller must be established.
Programmatic Forcing via AsIO Library
B&R provides the AsIO library for enabling/disabling forcing from within PLC code itself:
| Function Block | Purpose |
|---|---|
AsIOEnableForcing | Enables forcing for a specific I/O data point |
AsIODisableForcing | Disables forcing for a specific I/O data point |
AsIOGlobalDisableForcing | Disables all forcing globally |
AsIODPStatus | Reads the status of a data point, including force status flags |
This is useful for automated testing scenarios where you need to programmatically override inputs/outputs.
Forcing via PVI (External Applications)
External applications can interact with the force mechanism through PVI’s link nodes
(via the ANSL variable object). The Python PVI wrapper (Pvi.py) supports writing to
force values using the 'F+' syntax:
var = Variable(task, "AF_AI[6].ModuleOk")
var.value = True # writes to force value via 'F+' syntax
Limitations of PVI forcing:
- You can write the force value and read the force status via
POBJ_ACC_STATUS. - You cannot enable/disable forcing status itself through PVI writes — forcing must be
activated either through Automation Studio or the
AsIOEnableForcingfunction block.
Safety Considerations for Forcing
- Always document forced variables. B&R’s watch window shows forced variables, but if the online connection is lost, there may be no visible indication on the HMI.
- Never leave forces active on a production machine after troubleshooting. Use “Force All Off” before disconnecting.
- Forcing outputs can cause unexpected machine motion. Always follow your plant’s lockout/tagout (LOTO) procedures when working on active machinery.
- Forcing on safety I/O is restricted by the SafeLOGIC safety controller. Standard forcing does not affect safety-rated signals.
3. Changing Setpoints, Timers, and Parameters at Runtime
Runtime Parameter Changes Overview
Runtime parameter modification is the most common and safest form of online change. Unlike code modifications (which carry page-fault risk), changing the values of variables at runtime simply writes new data to the controller’s memory without altering the executable code.
Methods for Runtime Parameter Changes
Method 1: Watch Window (Engineering Tool)
The simplest method, available directly in Automation Studio:
- Establish an online connection to the PLC.
- Open the Watch Window.
- Add the setpoint, timer preset, or parameter variable.
- Double-click the PV Value column and enter the new value.
- Press Enter to write the value to the PLC.
This is a temporary change — the value will revert to its initialized value after a warm/cold restart unless persisted (see Section 4).
Method 2: Programmatic (Internal PLC Logic)
Parameters can be changed by PLC logic itself, for example:
(* Change a timer preset based on a recipe selection *)
IF gRecipeSelect = 10 THEN
tonCycleDelay.PT := T#5s;
ELSIF gRecipeSelect = 20 THEN
tonCycleDelay.PT := T#8s;
END_IF
(* Change a temperature setpoint *)
rTempSetpoint := rOperatorSetpoint + rCalibrationOffset;
This is the preferred method for production systems, as the logic is deterministic, traceable, and version-controlled.
Method 3: ArConfig (Runtime Configuration Parameters)
For system-level parameters (IP address, hostname, subnet mask), B&R provides the AsARCfg library:
(* Example: Change IP address at runtime *)
IF IPSet THEN
CfgSetIPAddr_1.enable := 1;
CfgSetIPAddr_1.pDevice := ADR(pDevice);
CfgSetIPAddr_1.pIPAddr := ADR(NewIPTemp);
CfgSetIPAddr_1();
IF CfgSetIPAddr_1.status = 0 THEN
(* Read back to confirm *)
CfgGetIPAddr_1.enable := 1;
CfgGetIPAddr_1.pDevice := ADR(pDevice);
CfgGetIPAddr_1.pIPAddr := ADR(NewIP);
CfgGetIPAddr_1.Len := 20;
CfgGetIPAddr_1();
END_IF
IF CfgGetIPAddr_1.status = 0 AND CfgSetIPAddr_1.status = 0 THEN
IPSet := FALSE;
CfgGetIPAddr_1.enable := 0;
CfgSetIPAddr_1.enable := 0;
END_IF
END_IF
The AsARCfg library also provides functions for:
CfgGetSubnetMask/CfgSetSubnetMaskCfgGetHostName/CfgSetHostName- And many more configuration parameters
Method 4: Persistent Variable Initialization
Variables can be initialized from files or recipes loaded at startup:
(* Load parameters from a configuration file *)
fbFileOpen(
enable := TRUE,
pDevice := ADR('CF'),
pFileName := ADR('config/setpoints.csv'),
mode := fmRead
);
This approach ensures parameters survive power cycles and are managed as data files rather than hardcoded values.
Timer Modification Specifics
B&R timers (TON, TOF, TP from the IEC_Timers library) have:
- PT (Preset Time): Can be changed at runtime simply by writing to
timerName.PT. - IN: The trigger input, also writable at runtime.
- ET (Elapsed Time): Read-only (computed by the timer block).
- Q: The output, also writable at runtime (though forcing is the preferred override method).
When you change PT while the timer is running, the new preset takes effect immediately.
If PT is shortened below the current elapsed time, the timer may or may not expire
immediately depending on the timer type and implementation.
Best Practices
- Centralize parameters in a dedicated data structure (e.g.,
ST_MachineConfig) to make runtime tuning systematic and auditable. - Validate all operator-entered setpoints with range checks before applying them.
- Log parameter changes to a data file or the AR event log for traceability.
- Use the mapp Recipe framework for managing sets of parameters that change together (e.g., product changeovers).
4. Saving Modified Programs Back to the CF Card for Persistence
The Persistence Problem
When you make changes to a running PLC via the watch window, force, or online download, those changes exist only in the controller’s volatile DRAM. After a power cycle or warm restart, all non-persisted values revert to their initialized state. To make changes permanent, you must write them back to the CF card (CompactFlash) or CFast card.
Method 1: Transfer to Target (Full Program Persistence)
The standard way to persist program changes is through the Transfer to Target operation:
- Compile the project with the desired changes.
- Transfer to Target (
Application > Transfer to Target). - Automation Studio writes the new program to the controller’s non-volatile storage (CF/CFast card or internal flash).
After transfer, the program will survive power cycles. The controller boots from the non-volatile storage on each startup.
Method 2: Save/Upload from PLC to CF Card
When you modify variables online (via watch window) and want those values to persist:
- In the Logical View, right-click the controller and select Save or use the Transfer > Upload from Target option.
- Automation Studio reads the current state of all process variables and writes them to the project.
- You then transfer the updated project back to the target.
Caveat: Simply changing a variable via the watch window does NOT automatically save it to the CF card. The B&R community has reported issues where a CF card stops functioning after variable changes via the watch window — this is typically caused by the project getting out of sync with the installed configuration.
Method 3: CF Card Image Backup (Binary Level)
For complete persistence and backup, use the Runtime Utility Center:
- Open Runtime Utility Center (installed with Automation Studio).
- Connect to the target controller.
- Navigate to CF Card Tools.
- Select Create Image to create a binary image of the entire CF card.
- Save the image file to your PC (
.imgformat).
To restore:
- Insert a blank CF card into your PC’s card reader.
- In Runtime Utility Center, select CF Card Tools > Restore Image.
- Select the saved image file and write it to the blank card.
This method captures:
- The complete Automation Runtime installation.
- All user programs and configurations.
- All persistent data (recipes, logs, parameter files).
- The AR configuration (IP settings, hostname, etc.).
Method 4: Offline Installation (AS Compile to CF)
Automation Studio can compile and write a project directly to a CF card without a running controller:
- Connect a CF card reader to the engineering PC.
- Insert the target CF card.
- In Automation Studio, use
Application > Transfer > Install CF/SD Card(Offline Install). - Select the CF card drive letter and the target partition.
- Automation Studio formats the card, installs AR if needed, and writes the compiled program.
Method 5: Persistent Data Files
For parameter data that changes frequently, store it in files on the CF card:
(* Save current parameters to file *)
fbFileWrite(
enable := bSaveTrigger,
pDevice := ADR('CF'),
pFileName := ADR('config/params.dat'),
data := ADR(stCurrentParams),
datalen := SIZEOF(stCurrentParams)
);
This approach separates program code from operational data, allowing frequent parameter updates without recompiling.
Recommended Backup Strategy
- Before any online change: Create a CF card image backup using Runtime Utility Center.
- After confirming the change works: Transfer the updated project to the target to persist the code changes.
- Periodically: Upload PVs (process variables) using Runtime Utility Center to capture the current state of all runtime values.
- For critical machines: Keep a spare CF card with a known-good image at the machine site for rapid recovery.
5. Online Change Limitations: What Can/Cannot Be Changed Online
Changes That CAN Be Made Online (No Restart)
| Change Type | Description |
|---|---|
| Constant values | Changing the value of a VAR CONSTANT declaration |
| Internal logic | Modifying expressions, comparisons, math operations within existing code |
| Variable initial values | Changing the initial value (not the data type or scope) |
| Timer/counter presets | Changing PT values of IEC timers |
| Adding new variables | Adding new VAR declarations (may require INIT cycle depending on task config) |
| Adding new function blocks | Adding new FB instances in existing programs (non-structural change) |
| Modifying existing FB instances | Changing the logic inside a function block that is already instantiated |
Changes That REQUIRE a Warm Restart
| Change Type | Description |
|---|---|
| Data type changes | Changing a variable from INT to REAL, adding array dimensions, changing STRING length |
| Task configuration changes | Changing task cycle time, priority, or phase |
| Adding/removing tasks | Creating or deleting a cyclic, freewheeling, or event-triggered task |
| Adding new programs | Adding a new program file to the project |
| Hardware configuration | Changing the I/O tree (adding/removing modules in the hardware configuration) |
| Library version changes | Upgrading a library version (may require full rebuild and warm restart) |
| Memory layout changes | Any change that shifts the absolute memory address of existing variables or code |
Changes That REQUIRE a Cold Restart (Power Cycle)
| Change Type | Description |
|---|---|
| Automation Runtime upgrade | Installing a new AR version on the controller |
| Firmware updates | Updating controller or module firmware |
| Network interface changes | Changing the IP configuration of the controller’s primary interface (sometimes) |
| System partition changes | Modifying the AR system configuration (partition sizes, boot parameters) |
Detecting What Requires a Restart
Automation Studio provides visual indicators:
- Transfer Configuration Dialog (AR >= G4.33): Before downloading, Automation Studio analyzes the differences between the installed and compiled code and indicates which changes will require a restart.
- Red Exclamation Mark: In the download dialog, a red
!icon warns that a warm restart is required. The controller will briefly leave RUN mode and execute INIT cycles for affected tasks before resuming. - No Warning: If no warning is displayed, the change can be applied purely online without any task interruption.
Structural vs. Non-Structural Changes
The distinction between structural and non-structural changes is critical:
- Non-structural changes (logic within existing functions, constant values, initial values) can typically be applied online.
- Structural changes (new data types, new tasks, hardware tree changes, library upgrades) require a warm or cold restart because they alter the memory layout that AR uses to manage running tasks.
Guidelines by Scenario
| Scenario | Can You Stop the Machine? | Can You Restart the Machine? | Recommended Approach |
|---|---|---|---|
| Urgent bug fix (logic only) | No | No | Online change (non-structural) |
| Urgent bug fix (new variable type) | No | Yes | Warm restart (download with ! warning) |
| New feature (new task) | No | Yes | Warm restart after changeover |
| Major update (library upgrade) | Yes | Yes | Full cold restart, test thoroughly |
| Parameter tuning | No | No | Watch window or HMI input |
6. Hot-Connecting: Adding/Removing Hardware at Runtime
Hot-Connecting Overview
B&R’s Automation Runtime supports hot-connecting — the ability to add or remove I/O modules from the X20 bus while the controller is running. This is primarily facilitated through the mappIO service and the AsIO library.
Enabling/Disabling Hardware Modules at Runtime with mappIO
The mappIO mapp service provides a high-level interface for modifying the hardware
configuration at runtime:
- Configure all possible hardware modules in the Automation Studio hardware tree (include optional modules even if they are not physically installed).
- Instantiate the
mappIOcomponent in your project. - Use the mappIO API to enable or disable specific modules based on runtime conditions:
(* Enable a specific I/O module based on a machine configuration *)
MappIO.EnableModule(
moduleIdent := 'X20DO9321',
slot := 3,
enable := bModuleRequired
);
Use Cases:
- Machines with optional equipment where modules are installed for some configurations but not others.
- Module replacement during operation (e.g., swapping a failed analog input module).
- Configuration-driven machines where the hardware setup depends on a recipe or model selection.
AsIO Library for Hardware Configuration
For lower-level control, the AsIO library allows creating and removing hardware configurations programmatically:
| Function | Purpose |
|---|---|
AsIOCreateConfiguration | Create a new hardware configuration at runtime |
AsIORemoveConfiguration | Remove an existing hardware configuration |
AsIOReadConfiguration | Read current configuration status |
AsIOEnableForcing | Enable I/O forcing for specific data points |
The AsIO approach was the traditional method before mappIO became available. It is more flexible but less user-friendly than mappIO.
X20 Bus Module Hot-Swap Behavior
The X20 bus system has specific hot-swap characteristics:
- Bus modules (X20BM01, X20BM11, etc.) are the backbone of the X20 I/O system. They provide the X2X backplane connection between modules.
- I/O modules can typically be inserted or removed while the bus is powered, provided the bus module supports hot-swap and the software configuration accounts for the change.
- When a module is physically removed, the AR runtime detects the absence and sets the
module’s
ModuleOkflag to FALSE. ThemappIOservice can then handle the diagnostic and optionally reconfigure the system. - When a module is inserted, AR detects the new hardware and initializes it. If the module matches the configured hardware tree, it becomes operational automatically. If it does not match, a diagnostic alarm is generated.
Practical Example: Optional Machine Configurations
(* Configuration 1: Standard machine *)
IF iConfig = 1 THEN
(* Enable standard I/O, disable optional modules *)
MappIO.SetModuleState('AI_Option', MODULE_DISABLED);
MappIO.SetModuleState('AO_Option', MODULE_DISABLED);
END_IF
(* Configuration 2: Machine with optional sensor package *)
IF iConfig = 2 THEN
(* Enable optional modules *)
MappIO.SetModuleState('AI_Option', MODULE_ENABLED);
MappIO.SetModuleState('AO_Option', MODULE_ENABLED);
END_IF
Limitations
- CPU modules cannot be hot-swapped — they are the core of the system.
- Bus modules that are in the middle of the rack chain (between two other modules) cannot be removed without breaking the X2X connection for downstream modules.
- Power supply modules obviously cannot be removed while the system is running.
- Hot-swap behavior depends on the specific module type — check the module’s datasheet for hot-swap support.
- For safety-rated modules (SafeLOGIC, SafeI/O), hot-swap is handled differently and must comply with safety standards (see Section 11).
7. Using PVI/OPC-UA to Write Variables on a Running PLC
PVI — Process Visualization Interface
PVI is B&R’s native communication middleware for accessing process variables. It abstracts the physical connection (Ethernet, USB, serial) behind a uniform API.
PVI Architecture
| Component | Location | Function |
|---|---|---|
| PVIServer | On the controller (AR) | Exposes process variables from running tasks |
| PVI Manager | Windows host | Centralized line configuration and routing |
| PVI OPC Server | Windows host | Translates OPC calls into PVI calls |
| PVI Client Libraries | Application | C/C++, .NET, VBS, Python access via PVI DLL |
Configuring a PVI Line
PVI is configured via the PVI Lines tree in Automation Studio or standalone PVI Manager:
[TCP]
Driver = TCPIP
StationA = PC_Main
StationB = PLC_01
IP_StationB = 192.168.10.50
Port_StationB = 11160
Default PVI TCP port: 11160. Modern controllers (AR >= B4.0) also expose OPC UA on port 4840.
Writing Variables via PVI (Python Example)
Using the Pvi.py wrapper (available at github.com/hilch/Pvi.py):
from pvi import *
# Connect to the PLC
line = Line()
line.connect("TCP", "PLC_01")
# Access a task
task = Task(line, "Task1")
# Write a setpoint variable
temp_setpoint = Variable(task, "gRecipe.rTemperatureSetpoint")
temp_setpoint.value = 85.5
# Write a boolean
pump_enable = Variable(task, "gMachine.bPumpEnable")
pump_enable.value = True
PVI Forcing
PVI supports writing to the force value of a variable using the 'F+' syntax:
var = Variable(task, "AF_AI[6].ModuleOk")
var.value = True # Writes to force value
## Read the force status
status = var.read_status(POBJ_ACC_STATUS)
Limitation: PVI cannot change the force activation status itself — only Automation Studio
or the AsIOEnableForcing function block can enable/disable forcing.
OPC UA — Standardized Access
OPC UA is the recommended communication method for new projects. It is supported natively on B&R controllers running AR >= 4.0.
Enabling OPC UA on the Controller
- In Automation Studio, open the Logical View > Controller > Configuration.
- Navigate to OPC UA settings.
- Enable the OPC UA Server.
- Configure:
- Endpoint URL:
opc.tcp://<controller-ip>:4840 - Security Policy:
None,Basic128Rsa15,Basic256,Basic256Sha256 - Max Sessions: Default 50, adjustable for SCADA fan-out
- Publishing Interval: Default 100 ms (minimum practical: 50 ms)
- Endpoint URL:
- Mark variables as OPC UA accessible: In the variable properties dialog, enable the OPC UA accessibility flag.
- Recompile and download.
Writing Variables via OPC UA (Python Example)
import asyncio
from asyncua import Client
async def write_setpoint():
url = "opc.tcp://192.168.10.50:4840"
async with Client(url=url) as client:
setpoint_node = client.get_node("ns=2;s=Task1.gRecipe.rTemperatureSetpoint")
await setpoint_node.write_value(85.5)
print("Setpoint written successfully")
asyncio.run(write_setpoint())
OPC UA Parameters
| Parameter | Default | Notes |
|---|---|---|
| Endpoint URL | opc.tcp://<ip>:4840 | Configurable |
| Security Policies | None, Basic128Rsa15, Basic256, Basic256Sha256 | Use Basic256Sha256 in production |
| Max Sessions | 50 | Adjust for large SCADA systems |
| Publishing Interval | 100 ms | Lower = more CPU load |
| Sampling Interval | 50 ms | Must be <= publishing interval |
PVI vs OPC UA Decision Guide
| Criterion | PVI | OPC UA |
|---|---|---|
| Standardization | B&R proprietary | IEC 62541 (international standard) |
| Encryption/Auth | None | Certificate-based, user tokens |
| Typical Latency | 5-20 ms | 10-50 ms |
| SCADA Support | Via PVI OPC bridge | Native |
| Effort to expose variable | Low (auto-exposed) | Low (mark as accessible) |
| Safety I/O Access | Yes (with restrictions) | Must exclude safety task variables |
Rule of thumb: Use OPC UA for new projects. Use PVI when integrating with B&R HMI panels or legacy systems.
Performance Considerations
Server CPU load scales approximately as:
ServerLoad ≈ N_variables × (1000 / Sampling_ms) × Payload_bytes
For 500 variables at 100 ms sampling with 8-byte payloads on an X20CP3584:
- CPU consumption: ~0.3-0.8 ms per 100 variables per cycle
- Bandwidth: ~40 KB/s (negligible on 100 Mbit Ethernet)
8. Runtime Parameter Modification from HMI
HMI Parameter Modification Overview
HMI-based parameter modification is the most operator-friendly method for runtime changes. B&R provides several HMI technologies, with mapp View being the current standard.
Architecture
The typical parameter modification chain is:
Operator → HMI Screen (mapp View) → OPC UA → PLC Variable → Machine Logic
mapp View communicates with the PLC via OPC UA internally. When an operator enters a new value in an HMI widget, the value is written through OPC UA to the corresponding PLC variable.
Designing HMI Screens for Parameter Changes
Input Widgets
mapp View provides several widgets for parameter input:
| Widget | Use Case |
|---|---|
| TextField | Free-form numeric or text entry (setpoints, filenames) |
| NumericInput | Numeric entry with min/max limits and unit display |
| Slider | Analog value adjustment with visual feedback |
| ToggleButton | Boolean on/off switches |
| RadioButton Group | Selection among predefined options |
| ListBox / ComboBox | Selection from a list (recipe names, mode selections) |
| DateTimePicker | Date/time parameter entry |
Binding Variables to Widgets
In mapp View, widgets are bound to PLC variables through the Content property:
- In the mapp View page editor, select the widget.
- In the Properties panel, set the Content to reference the PLC variable
(e.g.,
MainTask.gMachine.rSpeedSetpoint). - Configure input constraints:
- Minimum/Maximum: Numeric range limits.
- Format: Decimal places, unit display.
- Access Level: Restrict modification to authorized operators.
Implementing Access Levels
B&R provides the mapp User service for managing operator access:
(* In PLC code: define access levels *)
VAR_GLOBAL CONSTANT
ACCESS_LEVEL_OPERATOR : UINT := 10;
ACCESS_LEVEL_SUPERVISOR : UINT := 20;
ACCESS_LEVEL_ENGINEER : UINT := 50;
END_VAR
In mapp View, bind the widget’s Access Level property to the user’s current access level. When the user’s access level is insufficient, the widget is displayed as read-only.
Validation and Confirmation
For critical parameter changes, implement validation in the PLC:
FUNCTION fbSetSpeedSetpoint : BOOL
VAR_INPUT
rNewSpeed : REAL;
rMinSpeed : REAL;
rMaxSpeed : REAL;
bConfirm : BOOL;
END_VAR
IF bConfirm THEN
IF rNewSpeed >= rMinSpeed AND rNewSpeed <= rMaxSpeed THEN
gMachine.rSpeedSetpoint := rNewSpeed;
fbSetSpeedSetpoint := TRUE;
ELSE
(* Log error, reject change *)
fbSetSpeedSetpoint := FALSE;
END_IF
END_IF
Feedback to the Operator
Always provide visual feedback when a parameter is changed:
- Status indicators (green checkmark for success, red X for error).
- Current value display alongside the input field.
- Audit log visible to operators showing who changed what and when.
9. Online Monitoring and Cross-Reference
Online Monitoring Tools
Watch Window
The Watch Window (Online > Watch Window) is the primary monitoring tool:
- Displays real-time values of selected variables.
- Shows variable type, scope (global/local), and current value.
- Supports forcing (see Section 2).
- Can display values in different formats (decimal, hex, binary, float).
LAD Monitor
The LAD Monitor (Online > LAD Monitor) provides graphical monitoring of ladder logic:
- Shows real-time power flow through contacts and coils.
- Displays the current value of each variable in the rung.
- Supports forcing directly in the ladder diagram.
- Color-coded indicators show TRUE/FALSE states.
Trace (Oscilloscope)
The Trace tool (Online > Trace) is a digital oscilloscope for PLC variables:
- Record up to 4 channels of data simultaneously.
- Configure trigger conditions (rising edge, falling edge, value threshold).
- Variable time base from microseconds to hours.
- Export data to CSV for analysis.
- Essential for debugging timing-sensitive issues.
Scope View
The Scope provides real-time graphical display of variables over time, similar to an analog oscilloscope, but in a live view without recording.
I/O Monitoring
The I/O Monitor (Online > I/O Status) shows the state of all physical I/O points:
- Digital inputs and outputs with status LEDs.
- Analog input/output values with engineering units.
- Module status (ModuleOk, diagnostics).
- Bus module communication status.
Cross-Reference Tools
Go to Definition / Go to Reference
In the Automation Studio code editor:
- F12 (or right-click > Go to Definition): Jumps to where a variable is declared.
- Shift+F12 (or right-click > Show References): Shows all locations where the variable is used (read or written).
Cross-Reference View
The Cross-Reference window (View > Cross-Reference) provides a comprehensive list:
- All variables in the project with their usage locations.
- Filterable by read/write reference type.
- Shows which task/program accesses each variable.
- Essential for understanding the impact of a variable change before making an online modification.
Online Cross-Reference
When connected online, the cross-reference information is enriched with runtime data:
- Actual memory addresses of variables.
- Current values (via Watch Window integration).
- Task cycle time impact assessment.
Using Cross-Reference for Safe Online Changes
Before making an online change:
- Identify the variable you want to change using Cross-Reference.
- Check all read locations: Will any code behavior change unexpectedly if the value changes?
- Check all write locations: Will another task overwrite your change? Are there race conditions?
- Check for forcing: Is the variable currently forced? If so, your change will be overridden.
- Check task assignments: Which tasks access this variable? Different task cycle times can cause race conditions when modifying shared data.
10. Rollback Procedures if an Online Change Causes Problems
Immediate Response: Force All Off
If an online change causes unexpected behavior:
- Immediately click Force All Off in the Watch Window to release all forced values.
- If the problem was caused by a forced value, releasing it should restore normal operation.
Recovery via Online Download (Rollback Code)
If the problem is in the code itself:
- Revert the code changes in Automation Studio (use version control — Git, SVN, etc.).
- Recompile the project.
- Download to the running controller using Transfer to Target.
- If the download requires a warm restart, the controller will briefly execute INIT cycles before resuming RUN mode.
Recovery via Warm Restart
If the controller is in an inconsistent state:
- In Automation Studio, switch the controller to SERVICE mode:
Online > Set Mode > SERVICE
- This stops all cyclic tasks and initializes variables.
- Fix the code, recompile, and download.
- Switch back to RUN mode:
Online > Set Mode > RUN
Recovery via CF Card Swap (Cold Restart)
If the controller is unresponsive or in a fault state:
- Power off the controller.
- Replace the CF card with a known-good backup (created with Runtime Utility Center).
- Power on the controller.
- The controller boots from the known-good CF card with the previous working program.
Recovery via AR System Reset
If the controller is in SERVICE mode and will not start:
- Place the PLC into BOOT mode (via the hardware mode switch or by deleting the system partition).
- Connect via Automation Studio.
- Delete partitions using the HDD/CF Utility.
- Cycle power.
- Reinstall AR and the program from scratch (Offline Install to CF card).
Preventive Measures
| Measure | Description |
|---|---|
| CF Card Image Backup | Create a binary image before any online change using Runtime Utility Center |
| Version Control | Use Git/SVN to track all code changes; tag known-good versions |
| Upload PVs | Upload current process variables before changes using Runtime Utility Center |
| Test in Simulation | Use ARsim (Automation Runtime Simulation) to test changes before applying to hardware |
| Document Changes | Maintain a change log with date, description, who, and rollback version |
| Spare CF Card | Keep a known-good CF card at the machine for rapid recovery |
CF Card Backup Procedure (Detailed)
- Connect to the PLC via Runtime Utility Center.
- Navigate to Tools > Back up files from Compact Flash / Image file.
- Select Create Image to create a complete binary backup.
- Save to a PC with a meaningful filename (e.g.,
MachineA_backup_2026-07-10.img). - Store the backup in a versioned directory alongside the source code.
Restore Procedure (Detailed)
- Insert a blank CF card into the PC card reader.
- Open Runtime Utility Center.
- Navigate to CF Card Tools > Restore Image.
- Select the backup image file.
- Write the image to the CF card.
- Install the CF card in the PLC and power on.
11. Change Management for Safety-Critical Systems
Safety-Critical Change Management Overview
Modifying safety-related PLC programs requires strict adherence to IEC 61508, ISO 13849, and other applicable functional safety standards. B&R’s safety platform (SafeLOGIC, SafeI/O, openSAFETY) has specific rules for runtime modifications.
B&R Safety Architecture
B&R safety technology is built on:
- SafeLOGIC controllers: Dedicated safety PLCs (e.g., X20SL81xx, X20(c)SL81xx).
- SafeI/O modules: Safety-rated input/output modules.
- openSAFETY: B&R’s open safety protocol over POWERLINK or other fieldbuses.
- Safety+: B&R’s next-generation safety software framework with an open, digitally fingerprint-protected code base.
Rules for Online Changes to Safety Programs
-
Standard forcing does NOT affect safety I/O. The forcing mechanism in Automation Studio applies only to standard (non-safety) process variables. Safety-rated inputs and outputs are protected by the SafeLOGIC hardware and cannot be overridden through standard force functions.
-
Safety program changes require re-certification. Any modification to safety-related logic (programs running in the SafeLOGIC task) invalidates the current safety certification. The machine must undergo:
- Risk re-assessment
- Re-verification of safety functions
- Updated safety documentation
- Sign-off by a competent safety engineer
-
Safety tasks are isolated. Safety programs run in a dedicated task with higher priority and are protected from interference by standard tasks. Online changes to standard tasks do not affect safety task execution.
-
OPC UA must not expose safety variables. When configuring OPC UA on a controller that also runs safety programs, the OPC UA address space must be filtered to exclude variables in the safety task. Exposing safety variables to external systems violates IEC 62443 security requirements.
Management of Change (MoC) Procedure
For safety-critical systems, follow a formal Management of Change process:
- Request: Document the proposed change, including justification and scope.
- Risk Assessment: Evaluate the impact on safety functions. Identify any new hazards introduced by the change.
- Review: Have the change reviewed by a safety engineer and the machine builder’s quality team.
- Approval: Obtain sign-off from all relevant stakeholders (safety, engineering, production management).
- Implementation: Apply the change using a controlled procedure:
- Create a CF card backup before the change.
- Test in simulation first (ARsim).
- Apply the change during a planned downtime window.
- Verify all safety functions after the change.
- Verification: Test all affected safety functions (E-stop, light curtains, guard interlocks, etc.) to confirm they operate correctly.
- Documentation: Update all safety documentation, including:
- Safety requirements specification
- Safety validation report
- Operating manual
- Maintenance procedures
- Release: Only after successful verification, return the machine to production.
Best Practices for Safety-Related Online Work
- Never make online changes to safety programs while the machine is running. Always stop the machine, apply lockout/tagout, and work in a controlled environment.
- Use Safety+ for safety development where possible. It provides an open code base with digital fingerprinting that protects safety-critical code while enabling collaborative development.
- Separate safety and standard logic. Keep safety functions in dedicated SafeLOGIC programs, not mixed with standard machine control logic.
- Maintain a safety change log. Every modification to safety-related code must be recorded with date, description, who performed it, and verification results.
- Keep safety backups separate. Store CF card images of safety-related configurations with restricted access and formal version control.
Safety+ Considerations
B&R’s Safety+ framework introduces modern safety development practices:
- Open code base: Safety functions can be developed with third-party tools, enabling better collaboration and flexibility.
- Digital fingerprint: Protects the integrity of safety-critical code, ensuring unauthorized modifications are detected.
- Headless architecture: Supports CLI interaction for automated safety validation.
- Automatic safety configuration updates: Reduces maintenance effort and ensures consistency across machine variants.
12. Using mapp View for Runtime Parameter Changes
mapp View Runtime Changes Overview
mapp View is B&R’s HMI framework built on web technology (HTML5, CSS, JavaScript). It communicates with the PLC through OPC UA and provides a powerful, modern interface for operators to modify runtime parameters.
Setting Up mapp View for Parameter Changes
Step 1: Add mapp View to the Project
- In Automation Studio’s Logical View, right-click the controller.
- Select Add > mapp Component > mapp View.
- Configure the mapp View settings (web server port, default page, etc.).
Step 2: Create an OPC UA Variable Mapping
- In the Logical View, expand the OpcUa node under the controller.
- An OPC UA default view file is automatically added.
- Mark variables as OPC UA tags by checking the OPC UA accessible property in the variable’s properties dialog.
Step 3: Design the HMI Page
- Open the mapp View page editor.
- Create a new page or open an existing one.
- Add widgets from the widget palette for each parameter you want to expose:
+------------------------------------------+
| Temperature Control |
| |
| Setpoint: [ 85.5 ] °C |
| ^^^^^^^^ |
| NumericInput widget |
| bound to gTemp.rSetpoint |
| |
| Actual: 82.3 °C |
| Status: HEATING |
| |
| [Apply] [Reset to Default] |
+------------------------------------------+
Step 4: Bind Widgets to PLC Variables
For each widget:
- Select the widget.
- In the Properties panel, set the Content property to the PLC variable path
(e.g.,
MainTask.gMachine.rSpeedSetpoint). - Configure constraints:
- Minimum/Maximum: Prevent out-of-range entries.
- Step size: Define increment granularity for the widget.
- Unit: Display engineering units.
- Decimal places: Set display precision.
mapp Recipe for Parameter Groups
For managing groups of parameters that change together (e.g., product changeovers), use the mapp Recipe framework:
- Add the mapp Recipe component to your project.
- Define recipe structures in your PLC code:
TYPE ST_Recipe :
STRUCT
rTemperature : REAL;
rSpeed : REAL;
rPressure : REAL;
iDwellTime : TIME;
bEnableOption : BOOL;
END_STRUCT
END_TYPE
- Link recipe variables to mapp Recipe component.
- In mapp View, add recipe management widgets:
- RecipeSelector: Choose a recipe by name.
- RecipeEditor: Edit individual parameters within a recipe.
- RecipeSave/Load: Store or recall recipe data.
Changing Setpoints Through mapp View (Complete Example)
PLC Side:
PROGRAM Main
VAR
rTemperatureSetpoint : REAL := 25.0;
rTemperatureActual : REAL;
bHeaterEnabled : BOOL;
(* mapp View widget status *)
bSetpointChanged : BOOL;
bApplySetpoint : BOOL;
END_VAR
(* Apply new setpoint when operator confirms *)
IF bApplySetpoint THEN
IF rTemperatureSetpoint >= 0.0 AND rTemperatureSetpoint <= 200.0 THEN
(* Valid range — accept the change *)
bSetpointChanged := TRUE;
bApplySetpoint := FALSE;
ELSE
(* Invalid — reject and notify *)
bSetpointChanged := FALSE;
bApplySetpoint := FALSE;
END_IF
END_IF
(* Temperature control logic *)
IF rTemperatureActual < rTemperatureSetpoint THEN
bHeaterEnabled := TRUE;
ELSE
bHeaterEnabled := FALSE;
END_IF
mapp View Side (Widget Configuration):
| Widget | Property | Value |
|---|---|---|
| NumericInput (Setpoint) | Content | MainTask.rTemperatureSetpoint |
| NumericInput (Setpoint) | Minimum | 0.0 |
| NumericInput (Setpoint) | Maximum | 200.0 |
| NumericInput (Setpoint) | Decimal Places | 1 |
| Button (Apply) | Content | MainTask.bApplySetpoint |
| TextDisplay (Status) | Content | MainTask.bSetpointChanged |
| Rectangle (Heater) | Fill Color | MainTask.bHeaterEnabled (TRUE = red, FALSE = gray) |
Dynamic Page Content
mapp View supports dynamic page changes at runtime:
- Use NavigationButton widgets to switch between pages.
- Pages can be selected programmatically through a PLC variable bound to the navigation widget’s content.
- This enables context-sensitive displays (e.g., showing different parameter pages based on the selected machine mode or recipe).
Advanced: Runtime Image Positioning
While mapp View is designed for static widget layouts, dynamic visual changes can be achieved through:
- Visibility toggling: Show/hide widgets based on PLC variables.
- Color changes: Bind fill/stroke colors to status variables.
- Value formatting: Display different text based on ranges.
- Page switching: Load completely different pages for different operating modes.
For truly dynamic positioning (e.g., moving an image based on a variable), additional JavaScript can be used in the page’s client-side scripts, though this is an advanced technique that goes beyond standard mapp View practice.
Performance Tips
- Limit widget count per page: Each widget adds OPC UA subscription overhead. Keep pages under ~100 active widgets for optimal performance.
- Use polling vs. subscription: For slowly changing parameters, use a longer sampling interval to reduce controller CPU load.
- Optimize update rates: Set the refresh rate of each widget appropriately. Status indicators need 100-500 ms, while trend displays can use 1-5 seconds.
- Test with real data: Use ARsim to test the HMI with realistic data volumes before deploying to the target hardware.
Appendix A: Quick Reference Card
Online Change Decision Matrix
| What do you want to change? | Method | Restart Required? | Risk Level |
|---|---|---|---|
| A constant value | Online download | No | Low |
| Logic inside an existing FB | Online download | No (if non-structural) | Medium |
| A variable value temporarily | Watch Window write | No | Low |
| A variable value permanently | Watch Window + Transfer | No | Low |
| A setpoint from HMI | mapp View widget binding | No | Low |
| An I/O module configuration | mappIO / AsIO | No (if supported) | Medium |
| A variable data type | Online download | Warm restart | Medium |
| A task cycle time | Online download | Warm restart | Medium |
| A library version | Rebuild + download | Warm restart | High |
| The hardware tree | Rebuild + download | Warm restart | High |
| The AR firmware | Install AR | Cold restart | High |
| Safety program logic | N/A — not allowed online | Full stop + recertification | Critical |
Key B&R Libraries for Runtime Operations
| Library | Purpose |
|---|---|
AsIO | I/O configuration, forcing, hardware management |
AsARCfg | Runtime configuration (IP, hostname, etc.) |
AsSem | Semaphore-based synchronization for shared variables |
IECCheck | Runtime error detection (pointer errors, division by zero, etc.) |
mappIO | High-level I/O management and hot-connect |
mapp Recipe | Recipe management for parameter groups |
mapp User | Operator access level management |
mapp View | HMI framework for runtime parameter display and modification |
Key Automation Studio Shortcuts
| Shortcut | Function |
|---|---|
F7 | Build/Compile |
Ctrl+F7 | Rebuild All |
F12 | Go to Definition |
Shift+F12 | Show References |
F9 | Generate CF/SD Card |
Ctrl+D | Transfer to Target |
Appendix B: References and Sources
- B&R Community Forum: https://community.br-automation.com
- B&R Coding Guidelines (TM231TRE.001): B&R Download Portal
- B&R Automation Studio Online Help (built into AS)
- B&R Safety Technology: https://www.br-automation.com/en-us/technologies/safety-technology/
- B&R mapp View Documentation: https://www.br-automation.com/en-us/products/software/mapp-technology/mapp-view/
- PVI.py Python Wrapper: https://github.com/hilch/Pvi.py
- Awesome B&R Frameworks: https://github.com/hilch/awesome-B-R
- mapp Recipe Tutorial: Available on B&R GitHub training repository
- DMC B&R Communication Reference: DMC Blog
Key Findings
-
Online download to a running B&R controller requires AR >= G4.33 for transfer configuration options. Automation Studio indicates whether a change needs a warm restart (red exclamation mark) or can be applied fully online. Always perform Rebuild All (Ctrl+F7, not just Build/F7) before downloading to a running system, especially when library changes are involved.
-
The primary risk of online code changes is page faults from shifted memory addresses. Pointer-based code, global variables shared across tasks with different cycle times, and string buffer operations are the highest-risk areas. Use the
IECChecklibrary for runtime bounds checking andAsSemfor semaphore-protected access to shared variables. -
Variable forcing is available through three mechanisms: Automation Studio Watch Window (right-click variable, set Force On/Off), the
AsIOlibrary (AsIOEnableForcing/AsIODisableForcingfunction blocks for programmatic control), and PVI external writes using theF+syntax. PVI can write force values but cannot enable/disable forcing itself. -
Runtime parameter changes (setpoints, timers, configuration) are safest when done via PLC logic (deterministic, traceable, version-controlled),
AsARCfglibrary (for IP/hostname/subnet changes), mapp Recipe (for parameter groups), or mapp View HMI with access level controls (mapp Userservice). Watch Window changes are temporary and revert after restart unless persisted. -
Hot-connecting IO hardware at runtime is supported by B&R via the
mappIOlibrary and theAsIOlibrary’s hot-connect function blocks. The IO processor automatically detects newly inserted/removed modules. This requires AR >= G4.0 and proper module initialization in the hardware tree configuration. -
Safety program logic cannot be changed online – any safety modification requires a full machine stop, safety program re-download, and recertification. The SafeLOGIC safety controller’s forcing mechanisms are separate from standard IO forcing and require SafeDESIGNER software plus password.
-
OPC UA (port 4840) is the recommended communication method for new projects for external variable access, with certificate-based security and up to 50 sessions at 100 ms publishing interval. PVI (port 11160, ANSL protocol) remains necessary for B&R HMI panels and legacy systems. PVI does not auto-reconnect – implement retry logic for error code 11020.
-
Rollback procedure: (a) stop all forced variables with Force All Off, (b) download the last known-good version via Transfer to Target, (c) if a warm restart occurs, verify all tasks have re-entered RUN state, (d) if problems persist, perform a cold restart (power cycle) to restore from the CF card image. The CF card image is updated only when explicitly transferred with
Application > Generate CF/SD Card(F9).
Cross-References
| Related File | Relevance |
|---|---|
| execution-model.md | Task class scheduling, cycle times, and watchdog behavior affected by online changes |
| cf-card-boot.md | CF card persistence — how programs are saved to CF for persistence across power cycles |
| config-file-formats.md | Configuration files that control program loading and runtime parameters |
| pvi-api.md | PVI API for external variable writes and forcing from Python/C applications |
| opcua.md | OPC-UA variable subscriptions and writes for runtime parameter modification |
| safe-io-diagnostics.md | Safety system constraints — what cannot be changed online in safety programs |
| memory-map.md | IO memory mapping relevant to understanding force/override targets |
| firmware.md | AR version requirements for online change support (G4.33+) |
| diagnostics-sdm.md | Monitoring system health after online changes via SDM |
| hmi-integration.md | mapp View HMI parameter access levels and runtime modification workflows |
| retentive-data.md | How retentive variables are affected by warm restarts during online changes |
| access-recovery.md | Access level requirements for making online changes to a running system |
Document compiled from B&R official documentation, B&R Community Forum discussions, Automation Studio online help, and field engineering best practices. Always consult the official B&R documentation for your specific Automation Runtime version and controller model.