IMDHMIControls LibraryShop main store

How-to

How to migrate derived function blocks to Machine Expert

PLC programming Published 8 min read

Short answer

No tool converts Control Expert derived function blocks into Machine Expert. Migrate them as a manual code port: copy the Structured Text body, rebuild every declaration and dependency by hand, resolve the two environments' differences, and test each block; blocks written in other languages are recreated. IEC 61131-3 keeps the language portable, not the project or the libraries.

On this page
  1. What transfers and what stays behind
  2. The migration procedure
  3. Declarations you rebuild by hand
  4. Structured Text differences to resolve
  5. Blocks written in ladder or FBD
  6. Test each block before it joins the program
  7. The decision, case by case
  8. Questions asked

There is no migration tool for this direction, and no import path: nothing in Machine Expert loads a Control Expert derived function block (DFB). The migration is a manual code port, done block by block. For a block written in Structured Text, you copy the body text, rebuild every parameter and internal variable by hand, resolve the differences between the two environments, and test the block on its own before it goes near the machine program. For a block in ladder, FBD, or another language, you recreate the logic. IEC 61131-3 makes the port possible — it fixes the Structured Text language and the function block model — but it says nothing about project formats or library blocks, which is why declarations and dependencies never carry over.

What transfers and what stays behind #

No converter ships with either package, and no third-party converter is known for this direction. Control Expert can exchange DFBs between its own projects — the export and import commands sit under the "Derived FB Types" node of the project browser — but that exchange stays inside Control Expert, and Machine Expert does not load it. Control Expert, which grew out of Unity Pro, calls a user-defined block a derived function block; Machine Expert calls the same construct a function block. The names differ, and so does everything below the language.

IEC 61131-3 is the reason any of this works. It defines the Structured Text language, the function block execution model — parameters declared with a direction, each instance holding its own state between calls — and fixed integer widths, so INT is 16-bit signed and DINT 32-bit signed in every compliant package. It does not standardize project file formats, library block sets, or the engineering tool. The ST statements port as text; everything that gives them meaning is rebuilt.

What survives a copy and paste is the body, the statements themselves. What never survives it: the parameter list, the internal variables and their initial values, derived types, calls into the source library, and the instance data at each call site. That split sets the shape of the whole job, and it is not peculiar to this pair of packages — even inside one vendor's controller families there is no automated S7-300 to S7-200 STL conversion, because the language is standardized and the project around it is not.

Source block condition What you do Gate before you continue
Structured Text, readable Copy the body into a new Machine Expert function block; declare by hand Rebuilt interface matches the recorded contract
Ladder, FBD, or another language Recreate the logic in a Machine Expert language Execution order and stored state documented
Calls other blocks or derived types Port each dependency first Dependency has a tested equivalent in the target
Source not accessible Obtain authorized access or an approved specification Behavior defined tightly enough to test

The migration procedure #

Work one block at a time and finish it before starting the next.

  1. Record the contract. Open the DFB in Control Expert and write down its language, every parameter with direction (input, output, input-output), data type and initial value, every internal variable, and every referenced type or called block. This record is the test sheet for step 8.
  2. Order the work leaf-first. Port blocks that call no other DFBs before the blocks that call them, so every integration runs against already-tested code.
  3. Rebuild the interface. Create the function block in Machine Expert with the same parameter names, directions, types and initial values. Renaming a parameter gains nothing and breaks the paste in step 5.
  4. Range-check every integer declaration against what the block actually computes, not just what the source declared. The worked example below shows what a missed check costs.
  5. Copy the Structured Text body. Select the implementation in Control Expert, copy it, paste it into the target block, and keep an unchanged copy of the source open beside it for comparison. This paste is the only bulk step in the whole migration.
  6. Resolve what the compiler flags, item by item. The flags fall into three groups: names with no declaration yet, library operations that do not exist in the target under that name, and conversions the target refuses to do implicitly. Replace a missing operation with a documented target equivalent, not with the first call that compiles.
  7. Build the block alone until it compiles clean. Fix declaration errors before type errors, and type errors before anything that looks like algorithm trouble.
  8. Run the per-block comparison test described below, before the block is instantiated anywhere.
  9. Instantiate and reproduce the call context. Same number of instances, same task, same conditional execution as the source. Two devices that each need their own count get two instances; a block called conditionally keeps that condition.

