IMD SolutionComputing LibraryShop main store

Explainer

Why OFS alone cannot log M340 data to SQL Server

Edge computing and IIoT Published 7 min read By IMD Solution engineering team

Short answer

OFS is an OPC Data Access server for M340 data: it serves live values with quality to OPC clients and has no database function, so it cannot log to SQL Server by itself. The working path is M340 → OFS → Citect SCADA → SQL Server, with Citect as the OPC client that owns the insert and OFSClient kept as a read-only commissioning tool.

On this page
  1. What OFS is documented to do
  2. What an OFSClient read proves, and what it does not
  3. Where the SQL Server write actually happens
  4. Commissioning the three hops in order
  5. Who owns what in this path
  6. Worked example: logging rate versus update rate
  7. The decision, case by case
  8. Questions asked

No. OFS cannot log anything to SQL Server, and no OFS setting will change that. OFS (OPC Factory Server) is an OPC Data Access server: it lets Windows client applications read Modicon PLC data, the M340 included, in real time, and its job ends at that OPC connection. The database insert belongs to an OPC client. Since Citect SCADA already runs in this project, the working path is M340 → OFS → Citect SCADA → SQL Server, with Citect as the OPC client that owns the insert. Keep OFSClient for what it is built to do — commissioning the first hop — and bring the three hops up separately, because each one fails on its own.

What OFS is documented to do #

Schneider Electric's product documentation for OFS describes software that enables Windows client applications to access Modicon PLC data in real time, over the standard OPC Data Access protocol — the OPC Classic specification for reading and writing live process values. That description is also the boundary. As an OPC DA server, OFS:

  • waits for OPC clients to connect, then serves the values they subscribe to;
  • delivers each value with an OPC quality code, so a client can tell a good sample from a stale one;
  • carries no scheduler, no history buffer and no database interface — no connection string, no table name, no insert to run.

An OPC DA server is also strictly live: it serves what the PLC holds now and retains nothing for a client that was not listening. Retention over days and weeks is client work, and OFS is not a client. That is why logging from OFS afterwards has no mechanism to attach to, at any version.

What an OFSClient read proves, and what it does not #

OFSClient is the test client that ships with OFS: connect, browse, read items, write items. It has no database function of any kind — a good value in OFSClient never becomes a row anywhere. A clean OFSClient read therefore proves exactly hop 1 (M340 → OFS), for that item, at that moment. It says nothing about hop 2 (OFS → Citect) or hop 3 (Citect → SQL Server), which carry their own configuration, accounts and failure modes.

While you are in there, read value and quality as two separate outputs. After a network or PLC fault, a client can keep displaying the last good number while the item's quality turns bad; a logger that stores the value without the quality quietly converts an outage into plausible-looking data.

One safety note: OFSClient can write items, and a write through OFS lands in the PLC. Treat OFSClient as read-only on a running line, and prove changes with an approved test variable, never a production control value.

Where the SQL Server write actually happens #

The insert is client work, and in this project the client is Citect SCADA. The full path is:

M340 → OFS → Citect SCADA (OPC client and logger) → SQL Server

Citect connects to OFS as an OPC client and maps its tags to OFS items; its database mechanism — the documented database functions or logging component of the installed release — then runs the insert against SQL Server. The configuration side is not in doubt: the Plant SCADA (Citect SCADA) documentation carries an OFS server configuration section whose values are recommended defaults for SCADA usage, adaptable per project. Recommended defaults on the SCADA side exist because the OFS connection is set up and owned there.

The three hops fail independently, so judge each by its own pass condition. Alarm logging is a different chain that ends in the same database and breaks for its own reasons — see why Citect alarm logging never reaches SQL Server. And a database connection that opens is not a row that lands, which is the whole story in Cicode insert not logging to SQL Server after SQLConnect succeeds.

Commissioning the three hops in order #

  1. Confirm the value at the source. Pick one changing value, record its identifier, data type and expected range, and check the live value in the PLC monitoring tool before touching OPC. A logger cannot be more accurate than its source.
  2. Prove hop 1 in OFSClient. Read the item, confirm the value matches the PLC and the quality is good, and watch one real change arrive.
  3. Prove hop 2 from the Citect runtime, on the Citect host. Map one tag to the OFS item that just worked, match the data type, and confirm the runtime value tracks OFSClient under the same plant conditions. The running identity matters: a test client under your interactive login can connect while the runtime under its service account is refused, and when OPC Classic crosses machines, launch and activation permissions, access permissions and network settings all join the connection. If Citect runs on a server VM, check which Citect services actually started there before blaming OFS — why Citect SCADA starts only the client service on a server VM covers that failure.
  4. Prove hop 3 with one controlled insert. Configure the database connection for the account and host that will do the logging, run one insert to a test table, then open SQL Server and look for the row. A successful connection test is not a write test: the account can connect and still lack permission to insert. Read the returned database error and query the destination directly — what any screen shows proves neither the insert nor the commit.
  5. Attach the trigger last. Decide what one row means — periodic sample, change record or event — and capture value and quality together. A communication outage must end up as bad-quality records or a separate acquisition-failure record, never as a stream of plausible numbers.

