How-to
Build a reusable VFD function block in Sysmac Studio
Short answer
Yes: define one function block and instantiate it once per 3G3M1 inverter. IEC 61131-3 gives every instance its own data, so pump logic stays identical while each drive keeps separate state. Before reuse, verify the configured EtherCAT device matches the installed inverter, read the mapped process data, and check the Sysmac Library covers your device before writing your own block.
On this page
- Can one function block control every 3G3M1 inverter on the station?
- Should I use a Sysmac Library block or write my own?
- What has to be true in the EtherCAT configuration first?
- What belongs inside the function block?
- How do I scale the frequency reference into the drive word?
- How do I sequence run, stop and fault reset?
- How do I test the instances one at a time?
- Questions asked
You can control every 3G3M1 inverter at a station from one function block in Sysmac Studio: one definition, one instance per drive, and a verified EtherCAT process-data interface between the block and each device. IEC 61131-3 does the reuse for you, because every instance of a function block carries its own data, so your work goes into the boundaries, the scaling and the command sequence rather than into copying rungs. Take the sections below in the order you will meet them: library block or your own code, the EtherCAT checks that must pass first, what goes inside the block, the reference arithmetic, command sequencing, and a per-instance checkout. Get the Sysmac Library and its documentation from Omron or an authorized distributor only.
Can one function block control every 3G3M1 inverter on the station? #
Yes. One function block definition drives every inverter: instantiate it once per 3G3M1, and each instance keeps its own state, because IEC 61131-3 defines a function block as a typed unit whose every copy carries independent data.
That standard is the part of the PLC language standard that defines ladder, structured text and the other languages, and it requires each call of a function block to operate on its own instance data: values persist between scans and never leak into another instance. That is the whole basis of reuse here. Sequence state, edge detection and diagnostics live in the instance, so pump 2 cannot see pump 1's data.
Declare the instances and let the declaration do the work:
VAR
Pump1 : PumpDriveFB; // illustrative names: one instance per inverter
Pump2 : PumpDriveFB;
END_VAR
To work inside an instance in Sysmac Studio, right-click the instance and select "to lower layer"; in the Ladder editor, left-click on "Enter Function Block" to access the instance of the function block instruction you placed. The operation manual for function blocks and structures documents that definitions and instances both consume program memory in steps, so each added inverter adds steps: read the project's usage after the last instance is in, not before.
Should I use a Sysmac Library block or write my own? #
Write your own unless the library covers your exact device. Download the Sysmac Library from Omron, read the supported-device list and controller requirements of the MC Tool Box Library, and use its block only when the configured inverter and the functions you need are listed.
The library exists for this job: its catalogue describes function blocks that connect devices to the controller, plus backup and restoration helpers for quick setting change and recovery. Within it, the MC Tool Box Library is the set aimed at connecting and controlling inverters over EtherCAT. The decision rule: if its supported-device list names your configured device and covers run, stop, reset and reference, start with the library block and read its help before wiring it in; if it does not, write the custom block described below. A general description of inverters over EtherCAT is not compatibility confirmation for your installation.
Two limits apply to any library block: it cannot correct a mismatched device configuration or a wrong process-data mapping, and it hides the command sequence you would otherwise see. Keep pump sequencing and site permissives in your own code either way, so the application survives a change of drive interface. The interface you standardize on shapes everything downstream, and how a PLC controls a VFD across five interfaces shows what each option obliges you to map.
What has to be true in the EtherCAT configuration first? #
Four things: the EtherCAT configuration must name the same device that is installed, the network must be healthy, the drive must report ready, and the mapped process data must include the command, reference, status and feedback words your block will use.
The family name 3G3M1 alone does not select the interface. Record the nameplate model, the installed communication hardware and the device identification shown in the Sysmac Studio EtherCAT configuration, and proceed only when configured and installed agree. Then separate the readings you would otherwise conflate:
| What you see | What it means | What to do next |
|---|---|---|
| Configured device differs from installed device | The project may describe the wrong process-data interface | Correct the device identification and reconfigure before mapping commands |
| Communication diagnostics show a fault | Cyclic data is not a dependable control interface | Clear network and device diagnostics first |
| Communication healthy, drive not ready | An operating condition on the drive is unmet | Read drive status, operating mode and active faults |
| Drive ready, but ignores the command | Command ownership, mapping or sequence is wrong | Check the configured control source and the documented command sequence |
Command ownership decides the rest: confirm the drive is configured to take its run and reference sources from the network, because a healthy connection does not override a drive set to another source. Finally, watch the mapped status without issuing a start and compare it with the drive's own display; ready, stopped and fault indications must agree before you test any logic.
What belongs inside the function block? #
Four groups: application requests in, drive-interface data at the edge, application feedback out, and private instance state inside; keep the pump sequencing out of the block so the interface stays reusable when the drive implementation changes.
| Group | Contents | Design check |
|---|---|---|
| Application requests | Run request, operating reference, reset request, permissives | Define what happens when each request is removed |
| Drive interface | Mapped command and feedback words | Match the configured types, direction and scaling |
| Application feedback | Ready, running, faulted, communication healthy, actual value | Derive each indication from documented feedback |
| Instance state | Sequence state, edge detection, retained diagnostics | Must stay independent between inverters |
Use VAR_INPUT for what the block reads and VAR_OUTPUT for what it produces; use VAR_IN_OUT only when you intentionally pass a shared writable variable by reference. The skeleton below uses illustrative names, and the drive-side types must be replaced with the ones your process data actually maps:
FUNCTION_BLOCK PumpDriveFB
VAR_INPUT
RunRequest : BOOL := FALSE; // application wants the pump to run
Reference_Hz : REAL := 0.0; // engineering units, not drive counts
ResetRequest : BOOL := FALSE;
Permissive : BOOL := FALSE;
END_VAR
VAR_OUTPUT
Running : BOOL := FALSE; // drive reports operation
DriveFaulted : BOOL := FALSE;
Reference_Raw : INT := 0; // value written to the drive word
END_VAR
VAR
ReferenceMax_Hz : REAL := 50.0; // illustrative base frequency
FullScale : INT := 16384; // illustrative counts at 100 % reference
END_VAR
Keep requested state and reported state as separate variables: a run request means the application wants operation, running feedback means the drive reports it, and the difference is exactly what an operator needs to see when a start is inhibited. The same request-in, actuator-isolated, feedback-out shape appears in a PLC function block for gripper open and close control, which is a useful pattern check before you start typing.
How do I scale the frequency reference into the drive word? #
Divide the engineering-unit reference by its full-scale value and multiply by the drive word's full-scale count, in one place inside the block: at 37.5 Hz on a 50.0 Hz base with 16384 counts at 100 %, the transmitted word is 12288.
Those two full-scale numbers are an illustrative mapping: read the real range and scaling from the process-data assignment of the configured 3G3M1 before trusting them, because the mapped word can differ by configuration. The arithmetic, once the real numbers are in:
- Counts = Reference_Hz ÷ ReferenceMax_Hz × FullScale
- 37.5 Hz ÷ 50.0 Hz = 0.75
- 0.75 × 16384 counts = 12288 counts
- Reverse check: 12288 ÷ 16384 = 0.75, and 0.75 × 50.0 Hz = 37.5 Hz
Apply conversion and limiting in that one place: convert the real result to the drive word's integer type, which truncates, and clamp it between 0 and FullScale so a bad setpoint cannot command beyond the mapped range. The test that proves it: with the controller online or in simulation, set Reference_Hz to 37.5 while RunRequest is FALSE, and read Reference_Raw on the instance; it must show 12288 while the command word stays at stop. Before a controlled run, compare the transmitted word with the reference the drive reports interpreting, on its own display or diagnostics.
How do I sequence run, stop and fault reset? #
Gate the start, confirm the stop through feedback, keep fault reset separate from run, and make the restart policy explicit: a maintained run request must never turn into an uncommanded restart after a reset or a communication recovery.
Define the stopped condition first: read the drive's documented stop behavior, choose the response the application needs, and confirm the commanded stop in feedback before any automatic start logic exists. Gate every start on communication healthy, drive ready, permissives true and no fault, and expose which condition blocks, because a suppressed start with no stated reason costs a site visit. Derive the command transitions from the process-data specification of the configured device; do not copy a command-word pattern from another inverter merely because both use EtherCAT. Reset follows the drive's documented reset behavior, with the restart policy written beside it.
Treat lost feedback as its own condition: a cached running indication is not proof the drive is under control, so report communication loss separately from a drive-reported fault and set the drive-side communication-loss response to match the machine's risk assessment. One safety note: removing a run request is an operational stop, not a safety function, and personnel protection belongs to the machine's safety function as designed and validated against its risk assessment.
How do I test the instances one at a time? #
Build one instance, bind one inverter, compile, and prove the gating with starting inhibited before you release a controlled run; then repeat the same checkout per instance, because healthy communication on one slave proves nothing about the next.
- Create one instance and bind one inverter's mapped words; compile until the project is clean.
- Confirm one writer: no other routine may write the same drive command words.
- With starting inhibited, change the requests and watch the instance's internal decisions and outgoing values; a missing permissive must block the start while status stays feedback-driven.
- Under the site's commissioning procedure, issue a permitted run at a moderate reference; compare requested reference, transmitted word, drive indication and actual value, then stop and confirm the stop in feedback.
- Prove the fault path: trip a fault, confirm the block reports it and blocks starting, reset per the documentation, and confirm a maintained run request does not restart the drive.
- Repeat for every instance, then prove independence: run one pump while another is stopped and verify the stopped instance's command words do not change.
The per-drive discipline is the same one that pays off when commissioning five VFD drives on one Modbus gateway: prove one drive end to end, then each, then their independence. The decisions in one line: one definition with an instance per inverter; a library block only where the supported-device list names your configured drive, otherwise the custom block above; the EtherCAT device match verified before any mapping; scaling and limiting in one place; reset separated from run with an explicit restart policy; and one writer per command word.
Questions asked
Do I need InOut variables on every port to make the block reusable?
No. VAR_INPUT and VAR_OUTPUT are enough for values the block reads and produces, and they keep ownership easy to trace. Use VAR_IN_OUT only when you deliberately pass a shared, writable variable or structure by reference, because then two routines can write the same data. A block whose drive interface is mapped network words rarely needs InOut ports at all.
Does every instance cost controller memory?
Yes. The operation manual for function blocks and structures documents that program memory in steps is consumed by both function block definitions and their instances, so each additional inverter adds steps. Build the project with all instances present and read the controller's step usage then; the exact count depends on your block, so a figure from another project tells you nothing about yours.
Can I copy the command word pattern from another EtherCAT inverter?
No. Command and status word layouts belong to the device's configured process data, not to the fieldbus. A pattern that runs another inverter can map to different bits or scaling on the 3G3M1 and produce an uncommanded direction or reference. Derive every bit you set or read from the process-data assignment and the drive documentation for the configured device.
What should happen after a fault reset if the run request is still held on?
Whatever your restart policy says, written explicitly into the block. The sound default for a pump station is that a reset clears the fault but the start sequence must be re-armed, meaning the operator re-issues or re-acknowledges the run request, so a maintained signal cannot become an uncommanded restart after a reset or a communication recovery.