Declarations you rebuild by hand #

The interface is part of the block's behavior. Turn an input-output parameter into an output and the caller's variable stops being written. Narrow a type and the block still compiles. Get an internal variable's persistence wrong and a counter either restarts every call or carries a stale value. Because IEC 61131-3 fixes the widths, a range decision made once is portable — INT holds −32,768 to 32,767 and DINT to 2,147,483,647 — it just has to be made against what the block computes.

Worked example, illustrative numbers. A totals DFB accumulates parts on a line running 1,200 parts per hour. The source declares the accumulator as DINT; during the rebuild you declare it INT. The INT ceiling is 32,767 counts, and 32,767 ÷ 1,200/h = 27.3 h. The cross-checks agree: 1,200 × 27 = 32,400 counts fits, 1,200 × 28 = 33,600 counts does not. The block passes a full first day at 1,200 × 24 = 28,800 counts and wraps about three hours into the second day; a forced count of 40,000 reads back as 40,000 − 65,536 = −25,536. Declare the accumulator DINT — ceiling 2,147,483,647 counts, about 1.8 million hours at this rate — and put the 40,000-count test on the block's test sheet so the type choice is proven, not assumed.

Declaration item What must match the source Failure mode if it does not
Parameter direction Input, output, or input-output exactly Caller variable never written, or written when it should only be read
Integer type Range the block computes; INT ceiling 32,767, DINT ceiling 2,147,483,647 Count wraps negative past the limit
Internal state Variables that persist between calls, with initial values Counter restarts each call or holds a stale value
Arrays and structures Element types, bounds, member list Index outside the intended range, assignment rejected

Structured Text differences to resolve #

Structured Text is close enough between the two packages for a paste, and the differences sit at the edges. Library operations named in the body may not exist in Machine Expert, or may exist with different behavior; check each one against the target documentation and replace it with a documented equivalent. Conversions that Control Expert accepted implicitly may need an explicit conversion in the target — write the intended conversion and test values near the relevant limit.

Timers, counters, and edge-sensitive operations keep state inside themselves, and their results depend on being executed every scan or only in some scans. Reproduce the source's call conditions exactly, and test first-scan behavior on every block.

The discipline is the same one you apply when you port a PLC-5 filter routine to ControlLogix structured text: the algorithm travels as text, and everything around it is rebuilt and retested. At the language level this is the general problem of porting IEC 61131-3 Structured Text libraries across PLC platforms — syntax moves, type systems and libraries do not.

Blocks written in ladder or FBD #

Copy and paste is not a supported transfer for the graphical languages between these packages, so a ladder or FBD block is recreated. Before recreating it, write down the execution order: the sequence of assignments, which branches are mutually exclusive and which are evaluated independently, every variable written more than once in a call, and every subordinate instance called from only some branches.

The last two items are where recreations go wrong. If an early assignment feeds a later statement in the same call, rebuilding them in the opposite order changes the result while every visible condition looks identical. An instance called only inside one branch also holds its last state while that branch is false, so the recreated structure has to match or the state behavior diverges quietly.

Rebuild the sequence in whichever Machine Expert language holds it most readably — usually Structured Text — then exercise each path with controlled inputs and compare outputs and internal state against the source.

Test each block before it joins the program #

A clean build proves the target accepts the text, nothing more. Run the source block and the rebuilt block side by side, source project online and target in simulation or a test task, force identical inputs, and compare the declared internals as well as the outputs. Cover three cases on every block: first scan, limit values such as the 40,000-count test, and both edges of every Boolean input. Until the whole block set has passed, keep the machine unable to act on the comparison — outputs disabled, or the controller in a mode that cannot start motion.

