brands · South Africa
EcoStruxure Control Expert: Structure, DFBs and Data Tests
Understand EcoStruxure Control Expert project structure, tasks, data types and DFB instances with worked tests for running mean, variance and reset logic.

EcoStruxure Control Expert is the Schneider Electric engineering environment to investigate when a Modicon learning or maintenance task calls for it. Start with the exact controller, project version and required activity. Understanding how configuration, data definitions, program organisation and block instances relate is more useful than memorising a generic screenshot of a project tree.
This guide connects that structure to a worked statistical exercise: collecting accepted measurements while calculating their mean and variance. The example exposes execution order, persistent state, validation and independent instances. It is a fictional learning model, not a Schneider library block or a native project tested on an M340 or M580.
Vendor references were checked on 13 September 2026. We operate PLC Simulation Software and may benefit from its product links. Those resources support general programming practice; they do not establish native Control Expert file compatibility, vendor certification or access to Schneider engineering licences.
Begin with a project inventory
Record the engineering release and updates, controller reference, firmware, required libraries and any device integration packages. Note whether the task is creating a new training project, reading an existing application or moving a project between software versions. These activities can require different files and different evidence of success.
Schneider's communication block-library reference identifies Unity Pro as the former name used for version 13.1 and earlier. Avoid treating “Control Expert V15 or later” as the definition of the name change. For an actual transfer between releases, use the Unity Pro migration guide and the applicable compatibility information.
Make a small map of the project before editing. Identify hardware configuration, application data, reusable block types, executable logic and observation tools. A data definition does not execute a calculation merely because it appears in the same project. A block type also needs an appropriate use and instance where the design requires stored state.
In a training session, ask the learner to trace one value from its declared source to a calculation and then to an observed result. That trace shows whether they understand the project boundaries. A long list of menu names can be memorised without understanding which part owns the value or when it changes.
Tasks and sections determine when logic runs
The current Program Languages and Structure reference, revision 27 describes sections and program units associated with tasks, with execution order represented in the structural project browser. Its simulator discussion also distinguishes software debugging from real I/O and deterministic hardware timing. Use the matching manual to check the structure supported by your selected controller.
Schneider's task configuration FAQ points to task properties in the Project Browser for the execution arrangement and period. Treat task selection as a requirement decision. A requested task period is not the measured duration of every piece of code, and changing it does not automatically fix a slow or incorrectly ordered program.
For a first exercise, specify one logical update opportunity and state which calculation runs at that opportunity. If two sections both update the same accumulator, the result may be counted twice. If one section reads an intermediate value before another updates it, it may use an earlier result. These are design questions that must be resolved before comparing numerical outputs.
Give sections names that explain their responsibilities, such as input validation, accepted-sample calculation and result presentation. The exact organisation should fit the project, but the responsibilities should remain clear enough for a reviewer to find where a rejected value is stopped and where stored statistics change.

Distinguish a data structure from a function block
A data structure groups related information. In the worked example, the state record contains an accepted-sample count, mean and accumulated squared-deviation term. Those fields belong together because a correct update must preserve their relationship. They are not three unrelated global numbers that any section should modify without coordination.
A function block adds behaviour and instance state. The Schneider block-library description distinguishes stateful elementary function blocks from user-created derived function blocks. A reusable calculation must still be connected and called deliberately. The existence of a type does not establish that every channel has independent stored data.
When defining an interface, state which values are inputs, which results are outputs and which fields remain internal. Check the native rules for the chosen types and release. Schneider's V16 DFB pin-assignment FAQ documents specific mandatory assignments and unsupported generic types; it is a reason to verify the actual interface rather than assuming every type available in an editor is valid for every pin.
Our function versus function block reference develops the broader concept. The important assessment question is whether repeated calls use the intended state. Two independent measurements should not share one sample count merely because both use the same block definition.
Worked example: running mean and variance
Define a fictional collector that accepts one measurement per deliberate update opportunity. A measurement is a finite number from minus 50 through 150 inclusive. A Boolean quality input must be true. A Boolean reset input controls clearing the collector. These are educational limits chosen for this exercise, not a Modicon analogue input specification.
The stored state starts with count zero, mean zero and M2 zero. M2 is the running sum used to calculate squared deviations about the evolving mean. A count of zero means there is no accepted measurement; it does not mean the measured average is zero. Presentation must preserve that distinction.
For an accepted measurement x, use the following order:
- Set the new count to the old count plus one.
- Calculate delta as x minus the old mean.
- Calculate the new mean as the old mean plus delta divided by the new count.
- Calculate delta2 as x minus the new mean.
- Calculate new M2 as old M2 plus delta multiplied by delta2.
- Publish the new count, mean and M2 together as the next state of this fictional model.
The word “together” describes the model's state transition. It is not a claim that a particular PLC structure assignment, cross-task access or communication transfer is automatically atomic. A native implementation needs an appropriate ownership and observation design.
Population variance is M2 divided by count when at least one value has been accepted. Sample variance is M2 divided by count minus one when at least two values have been accepted. Write the denominator explicitly as the full quantity count minus one. Parentheses matter when translating the formula into code.
This exercise calculates both quantities to expose the difference. It does not choose which statistical interpretation is appropriate for a real measurement programme. The assumptions behind data collection, representativeness and measurement quality remain separate from correct arithmetic.

