Protocol Diagnostics November 8, 2026 11 min read

Modbus Exception 07 (Negative Acknowledge): Causes, Protocol Rules & PLC Fixes (2026)

When commissioning industrial automation systems, few error codes trigger more confusion than Modbus Exception Code 07 (Negative Acknowledge / 0x07). Unlike Exception 01 (Illegal Function) where the slave simply does not understand the command, or Exception 02 (Illegal Address) where the register address is out of range, Exception 07 indicates that the slave understood the command, recognized the register address, and validated the data syntax—yet actively and deliberately refused to execute the operation.

Need to Test Modbus Exception Handling Safely?

Testing error handling and fail-safe interlocks directly on live industrial equipment can trigger hazardous machine trips. Use ModbusSimulator to emulate slave devices that generate Exception 07 on demand, validating your SCADA retry state machines and alarm annunciators in a zero-risk virtual sandbox.

1. The Formal Protocol Specification of Exception Code 07

According to the official Modbus Application Protocol Specification V1.1b3 (Section 7: Modbus Exception Responses), Exception 07 is formally defined as:

Exception Code Name Official Modbus Specification Definition
07 (0x07) Negative Acknowledge "Specialized use in conjunction with programming commands. The server (or slave) cannot perform the program function received in the query. This code is returned for an unsuccessful programming request using function codes 13 or 14 decimal. The client (or master) ought to query the server (or slave) for diagnostic or error information with respect to this request."

While originally drafted for legacy Modicon 984 and Quantum PLC programming commands (Function Code 13: Program Controller, Function Code 14: Poll Controller), modern automation vendors widely utilize Exception 07 as the universal protocol signal for prohibited state execution. When an operator, SCADA script, or edge gateway attempts to write parameters via Function Code 06 (Write Single Register) or Function Code 16 (Write Multiple Registers) while the slave device is in a state that prevents parameter alteration, Exception 07 is returned.

2. Hex Packet Breakdown: How Exception 07 Appears on the Wire

When an error occurs, the slave device sets the high-order bit of the requested function code (adding 0x80) and appends the single-byte exception code 0x07.

Modbus RTU (Serial RS-485) Packet Breakdown

Assume a master attempts to write parameter settings to Slave ID 0x01 using Function Code 0x10 (Write Multiple Registers), but the device rejects the write:

Byte Position Field Hex Value Engineering Description
Byte 0 Slave Address 0x01 Target Slave Unit ID
Byte 1 Exception Function Code 0x90 Original FC 0x10 + 0x80 (High bit set indicates exception)
Byte 2 Exception Code 0x07 Negative Acknowledge (Operation Prohibited/Failed)
Bytes 3-4 CRC16 Checksum 0x4D 0x30 Cyclic Redundancy Check validating frame integrity

Modbus TCP (Ethernet) Packet Breakdown

Over Ethernet, the same exception includes the 7-byte MBAP (Modbus Application Protocol) header:

[Transaction ID: 2B] [Protocol ID: 00 00] [Length: 00 03] [Unit ID: 01] [Error FC: 90] [Exception Code: 07]

3. The 5 Root Causes of Modbus Exception 07 in Modern Systems

Root Cause 1: PLC Hardware Key-Switch in RUN Mode

Most industrial PLCs (including Schneider Modicon, Allen-Bradley via gateways, Siemens, and Omron) feature a physical three-position front key-switch: RUN, REMOTE, and PROGRAM. When the key-switch is physically set to RUN, the processor prohibits any programmatic block writing or system configuration updates over external communication ports. Any write query directed at system control registers will be immediately rejected with Exception 07.

Root Cause 2: Unlocked Security Password / Authorization Required

Modern smart devices—such as digital protection relays (SEL, Schneider Micrologic, ABB Relion), power quality meters, and fiscal flow computers—enforce tiered security. Before an external master can alter setpoints or calibration registers, the master must first write a cryptographic security PIN or authentication token to a designated unlock register (e.g., register 40001 = 0x1A2B). If an unauthenticated master sends a write command directly, the slave returns Exception 07.

Root Cause 3: Hardware Write-Protect Jumpers or DIP-Switches

Many solar inverters, Coriolis mass flow meters, and Variable Frequency Drives (VFDs) feature a physical hardware jumper or PCB DIP-switch labeled WP (Write Protect) or CAL LOCK. When this jumper is bridged, the internal microcontroller hardware locks all non-volatile EEPROM memory blocks, preventing remote writes and returning Exception 07 upon write attempts.

Root Cause 4: Operational Safety Interlocks

In motor control and process heating applications, changing critical parameters (such as motor rated current, acceleration ramp rate, or PID proportional gain) while the machine is running poses severe safety risks. Firmware routines explicitly block writes while the motor is energized or the burner flame is detected, returning Negative Acknowledge until the machine is safely halted.