For scheduling, use this illustrative planning number: one hour per mid-size Structured Text block, roughly 100 lines with a dozen declarations, covering rebuild, resolution and the comparison test. Forty such blocks is 40 × 1 h = 40 h, one working week of engineering time. Dependencies count as blocks of their own, library differences add resolution time, and every non-ST block adds recreation time on top of that budget.

The decision, case by case #

  • Structured Text with readable source: copy the body, rebuild the declarations, run the per-block test. That is the whole method, and there is no faster one.
  • Ladder or FBD: recreate from the documented sequence. A small block with no written behavior description is usually faster rebuilt from its functional requirement than reverse-engineered rung by rung.
  • No source access: obtain authorized access to the project, or rebuild from an approved specification. A block that participates in a safety function is rebuilt from its validated specification, never from watching what the machine appears to do.
  • Controller family being replaced outright: the block port is only the code layer. Hardware selection, I/O and commissioning are a separate effort, the same split you face when migrating a MicroLogix 1500 machine to a current PLC.

Questions asked

Can Machine Expert import the DFB export file from Control Expert?

No. That export, made from the Derived FB Types node of the project browser, exchanges blocks between Control Expert projects only, and Machine Expert does not load it. The block is rebuilt by hand: create the function block, declare the parameters and internal variables, then paste the Structured Text body. Nothing in the export file shortcuts the declaration work.

How long should I budget for the port?

Start from one hour per mid-size Structured Text block, covering the declaration rebuild, the difference resolution and the comparison test. Forty such blocks is 40 hours, about one working week. After the first five blocks, replace that assumption with your own measured rate; ladder and FBD blocks run longer because they are recreated, not copied.

Why does the pasted Structured Text fail to compile?

Because the paste carries only the body. Every name in those statements, including parameters, internal variables, types and library calls, must exist as a declaration in the target block first. Missing declarations, library operations absent from the target, and stricter implicit conversion rules are the three usual causes. Also confirm the entire body was selected in the source; a partial selection pastes cleanly and fails later.

Do I test every block or only the integrated program?

Every block, before it is instantiated. A clean build proves the target accepts the text, not that the block behaves identically, and the mistakes this migration makes, such as a flipped parameter direction, a narrowed type or lost internal state, still execute. A defect found after integration forces a retest of everything downstream of it.

What is the route for a DFB written in ladder or FBD?

Recreate the logic in the target. First document the assignment order, the branch structure, repeated writes and stored state, keeping an exported or printed copy of the source logic as reference. Rebuild the sequence in a Machine Expert language, then exercise each path against the source behavior.

Keep reading

  • How-to

    Port a PLC-5 filter routine to ControlLogix structured text

    The filter is a first-order lag whose only state is the previous filtered value. Give every filtered signal its own instance of one filter UDT that also holds the exponent and coefficient, translate the rungs to ordered assignments in a periodic task, and preload the state on the first pass. Prove the port with a step: 63.2% of the change after one time constant, about 95% after three.

    PLC programming

  • Selection guide

    Migrating a MicroLogix 1500 machine to a current PLC

    Quote CompactLogix as the baseline for the rebuild: Rockwell's migration reference gives the MicroLogix 1500 two documented destinations, MicroLogix 1400 or CompactLogix 5370 (L1/L2), and a low-volume machine rebuild does not justify the Micro850 route. Take the Micro850 only for high build volume, after the 11 uncovered inputs, serial Modbus, the drive interface and a trial CCW import are verified.

    PLC programming

  • Troubleshooting

    When a CODESYS TON works in structured text but not ladder

    The structured text routine counts because its four statements run in sequence inside one scan; the ladder version fails when the reset network clears Timer.Q before the addition samples it, or an unconditional reset restarts the timer every cycle. Put the call, the Q test, the addition and the reset of the same TON instance in one ladder network, left to right in that order, and it counts exactly one B per interval.

    PLC programming