Trace four measurements without skipping intermediate state
Use the accepted sequence 2, 4, 4, 6. The first value produces count one, mean two and M2 zero. Population variance is zero for that one accepted value. Sample variance is unavailable because its denominator would be zero.
For the second value, delta is 4 minus 2, or two. New mean is 2 plus 2 divided by 2, which equals three. Delta2 is 4 minus 3, or one. M2 becomes zero plus 2 × 1, which equals two.
For the third value, delta is one. New mean is three plus one third, or ten thirds. Delta2 is two thirds. M2 becomes two plus two thirds, or eight thirds. For the fourth value, the new mean becomes four and M2 becomes eight.
| Accepted values | Count | Mean | M2 | Population variance | Sample variance |
|---|---|---|---|---|---|
| 2 | 1 | 2 | 0 | 0 | Unavailable |
| 2, 4 | 2 | 3 | 2 | 1 | 2 |
| 2, 4, 4 | 3 | 10/3 | 8/3 | 8/9 | 4/3 |
| 2, 4, 4, 6 | 4 | 4 | 8 | 2 | 8/3 |
Check the final result independently from the stored sequence. The mean is four. Squared deviations are four, zero, zero and four, which sum to eight. Dividing by four gives population variance two. Dividing by three gives sample variance eight thirds.
An implementation that uses delta twice instead of recalculating delta2 after the mean update gets a different M2. With just the first two values, it would accumulate four rather than two. A two-sample test therefore exposes the mistake before a large data set makes the error harder to inspect.
Define reset, invalid data and capacity
The reset input must first be a valid Boolean. When reset is true, clear count, mean and M2 and return Reset status. The unused measurement and quality fields do not prevent this reset. When reset is false, a malformed measurement or quality other than true returns Invalid input and preserves the existing statistical state.
This policy excludes invalid observations rather than converting them to zero. Suppose the collector accepts 2 and 4, rejects a bad-quality 100 and then accepts 4 and 6. It still has four accepted samples with mean four and M2 eight. Counting the rejected 100 or replacing it with zero would calculate a different data set.
The latest status and stored statistics therefore describe different things. Invalid input means the latest opportunity did not contribute. The saved mean may still describe earlier accepted observations. Label it with its accepted count instead of presenting it as a valid measurement from the current opportunity.
Set a fictional capacity of 1,000 accepted samples. At capacity, a further otherwise-valid measurement returns Full and preserves all state. The model does not roll over, discard the oldest sample or automatically reset. Those would be different collectors with different statistical meaning.
Check validation before the capacity response when reset is false. An invalid measurement at capacity remains Invalid input. A valid measurement at capacity is Full. Reset still clears the collector. This precedence makes the model deterministic when more than one condition could apply.