Hops 2 and 3 run on the Citect host, so that host has to stay up for logging to continue. If the project puts logging on its own box in the cabinet instead of the supervision station, the fitting host is a fanless industrial mini PC.

Who owns what in this path #

Component Role in the path A pass there proves It does not do
OFS OPC DA server for M340 data Hop 1: the PLC value reaches OPC, with quality Schedule logging, retain history, or touch SQL Server
OFSClient OPC test client bundled with OFS Hop 1 again, item by item Log anything: it has no database function
Citect SCADA OPC client and logger Hop 2 and hop 3: tag value in runtime, row in the table Serve the OPC data itself — OFS stays the server
SQL Server Destination The row exists, with the right timestamp and value Reach OFS or the PLC on its own

Worked example: logging rate versus update rate #

These numbers are an example, not a documented OFS setting. Suppose an OFS subscription delivers a changed value every 1000 ms and the Citect logging trigger runs every 250 ms. Over one hour the trigger fires 3600 s / 0.25 s = 14,400 times, while OPC supplies at most 3600 s / 1 s = 3600 fresh values, because OPC DA reports on change and a flat value produces nothing new. At least 14,400 - 3600 = 10,800 rows — three quarters of the table growth — repeat a value the database already holds: the table grows four times faster than the measurement changes.

The ratio is the decision rule: set the logging period at or above the OPC delivery period. Matching the trigger to the subscription — 1000 ms in this example — stores each delivered sample once, at 3600 rows an hour. Slowing the trigger further trades intermediate samples for fewer rows and is right only when the question the data answers tolerates gaps. A trigger faster than the subscription buys nothing: faster inserts do not create faster measurements, they just duplicate the last acquired value. The cadence-and-trigger structure is the same as when you log production data from a panel PC to SQL Server — the host changes, the rate arithmetic does not.

The decision, case by case #

  • Can OFS alone log M340 data to SQL Server? No — it is a server, and there is no insert in it to find or enable. Stop looking for one.
  • Citect SCADA already in the project: make it the OFS client and the logger. That is the no-new-software answer, and it keeps OFS doing only what it is for.
  • OFSClient shows a good value with good quality: hop 1 is proven. Expect hop 2 and hop 3 to fail independently of it, and test them under the runtime identity and the logging account, not from your workstation.
  • Choosing a different OPC client instead: the division of labor is identical — the client owns the insert, OFS serves values, OFSClient stays a diagnostic.

Questions asked

Does the OPC UA wrapper in OFS change the answer?

No. OFS can also expose its data through an OPC UA wrapper, with its own security policy, message encoding and user identity settings, and it ships a UA sample client alongside OFSClient. That changes the protocol on the server side, not the architecture: an OPC UA endpoint is still a server endpoint with no database role, so a UA client still has to read the values and run the SQL insert itself.

Can OFS and the Citect host be different computers?

Yes, and that is where most hop 2 failures live. An OPC Classic connection across machines runs over Windows distributed COM, so launch and activation permissions, access permissions and network settings all become part of the link. A test client under your interactive login can connect while the Citect runtime under its service account is refused. Prove the connection under the account and on the host the runtime actually uses.

Is Citect SCADA the only OPC client that can do this?

No. Any client that reads OFS and has a database write path works: another SCADA package with SQL logging, a purpose-built logger, or a small application against an OPC client library. The case for Citect in this project is that it is already commissioned, so the architecture adds no new software and no new server. Whichever client you choose, the division of labor is fixed: the client owns the insert, OFS serves values.

What should one logged row contain?

The tag identity, the value in engineering units, a timestamp with a stated time basis, and the OPC quality. Keep the quality column even when you plan to store only good samples: it is the evidence that separates a real process change from a stale number that kept arriving across a communication fault. Choose SQL types that preserve the PLC value's range and precision, so a representative value round-trips without truncation or silent conversion.

Keep reading

  • How-to

    Logging PLC values from an OPC server into SQL Server

    SQL Server has no OPC client, so it cannot read OFS items by itself. Put an OPC client component between the server and the database: a packaged gateway or a small application that reads tags and writes rows. Prove the PLC read through an OPC test client first, then prove one database write under the runtime account before logging production values.

    Edge computing and IIoT

  • Explainer

    Do you need a historian or just an OPC tag server?

    No. An OPC tag server (OPC DA) supplies the current value, quality and timestamp of each item and stores nothing, so monthly figures need a historian or a SQL logger collecting from that same server. Keep a reporting client like ActiveFactory only if you also run the historian it expects.

    Edge computing and IIoT

  • How-to

    How to log Ignition tags every 15 minutes to a database

    To capture Ignition tag values on a strict 15-minute schedule, use a scheduled SQL Bridge transaction group that inserts a snapshot row into a database table, then point the report's query at that table. The tag historian is deadband-driven and stores asynchronously, so it cannot be set to one fixed 15-minute timestamp.

    Edge computing and IIoT

Why historian data goes missing and reappears the next day