Root Cause 5: Incompatible Multi-Register Parameter Bundles

When writing configuration blocks using Function Code 16, some devices require related registers to be written simultaneously in consistent configurations (e.g. setting Primary Voltage, Secondary Voltage, and CT Ratio together). If the slave device's internal validation algorithm detects mutually conflicting parameters in the write payload, it rejects the entire transaction with Exception 07.

4. Engineering Diagnostic Flowchart for Exception 07


+-------------------------------------------------------------------+
|               Master Receives Exception Code 07                   |
+-------------------------------------------------------------------+
                                  |
                                  v
                 Is the target device a PLC / RTU?
                               /     \
                             YES      NO (Smart Sensor / VFD / Meter)
                             /         \
                            v           v
             Check physical Key-Switch   Does device have Write-Protect
             Is it in RUN mode?          jumper or parameter lock?
                 /        \                     /          \
               YES         NO                 YES           NO
               /            \                 /              \
              v              v               v                v
        Switch to REMOTE   Check Security  Remove Hardware  Check Safety
        or PROGRAM mode.   Auth Register   Lock Jumper      Interlocks / Run State
      

5. How to Handle Exception 07 in Master PLC & Python Code

Because Exception 07 represents a deliberate rejection rather than a transient electrical glitch, master controllers must handle it gracefully without crashing or flooding the network.

Python pymodbus Example: Robust Exception 07 Handling

from pymodbus.client import ModbusTcpClient
from pymodbus.exceptions import ModbusException
from pymodbus.pdu import ExceptionResponse

client = ModbusTcpClient('192.168.1.50', port=502, timeout=2.0)
client.connect()

def write_parameter_safe(unit_id, address, value):
    try:
        response = client.write_register(address=address, value=value, slave=unit_id)
        
        if isinstance(response, ExceptionResponse):
            if response.exception_code == 0x07:
                print(f"[ALARM] Slave {unit_id} returned Exception 07 (Negative Acknowledge)!")
                print(" -> Reason: Device rejected programming command.")
                print(" -> Action: Check device key-switch, unlock security registers, or verify machine is stopped.")
                # DO NOT retry immediately - alert supervisory system
                return False
            else:
                print(f"[ERROR] Modbus Exception: {response.exception_code}")
                return False
        
        print(f"[SUCCESS] Parameter written to address {address}")
        return True

    except ModbusException as e:
        print(f"[COMM ERROR] {e}")
        return False
    finally:
        client.close()

# Example test
write_parameter_safe(unit_id=1, address=1024, value=500)

6. Simulating Exception 07 in ModbusSimulator

Building resilient industrial control systems requires verifying how your SCADA graphics, alarm banners, and PLC communication blocks behave when Exception 07 is encountered. With ModbusSimulator, you can configure simulated slaves to return Exception 07 under customized test scenarios:

Frequently Asked Questions

What is Modbus Exception Code 07 (Negative Acknowledge)?

Modbus Exception Code 07 is a standard protocol response indicating that the slave device cannot perform the programming function received in the query. The device recognized the command and address, but refused execution due to operating mode restrictions or physical interlocks.

What is the difference between Exception 05 (Acknowledge) and Exception 07 (Negative Acknowledge)?

Exception 05 means the slave accepted the command and is actively executing it in the background (requiring the master to poll for completion). Exception 07 means the slave refused the command entirely; the operation was aborted and will not execute.

Why do PLCs and VFDs return Exception 07 during write operations?

The most common cause is the PLC key-switch being set to RUN instead of REMOTE/PROGRAM, physical DIP-switch write protection, an active password lock, or safety interlocks preventing parameter alteration while motors are running.

Which Modbus function codes are officially associated with Exception 07?

Historically, Exception 07 was designed for programming function codes 13 and 14. In modern industrial devices, it is returned on standard Write Multiple Registers (FC 16) or Write Single Register (FC 06) when firmware modification is prohibited in the current state.

How should a SCADA master handle Exception 07?

A SCADA master must not blindly retry the command in a tight loop. It should flag an operator alarm ('Write Inhibited: Check Device Key-switch or Security State') and suspend further writes to that target block.

How can I simulate Modbus Exception Code 07 in ModbusSimulator?

In ModbusSimulator, configure an exception rule on your target register range setting the response code to 0x07. You can configure conditional triggers to test your SCADA and PLC error handling without risking physical hardware.

Is Exception Code 07 supported in both Modbus RTU and Modbus TCP?

Yes. Exception codes reside inside the standard Modbus Protocol Data Unit (PDU) and function identically across RS-485 Modbus RTU, Modbus ASCII, and Ethernet Modbus TCP networks.

Master Modbus Simulation & Troubleshooting

Test master polling routines, simulate slave devices, and debug complex exception codes with zero hardware risk.