Back to all posts
Control Systems7 min read·October 25, 2026

How Do You Prevent Duplicate MES Commands to a PLC?

TB
ThynkBlox Automation Team
Automation Engineering

Prevent duplicate MES commands to a PLC by giving each requested action a unique identity and making the PLC return the recorded state when that identity arrives again. Define separate acknowledgements for acceptance and completion, with responses tied to the command ID. After a timeout or reconnection, check the original command's state before deciding whether to resend it or request another action.

Why is a command bit and an acknowledgement bit not enough?

Consider this illustrative failure: the MES sends a request to dispense material, the PLC accepts it, and communication stops before the MES receives the acknowledgement.

From the MES view, two explanations remain possible: the request never arrived, or it arrived and the reply was lost. Sending a fresh dispense request assumes the first explanation without resolving the second.

A handshake built only around setting and clearing bits leaves those explanations unresolved unless it includes an identity and recovery rules. Specify what the acknowledgement means, which request it belongs to, and how that association survives a communication break.

Treat the command as a record with a lifecycle. A request bit can signal that a record is ready; it should not be the only record of the requested action.

What should identify each MES command?

Use a command identity that stays unchanged throughout retries. A practical design is a sender identity, a retained generation identifier and an increasing sequence ID.

Define the following fields in the interface contract:

FieldPurpose
Sender and generationDistinguish command streams, including after a reset
Sequence IDIdentify one request within that stream
Target and command typeIdentify the equipment and requested action
ParametersDescribe the action, including units and limits
Response command IDConnect every response to its request
State and resultReport progress, rejection or outcome

Do not reuse an identity for a different action. If a repeated ID arrives with changed parameters, require a conflict response and prevent execution.

Define sequence rollover before commissioning. Likewise, decide how a restarted MES obtains its next identity without reusing an earlier one.

For a simple interface, allow only one outstanding command per target. If concurrent requests are necessary, specify queue capacity, ordering and the response when the queue is full.

Which acknowledgement states should the handshake use?

Give each state one explicit meaning. The following is a proposed contract, not a claim about a particular controller or protocol.

StateMeaning in the agreed contractMES response
AcceptedThe request has been validated and recorded for processingTrack the same ID
ExecutingThe recorded action has startedWait or investigate
CompletedThe defined completion condition has been metRecord the result
RejectedThe request was refused before executionResolve the reason
FailedExecution ended without the required outcome; partial action may have occurredReconcile before another request
UnknownAvailable records cannot establish the outcomeHold dependent actions

Acceptance must not mean merely that a value appeared in a communication register. Require validation of the target, command, parameters and readiness conditions before acceptance.

Completion needs an observable condition: for example, a specified position reached or an agreed process step confirmed. Define that condition for each command type.

Return the command ID with every state. An unlabelled “done” flag gives the MES no reliable way to distinguish the current request from a previous one.

How should the PLC handle a repeated sequence ID?

Before starting an action, check the received identity against the active command and retained results.

For a recognised identity with matching parameters, return its recorded state. Do not start the action again. For a recognised identity with different parameters, return a conflict.

For an unfamiliar identity, validate whether it belongs to the permitted command stream. Do not treat every unfamiliar ID as new: an old request may arrive after its detailed result has been removed.

Specify a retained sequence boundary or equivalent rejection rule for stale requests. Define how long results remain available, how the MES confirms receipt, and what happens when record capacity is exhausted.

If the interface transfers fields separately, include a publication step so the PLC validates a complete, consistent request. It must not accept a mixture of old parameters and a new ID.

What should happen when a command times out?

Use separate timeouts for waiting for acceptance and waiting for completion. Set them from the agreed communication and process behaviour; avoid one blanket value for every action.

A timeout should trigger a status check, not a new command identity.

  • Acceptance timeout: ask whether the original ID was recorded. If retrying is permitted, resend the unchanged request with the same ID.
  • Completion timeout: inspect the same command and the equipment condition. Do not turn a slow action into a second action.
  • Cancellation timeout: check whether cancellation took effect. Sending a cancellation request is not confirmation that execution stopped.

Define retry limits, escalation and the information shown to the operator. Describe an unresolved result plainly, such as “Command outcome unconfirmed; check equipment before continuing.”

Keep that condition visible until it is resolved. Our guide to why operators ignore alarms discusses the importance of clear, actionable alarm handling.

How should MES and PLC reconcile after reconnection?

Pause new commands for the affected target while the systems compare records.

The MES should present its outstanding command identity. The PLC should return its recorded identity, state and result, together with any restart or record-loss indication required by the contract.

Then apply explicit recovery rules:

  1. Same command completed: record the existing result and continue.
  2. Same command accepted or executing: resume monitoring it.
  3. Command rejected: resolve the rejection before issuing another request.
  4. Command failed: establish whether any partial action occurred.
  5. Missing or conflicting records: hold the target for reconciliation.

A missing record is not sufficient evidence that nothing happened. In the illustrative dispense example, the material could have moved before the completion record was saved.

Specify retained storage and restart behaviour, but also define recovery for the gap between a physical action and its recorded outcome. Where the outcome cannot be established automatically, require a controlled check by an authorised person.

What does a lost acknowledgement look like in practice?

The following sequence is illustrative.

The MES sends dispense command 731. The PLC records it as accepted, starts the action and reaches the defined completion condition. The connection drops before the MES receives the completion response.

The MES reconnects and queries 731. The PLC returns Completed, tied to that identity, and the MES records the existing result.

If the MES resends 731, the PLC returns the recorded completion again. If it instead creates 732 for the same intended dispense, it has created a separate request. The duplicate protection depends on preserving the original identity.

If the PLC cannot establish what happened to 731, the correct response under this contract is Unknown, followed by reconciliation.

What common mistakes should the specification prevent?

Avoid these shortcuts:

  • Creating a new sequence ID on every retry.
  • Treating accepted as completed.
  • Clearing command history when communication drops.
  • Checking only the latest ID when older retries remain possible.
  • Reusing an ID with changed parameters.
  • Allowing a manual restart and an MES retry to request the same action independently.
  • Reporting a failed command as proof that no physical action occurred.

Do not use this handshake as a safety function. Have safety-related design and its relationship to remote commands assessed with a qualified assessor.

Record ownership, states, retention and recovery rules in the interface specification. Our guide to what a functional design specification should contain provides a starting structure.

What should commissioning prove?

Test the failure paths against observable equipment behaviour:

  • Send the same request repeatedly before and after completion.
  • Reuse an ID with changed parameters.
  • Interrupt communication before acceptance and during execution.
  • Lose the completion reply, then reconnect.
  • Restart each side at different command states.
  • Deliver a stale request after result retention expires.
  • Exercise sequence rollover and record-capacity limits.

For each test, record the requested action, actual action and returned state. Require one execution for a recognised command, an explicit rejection for conflicts, and a hold when the outcome remains uncertain.

Frequently asked questions

Should every retry keep the same sequence ID?

Yes, when it represents the same requested action. Preserve the full identity and parameters. A new ID should represent a separately authorised action.

Is an accepted acknowledgement enough to update production records?

Under this contract, acceptance confirms validation and recording only. Update records that depend on completion when the defined completion result arrives.

Can the MES retry after a PLC restart?

Only according to the agreed restart and retention rules. First establish whether the original command is recognised and whether its outcome is known.

Where should a plant start?

List commands whose repetition would cause an unwanted physical or production result. Specify their identities, states and recovery rules first, then test those rules through the complete interface.

Next step

Want to apply this to your plant?

Every project starts with a fixed-fee assessment, and you can stop after the report.