Verify state ownership and repeated execution
Create two collectors with separate state. Collector A receives 2 and 4, giving mean three and M2 two. Collector B receives 10 and 14, giving mean twelve and M2 eight. Interleave the updates and confirm that the results remain the same. This tests instance independence more effectively than feeding both collectors identical values.
Then deliberately call A twice with the same accepted measurement at one intended update opportunity. The collector counts two samples because its contract accepts one sample per call. It has no built-in knowledge that a caller repeated an observation. If duplicate detection is required, add an observation identifier or another explicit acceptance rule and test it separately.
This matters when arranging sections. A statistical block called from two paths can produce plausible values while its count advances faster than intended. Observe both the mean and the count. A constant input may keep the mean unchanged even while duplicate calls silently double the number of accepted observations.
Test reset on one collector while preserving the other. A reset must not clear a shared global record by accident. After resetting A, its count is zero and its statistics are unavailable for presentation. B should retain its previous count and results.
The PLC data type guide helps connect numeric representation to these observations. Use appropriate floating-point types for the fractional calculations, and document the comparison tolerance used by the test harness. Exact equality is suitable for some simple results, while repeating fractions require a deliberate tolerance.
Numerical checks beyond the example table
Test constant sequences, including five zeros and five values of 150. Their means should match the constant value and M2 should be zero within the declared numerical tolerance. A zero mean with five accepted zeros is a valid result; a zero count is still an empty collector.
Test the range endpoints with minus 50 and 150. The mean is 50, M2 is 20,000, population variance is 10,000 and sample variance is 20,000. This exposes an implementation that accepts only non-negative measurements or confuses the input range with the possible range of variance.
Test a fractional sequence such as 0.1, 0.2 and 0.3. The mean is 0.2 and the sum of squared deviations is 0.02 mathematically. A reference calculation should compare with a tolerance because the binary floating-point representation does not store every decimal fraction exactly.
For a larger deterministic check, compare the running calculation with a separate two-pass calculation: first find the mean of the saved accepted values, then sum their squared deviations. The local reference tests compare these methods across many small integer sequences and the stated boundary cases. They verify the fictional algorithm, not native controller arithmetic or timing.
Do not add a blanket clamp that hides substantial negative variance or other unexpected results. Investigate the input, update order and numeric representation. If a native design uses a specific treatment for tiny numerical errors, document its threshold and test its limits rather than silently rewriting every abnormal result.

Importing reusable types needs a comparison step
When bringing a block into a project, compare its dependencies as well as its visible name. Schneider's DDT mismatch FAQ explains that device integration changes and hidden fields can make apparently similar structures differ. It proposes comparing exported definitions when investigating that issue. A matching label does not establish matching structure.
The Import Trouble Report guidance distinguishes keeping, replacing and renaming duplicate objects for the documented software versions. These actions have different consequences. Read the report and record the intended decision instead of clicking through until the import completes.
For the fictional collector, changing count from one representation to another, renaming M2 or changing the interface's quality type affects the contract. A successful import does not prove existing callers still provide the right information. Re-run the independent-instance, invalid-input and reset cases after a relevant change.
Keep a clean example project and an explicit dependency list for training. That makes it possible to distinguish a logic defect from an unavailable library or conflicting type. When a build fails, preserve the actual diagnostic text; do not replace it in the portfolio with an invented generic migration log.
What to assess in a Control Expert course
A useful course should let learners explain the project structure, create or inspect suitable data definitions, locate the executable logic and observe a result with its relevant state. Ask whether the practical assessment includes finding an incorrect call order or shared instance, not just reproducing the instructor's final project.
For South African course buyers, obtain the controller model, software release, practical arrangement and prerequisite knowledge in writing. The Schneider training hub connects the brand-specific learning topics, while the PLC course price comparison guide helps compare what a quotation includes.
If you need practice with general structured calculations, review the product's Structured Text learning material and PLC program testing resources. Check the current lesson scope before purchasing. Native Control Expert training requires its own supported environment and access arrangements.
Training managers can use the training-centre assessment guide to define observable outcomes. For this exercise, the evidence should include the state definition, expected trace, test results and an explanation of why a rejected input did not change the accepted data set.
EcoStruxure Control Expert questions
Are a DDT and a DFB interchangeable?
No. A data definition describes grouped information, while a function block provides behaviour with an interface and potentially persistent instance state. Decide how the application owns and updates the information, then verify the native type and parameter rules for the selected release.
Does changing a task period fix a wrong result?
Not necessarily. A duplicate call, incorrect update order or shared accumulator can remain wrong at any period. Trace the inputs and stored state first. Task configuration and measured timing are separate parts of the investigation.
Why does the variance calculation need the new mean?
The specified update uses delta from the old mean and delta2 from the new mean. Reusing the first delta changes the accumulated squared-deviation term. The sequence 2 followed by 4 exposes that defect with a small hand calculation.
What happens when the collector rejects a measurement?
The accepted count, mean and M2 remain unchanged, while the latest status reports Invalid input. The stored result describes the earlier accepted samples. It should not be labelled as a valid current measurement from the rejected update.
Can these results prove a native M580 project works?
They establish expected behaviour for a fictional reference model. A native implementation still needs its own build, execution, type, instance and timing evidence. Keep those results separate so a reviewer knows exactly what has been demonstrated.
