Overview: From SIMOTION Array to Excel Workbook
Production data for a pin-setting machine is generated cycle-by-cycle in a SIMOTION D425 motion controller and accumulated shift-by-shift inside a structured array. The typical requirement is to retain 365 days of shift totals (good pieces, rejects, downtime, OEE inputs) and to expose that array to a PC on the same LAN so that supervisors can open it directly in Microsoft Excel for analysis, charting, and ERP upload.
The D425 (part of the SIMOTION D4xx range, firmware V4.x / V5.x) does not natively create a .xls file - it is a real-time motion controller, not a file server. The data must therefore leave the controller over its Ethernet interface using one of the supported open protocols and be written to a spreadsheet by a PC-side service. The four practical paths are:
- OPC XML DA server running on the SIMOTION (no PC license, simple polling).
- SIMATIC NET OPC DA Server on the PC, reading SIMOTION variables over the SOFTNET interface.
- TCP/IP communication using the SCOUT "Interbranch Communication" library (binary, deterministic, free).
-
FTP file drop of a
.csvfollowed by Excel auto-refresh (requires a small PC-side daemon).
Each method is covered below with prerequisites, programming steps, sample code, and a verification procedure.
Architecture and Network Prerequisites
| Item | Specification |
|---|---|
| Controller | SIMOTION D425 (6AU1425-...); CPU firmware V4.4 or V5.2 recommended for OPC XML |
| Engineering | SCOUT TIA V5.2 SP1 / SCOUT V4.4 HF6 or newer with project on the engineering PG |
| Runtime licences | SIMOTION OPC XML Server (no extra cost on D425 with firmware V4.2+), SIMATIC NET SOFTNET-IE S7 Lean / Standard for OPC DA |
| Network | Industrial Ethernet, 100/1000 Mbit/s, D425 X120 port (PROFINET IO / Industrial Ethernet) in the same subnet as the PC |
| PC | Windows 10/11 64-bit, .NET 4.8, Microsoft Excel 2016 / 2019 / 365, optional SIMATIC NET V16 SP1 |
| Firewall | TCP 80 (OPC XML), 4840 (OPC UA), 21 (FTP), 102 (S7), 2000/2001/2002 (custom TCP via SCOUT library) |
192.168.0.10 / 24 for the D425 and 192.168.0.20 / 24 for the PC). Avoid routing through a managed switch that blocks broadcast traffic needed by the OPC XML discovery (WS-Discovery UDP 3702).
Method 1 - OPC XML DA Server Running on the D425
The OPC XML DA server is embedded in the SIMOTION firmware from V4.2 onward. It exposes every variable published on the controller as an OPC item, and any OPC XML client - including the OPC.Excel.Connector add-in or a Power Query feed - can subscribe to it.
Step 1: Publish the production array
In SCOUT, open the unit that owns the shift data. Right-click the array tag (e.g. shiftData[1..365]) and select Properties > OPC > Exportable. Set the OPC visibility to Public for the top-level structure; child elements are exposed automatically.
// MCC source snippet - declaring the exportable array
TYPE shiftRecord
STRUCT
shiftId : DINT; // 1..3
dateJulian : DINT; // days since 2000-01-01
goodParts : UDINT;
rejectParts : UDINT;
downtimeSec : UDINT;
runtimeSec : UDINT;
END_STRUCT;
END_TYPE
VAR_GLOBAL
shiftHistory : ARRAY[1..365] OF shiftRecord; // OPC-exported
END_VAR
Step 2: Activate the OPC XML server in the project
- Open SIMOTION > Commissioning > Web server / OPC settings in SCOUT.
- Enable OPC XML DA Server and assign HTTP port
80. - Set the user authentication to Anonymous read if the array is non-sensitive, or define a user in the SIMOTION user administration.
- Download the project to the D425 and run
RUN.
Step 3: Read the array from Excel with Power Query
- Open Excel > Data > Get Data > From Other Sources > From OData Feed (OPC XML DA is a compatible OData-like service for Microsoft clients).
- Enter the URL:
http://192.168.0.10:80/soap/opcxmland the device name, e.g.SIMOTION/D425. - Select the items
shiftHistory.goodParts,shiftHistory.rejectParts, etc. - Click Transform, pivot the array to a tabular layout, then Close & Load To > Table.
- Schedule refresh with Query > Properties > Refresh every 5 minutes.
Method 2 - SIMATIC NET OPC DA Server on the PC
For sites that already own a SIMATIC NET licence, the OPC.SimaticNet server is the most robust option. It supports DA 2.0 / 3.0, has high item density, and is reachable from any OPC client such as OPC.Excel.Connector, WinCC, or a custom C# application.
Step 1: Install SIMATIC NET on the PC
- Install SIMATIC NET PC Software V16 SP1 (or V18 for TIA V17 projects).
- During install, select OPC Server and SOFTNET-IE S7 Lean (one S7 connection) or SOFTNET-IE S7 Standard (up to 16 connections).
- Restart the PC and verify the
SIMATIC NET Configuration Consoleshows the Ethernet adapter bound to the S7 protocol.
Step 2: Configure an S7 connection to the D425
- Launch Station Configuration Editor and add a PC station with index 1 (matches the OPC default).
- Insert an OPC Server slot and an IE General module on the same station.
- Open SIMATIC NET Configuration > Connections and create a new S7 connection to
192.168.0.10(D425), rack 0, slot 2 (D4xx CPU slot), connection resource DB 1. - Download the PC station configuration.
Step 3: Expose the array in the OPC namespace
The SIMATIC NET OPC server reads item names in the form S7:[S7 connection_1]DBx,BYTE y. For symbolic access (preferred), enable Symbolic access to S7-1500 / SIMOTION in the SIMATIC NET configuration and use the symbolic path:
S7:[D425_OPC]shiftHistory[1].goodParts
S7:[D425_OPC]shiftHistory[1..365].runtimeSec
Step 4: Read from Excel with OPC.Excel.Connector
- Install the OPC Excel Connector add-in (Microsoft, free, retired but still redistributable) or use a modern replacement such as OPC-DA-to-Excel bridge in C#.
- Add a new Server pointing to
OPC.SimaticNet. - Bind cells
A1:A365toshiftHistory[i].goodPartsusing the=OPCItemformula. - Press Refresh All; the array is filled within ~600 ms for 365 records.
Method 3 - TCP/IP via the SCOUT Communication Library
When licensing cost must be zero and the dataset is large or proprietary, the SIMOTION Interbranch Communication (IBS) library on the SCOUT Utilities & Applications DVD provides a deterministic TCP/UDP stack callable from MCC/ST/LAD. The library is part of the standard SCOUT install (Start > Programs > Siemens Automation > SCOUT > Utilities & Applications > Interbranch Communication).
Step 1: Install the library
- Copy the library archive to a working folder and unpack it.
- In SCOUT, open Libraries > Open Library and select the unpacked
.zip/.slb. - Drag the TCP_IP_basic and TCP_IP_stream function blocks into your project.
- Compile and download.
Step 2: SIMOTION-side TCP server
Create a unit ShiftDataExport with the following ST code. The SIMOTION listens on port 2000, accepts a GetShift command, and returns a binary record. The PC acts as a client and writes the bytes into Excel as a tab-separated file.
PROGRAM ShiftServer
VAR
fbListen : TCPIP_Listen; // from library
fbAccept : TCPIP_Accept;
fbRecv : TCPIP_Receive;
fbSend : TCPIP_Send;
hSocket : DINT := -1;
rxBuf : ARRAY[0..255] OF BYTE;
txBuf : ARRAY[0..8191] OF BYTE;
cmd : STRING[32];
i : DINT;
pRecord : POINTER TO shiftRecord;
END_VAR
// Trigger: Rising edge of _TCP.startServer
IF _TCP.startServer THEN
fbListen(port := 2000, hSocket := hSocket);
END_IF;
// Accept a pending connection (polled each cycle)
fbAccept(hSocket := hSocket, subSocket := hSocket);
// Receive a 32-byte command
fbRecv(socket := hSocket, pData := ADR(rxBuf), dataLen := 32, recLen := i);
IF i > 0 THEN
cmd := STRING_FROM_BUFF(rxBuf, 0, 32);
IF cmd = 'GETSHIFT' THEN
// Build a 365 x 28 byte payload = 10220 bytes
FOR i := 1 TO 365 DO
pRecord := ADR(shiftHistory[i]);
memcpy(ADR(txBuf) + (i-1)*SIZEOF(shiftRecord),
pRecord, SIZEOF(shiftRecord));
END_FOR;
fbSend(socket := hSocket, pData := ADR(txBuf),
dataLen := 365 * SIZEOF(shiftRecord), sentLen := i);
END_IF;
END_IF;
Step 3: PC-side client (Python example)
Python's socket module plus pandas to push the data to .xlsx - the cheapest, fastest and most portable approach.
import socket, struct, pandas as pd
HOST, PORT = '192.168.0.10', 2000
RECORD_FMT = '<i i I I I I' # 28 bytes matching shiftRecord
RECORD_LEN = struct.calcsize(RECORD_FMT)
s = socket.socket(); s.connect((HOST, PORT))
s.sendall(b'GETSHIFT\x00' + b'\x00'*24)
payload = b''
while len(payload) < 365 * RECORD_LEN:
chunk = s.recv(4096)
if not chunk: break
payload += chunk
rows = [struct.unpack(RECORD_FMT,
payload[i*RECORD_LEN:(i+1)*RECORD_LEN]) for i in range(365)]
df = pd.DataFrame(rows, columns=['shiftId','dateJulian',
'goodParts','rejectParts','downtimeSec','runtimeSec'])
df.to_excel(r'C:\ShiftReport\history.xlsx', index=False)
s.close()
Step 4: Schedule the export
- Save the script as
C:\ShiftReport\pull.py. - Open Task Scheduler and create a task that runs at every shift change (e.g. 06:00, 14:00, 22:00) with action
python.exe C:\ShiftReport\pull.py. - Add an error event to the Windows Event Log so MES can pick it up.
Method 4 - FTP File Drop of a CSV
When the PC application (MES, custom .NET) is already polling a shared folder, the simplest method is to have the D425 write a CSV block to a shared network share. SIMOTION does not include a CIFS client, so the pattern is reversed: a PC daemon requests a chunk of data over OPC or TCP, appends a line to history.csv, and Excel opens it directly with Data > From Text/CSV or a refreshable query.
- Create a network share
\\\\MES-PC\\ShiftDatawith write access for the PC service account. - Extend the TCP server to support the command
GETCSV; the response is a single line of comma-separated values for one shift. - The PC appends the line to the CSV and renames
history.csvwith a date stamp once per day. - Excel Power Query refreshes on open - the file path is in the query definition.
Designing the Array for Smooth Export
Whatever method you pick, the array geometry on the SIMOTION must match what Excel expects. A common pitfall is a sparsely populated array - shift 365 is empty on day 1 of commissioning, so Power Query reads 0 instead of NULL. Use the following rules of thumb:
| Field | Type | Initial value | OPC XML path |
|---|---|---|---|
| shiftId | DINT | 0 | shiftHistory[1..365].shiftId |
| dateJulian | DINT | -1 (means "no data") | shiftHistory[1..365].dateJulian |
| goodParts | UDINT | 0 | shiftHistory[1..365].goodParts |
| rejectParts | UDINT | 0 | shiftHistory[1..365].rejectParts |
| downtimeSec | UDINT | 0 | shiftHistory[1..365].downtimeSec |
| runtimeSec | UDINT | 0 | shiftHistory[1..365].runtimeSec |
Keep the array fixed-size (365) to avoid OPC XML dynamic-array re-browsing. A ring buffer or pointer indirection only confuses the spreadsheet side.
Verification Procedure
-
Reachability: From the PC, open a command prompt and run
ping 192.168.0.10. Latency must be below 5 ms on a healthy LAN. -
OPC XML discovery: In a browser, open
http://192.168.0.10/soap/opcxml?wsdl. You should see a WSDL document; if you get 401 Unauthorized, check the user list on the D425. -
Item browse: In SIMATIC NET OPC Scout V10, connect to
OPC.SimaticNet, navigate toS7:[D425_OPC]shiftHistoryand confirm the array length is 365. - Read test: Add a Read DA item group of three elements, click Read. Update cycle should report < 100 ms for 365 records.
- Excel round-trip: Refresh the workbook, then deliberately corrupt one cell. The next refresh should overwrite it back to the SIMOTION value - if it doesn't, you are looking at a static copy rather than a live query.
- Long-run: Leave the query refreshing overnight and verify the array does not stall; a 24-hour stability test catches TCP socket leaks in custom code.
Troubleshooting Matrix
| Symptom | Likely cause | Fix |
|---|---|---|
| OPC XML WSDL returns 404 | Web server not enabled or wrong port | Re-enable OPC XML DA in SCOUT project, set HTTP port 80, re-download |
| OPC items show quality "Bad - Out of Service" | Variable not marked as OPC exportable | Right-click tag > Properties > OPC > Exportable |
| OPC DA client cannot browse S7 connection | PC station not downloaded / wrong index | Re-download PC station in Station Configuration Editor, index = 1 |
| TCP socket closes after 1 record | Server in close-wait after one send | Keep the socket open until client sends BYE; flush send buffer with TCPIP_Send return code = 0 |
| Excel Power Query hangs on refresh | Subnet mismatch or proxy server | Disable "Use proxy server for LAN" in Internet Options or add bypass for 192.168.0.*
|
| Array values are all zero | Variable not initialised after STOP/RUN transition | Run the initShiftHistory routine in Startup task |
| Power Query shows only 64 elements | OPC XML browse depth exceeded | Split the array into two structures of 182 / 183 records |
| File locks in shared folder | Excel opens history.xlsx exclusively |
Close the workbook on the MES PC or move the export to a daemon that writes a copy |
Method Selection Cheat Sheet
| Criterion | OPC XML | OPC DA (SIMATIC NET) | TCP/IP library | CSV/FTP daemon |
|---|---|---|---|---|
| PC licence cost | 0 | SOFTNET licence required | 0 | 0 |
| Throughput (365 records) | ~1.2 s | ~0.6 s | ~0.05 s | ~0.5 s |
| Firewall friendliness | Port 80 only | Port 102 (S7) + DCOM | Arbitrary | Port 21 / SMB |
| Bidirectional write-back | Yes | Yes | Yes (custom) | No |
| Engineering effort | Low | Medium | High | Medium |
| Excel integration | Power Query native | OPC Excel Connector / C# | Python + pandas | Power Query native |
For a single-machine commissioning such as the pin setter, OPC XML on port 80 is the lowest-effort and most maintainable path. Reserve the TCP/UDP library for OEM-style machines that are shipped to many sites with restricted outbound connectivity.
Field-Proven Commissioning Tips
- Always export the symbolic name, not the absolute address - it survives firmware upgrades and project refactoring.
- On the D425, mark the data block as retain in the unit properties; otherwise the array is cleared on every STOP/RUN transition.
- Set the OPC XML update rate to at least 500 ms. A faster rate wastes CPU on the controller and may stall the servo.
- Use a dedicated VLAN for OPC traffic if the line is shared with PROFINET IO motion devices; broadcast storms from office PCs will otherwise jitter the bus.
- Tag every export job with a version number stored in the array header, so spreadsheet formulas referencing "production v3" do not break when the schema changes.
- Validate the array on day 1: write a known pattern (1..365) into the array in Startup task and confirm Excel shows the same numbers. Then clear the array and let the real counters fill it.
FAQ
Can the SIMOTION D425 write a .xls file directly to a network share?
No. The D425 is a real-time motion controller without a CIFS/SMB stack. The array must be exported over Ethernet (OPC XML on port 80, OPC DA via SIMATIC NET, or TCP using the SCOUT Interbranch Communication library) and saved to .xlsx by a PC service or a Python/Excel script.
Do I need a SIMATIC NET licence to read the array with Excel?
Only if you choose OPC DA. The OPC XML DA server embedded in the D425 firmware (V4.2 or newer) is free, runs on port 80, and can be consumed by Excel Power Query without any licence on the PC side.
What is the fastest way to move 365 shift records to Excel?
Use the SCOUT Interbranch Communication (TCP/UDP) library with a small PC client written in Python. A single GETSHIFT command returns the whole 365 x 28-byte block in well under 100 ms over a 100 Mbit/s LAN.
How do I keep the array across a STOP/RUN transition?
Open the unit properties in SCOUT, switch to the Retain tab, and tick Retain variable for the array. Also enable Retain global data under Project > Properties > Runtime. Without this, the array is zeroed every restart.
Why does OPC Scout show only 64 array elements?
OPC XML DA on SIMOTION has a browse-tree depth limit of 64. If the array index goes deeper in the symbolic tree, only the first 64 entries are visible. Split the structure into two arrays of 182/183 records to stay within the limit.
Can I write the array back from Excel into the D425?
Yes, with both OPC XML and OPC DA the connection is bi-directional. Bind a cell to shiftHistory[i].goodParts, change the value, and the SIMOTION tag updates on the next scan - useful for manual corrections or recipe downloads.