1. Overview
When a SIMOTION D controller (D4x5, D4x5-2, D410) drives a SINAMICS S120 drive object, every non-cyclic parameter access travels over the internal PROFIdrive (DP-V1) channel. Two functionally similar, but architecturally very different, function-block families can perform that access from the SIMOTION application:
- The
Command Librarywith_writeDriveParameter/_readDriveParameter– the classic, blocking-oriented blocks shipped with every SIMOTION SCOUT installation. - The
LDPV1library (Logical Drive PROFIdrive V1) withFBLDPV1WriteOneParameter/FBLDPV1ReadOneParameterand the surroundingFBLDPV1Buffermanager – the buffered, async, multi-job-capable alternative that the SIMOTION Project Generator wires into Message Handling for HMI and trace services.
This reference covers the runtime semantics of both paths, the buffer and identifier rules that prevent cross-talk between the two, and the field-proven configuration patterns that let a SIMOTION D project use both a SIMOTION Message Handling instance and a custom FBLDPV1WriteOneParameter loop without losing jobs.
2. The Two Parameter-Write Paths at a Glance
| Attribute | Command Library_writeDriveParameter
|
LDPV1 LibraryFBLDPV1WriteOneParameter
|
|---|---|---|
| Execution model | Synchronous call; CPU blocks until drive ACKs/NACKs (or timeout) | Asynchronous; command is queued in a DP-V1 buffer slot, polled by the buffer FB |
| Per-DO concurrent jobs | One outstanding write/read at a time (caller must serialize) | Multiple jobs in flight, limited only by buffer length |
| Underlying telegram | Direct DP-V1 write request from the SIMOTION runtime task | DP-V1 write through shared buffer (single AC cycle) |
| Job identifier required | No – the call is identified by instance pointer | Yes – i_jobId is used for tracking and completion evaluation |
| Buffer identifier | Not applicable | Mandatory field on every FB call; must be unique per drive/DO |
| Where it is used in SCOUT | Programmer-written ST/MCC code, technology object configuration | Project Generator → "Message Handling" (HMI, Trace, STARTER, web server) |
| Failure behaviour with concurrent calls | Calls overlap → drive returns BUSY, last call wins or times out | Calls slot into the buffer; FIFO ordering per buffer identifier |
| Throughput at high call rates | Degrades sharply (>5 Hz on a single DO) due to blocking | Linear up to buffer length (typical 16–32 jobs / DO) |
3. Command Library: _writeDriveParameter
_writeDriveParameter is a SIMOTION system function declared in the _DriveParameter namespace. It is the simplest path: hand it a logical drive address, a parameter number, the value, and an execution flag; the block initiates a DP-V1 single-parameter write and returns when the drive object has answered.
// ST snippet (SIMOTION) – Command Library
VAR
rRetVal : DINT; // 0 = OK, 0x8001 = BUSY, 0x8002 = TIMEOUT, ...
dValue : DINT := 1500;
END_VAR
rRetVal := _writeDriveParameter(
ioObjectHandle := Axis1, // TO / axis handle
iParameterNumber := 1150, // p1150 = ramp-function generator ramp-up time
iParameterIndex := 0,
iValue := dValue, // DWORD but cast from DINT
iValueLength := 4, // bytes
iExecute := TRUE,
iTimeout := 2.0, // seconds
oDone => ,
oBusy => ,
oError => );
Because the call is blocking, the surrounding task is held for the round-trip time of a DP-V1 write (typically 1–4 servo cycles on a SIMOTION D4x5 at 1 ms). A loop that issues 10 parameter writes in one MotionTask cycle stalls the entire cycle for the sum of all round-trips. This is the root cause of the common complaint that "writeDriveParameter and readDriveParameter take much time". When many commands target the same drive object they pile up at the DP-V1 interface; the drive has a finite acyclic-channel queue and returns 0xF2 (sequence error / channel busy) for any request that arrives while a previous one is still being processed.
_writeDriveParameter for one-shot commissioning and HMI-driven parameter changes; do not use it in any cyclic task that must complete inside one servo cycle.4. LDPV1 Library: Architecture and Components
The LDPV1 library is a layered set of function blocks that ship with SIMOTION SCOUT and are also distributed as part of the "SIMOTION Utilities & Applications" package. Its purpose is to multiplex many non-cyclic requests onto a single logical DP-V1 channel per drive object, with deterministic order, completion detection and centralised error handling.
| Function block | Role |
|---|---|
FBLDPV1Buffer |
Per-DO buffer manager. Owns the acyclic channel, dispatches queued commands, evaluates responses, raises done/error events. |
FBLDPV1WriteOneParameter |
Queues a single-parameter write into a buffer slot and signals when the write is acknowledged by the drive. |
FBLDPV1ReadOneParameter |
As above, for reads. Returns the read value through a VAR_OUTPUT structure. |
FBLDPV1WriteMultiParameter / FBLDPV1ReadMultiParameter
|
Variant for multi-parameter access (DO array write/read). |
FBLDPV1Init / FBLDPV1DeInit
|
Buffer creation, size configuration, teardown. |
Each drive object on a SIMOTION D controller that participates in LDPV1 traffic must have exactly one FBLDPV1Buffer instance, and every FBLDPV1WriteOneParameter call must target that buffer through a unique buffer identifier slot.
5. FBLDPV1WriteOneParameter Deep Dive
The signature below is reproduced from the LDPV1 V4.x library header (SIMOTION SCOUT V5.x, library version 4.5.0):
FUNCTION_BLOCK FBLDPV1WriteOneParameter
VAR_INPUT
i_jobId : DINT; // 0 = ignore tracking, >0 = application tag
i_bufferId : DINT; // buffer slot, MUST be unique per buffer FB
i_driveHandle : DRIVE_HANDLE; // handle of the drive object (TO or logical address)
i_paramNumber : DINT;
i_paramIndex : DINT;
i_valuePtr : PVOID; // ANY pointer to the value to write
i_valueLength : DINT; // bytes (1, 2, 4, 8)
i_execute : BOOL;
END_VAR
VAR_OUTPUT
o_done : BOOL;
o_busy : BOOL;
o_error : BOOL;
o_errorId : DINT; // 0x0000 = OK, see section 11
o_jobId : DINT; // echoes the i_jobId of the completed slot
END_VAR
Calling pattern – the FB is a classic two-step rising-edge model:
// ST pattern for one parameter
IF bStartWrite AND NOT fbWrite.o_busy THEN
fbWrite(i_execute := FALSE); // reset edge
END_IF;
IF bStartWrite THEN
fbWrite(
i_jobId := 4711,
i_bufferId := 0, // see section 7
i_driveHandle := Axis1.HwDriveHandle,
i_paramNumber := 1150,
i_paramIndex := 0,
i_valuePtr := ADR(dValue),
i_valueLength := 4,
i_execute := TRUE);
END_IF;
IF fbWrite.o_done THEN
// re-arm
fbWrite(i_execute := FALSE);
END_IF;
IF fbWrite.o_error THEN
// see section 11 for o_errorId decoding
bStartWrite := FALSE;
END_IF;
FBLDPV1WriteOneParameter is executed, the FB returns o_error = TRUE with o_errorId = 0x7001 ("buffer overflow, request rejected"). Increase i_bufferSize in FBLDPV1Init if this occurs under normal load.6. Buffer Manager (FBLDPV1Buffer) Operations
The buffer manager runs as a long-running FB in the background. It is the only entity that actually owns the DP-V1 channel. It performs three duties in a single sweep:
- Dispatch – scans its slot list, picks the next slot in FIFO order, and issues the DP-V1 request through the SIMOTION IO layer.
- Poll – waits for the response from the drive object; updates the slot's state (RUNNING → DONE / ERROR).
-
Complete – raises the slot's
o_done/o_error, releases the slot, and moves to the next pending job.
Because the buffer is a single FB instance per DO, every queued write is serialised on the wire – exactly what the S120 acyclic channel requires. Application code can fire ten FBLDPV1WriteOneParameter calls inside a 1 ms MotionTask and the buffer will simply queue them; the writes are processed in subsequent servo cycles without blocking the caller.
7. Job Identifiers, Buffer Identifiers, and Data Set Numbers
Three identifier fields appear on the LDPV1 FBs and they are often confused. The rules below are taken from the SIMOTION SCOUT LDPV1 library manual (entry ID 109751626 in the Siemens Industry Online Support) and verified against a D435-2 / S120 firmware V5.2 SP3 stack.
| Field | Purpose | Uniqueness | Mandatory? |
|---|---|---|---|
i_jobId |
Application tag. Echoed back in o_jobId so the caller can match a completed slot to the request it issued. |
Unique per application context (the tag is not interpreted by the FB). | Optional – set to 0 if you don't need correlation. |
i_bufferId |
Slot index inside the FBLDPV1Buffer instance that will hold the request. |
Unique per buffer instance; reused slot IDs cause slot overwrite and lost completions. | Mandatory. |
| Data Set Number (DS) | The drive's acyclic parameter set number (0 = parameter, 47 = fault buffer, 16 = identification, etc.). Mapped at the drive, not at the SIMOTION FB. | Selected per-parameter by the FB based on the parameter number; do not confuse with a SIMOTION-side index. | Handled internally by LDPV1. |
7.1 Buffer Identifier Rules
The buffer identifier is the single most common source of jobs that go missing. The library's hard rule is: two outstanding FBs must not share a buffer identifier in the same FBLDPV1Buffer instance. If they do, the second call overwrites the first's slot and the first call's o_done/o_error will never be raised.
0 for the SIMOTION Message Handling instance (the Project Generator does this by default). Allocate a disjoint range, e.g. 1..15, for application code. The LDPV1 default buffer length is 8 slots, so a project's total outstanding FB calls should not exceed the buffer size at any point in time.7.2 Job Identifier Rules
Job identifiers are purely application-level tags. They do not need to be globally unique – the LDPV1 library never inspects the value. The only constraint is that the tag you set in i_jobId is the value you compare against o_jobId when o_done rises. A common pattern is to embed a counter, a state number, or a pointer to the source structure into i_jobId.
7.3 Data Set Numbers
The Data Set Number is an attribute of the drive, not the SIMOTION FB. For SINAMICS S120 the S120 parameter list (LH1) documents the DS used by each parameter; most user-visible parameters (p, r, c) sit in DS0. FBLDPV1WriteOneParameter selects DS0 by default – there is no need to specify a DS unless you are accessing the fault buffer (DS47) or the identification & maintenance data (DS16). The FB does not expose a DS input.
8. SIMOTION Message Handling Integration
SIMOTION's Project Generator creates a block called Message Handling the moment you enable HMI communication, web-server diagnostics, the SIMOTION trace viewer, or STARTER routing through a D4x5. The block is implemented as an LDPV1 client: a private FBLDPV1Buffer with a single consumer that calls FBLDPV1ReadOneParameter / FBLDPV1WriteOneParameter on behalf of the higher-level requestor.
Concretely, Message Handling:
- Allocates its own buffer instance on every drive object that is exposed to the HMI / web server.
- Uses
i_bufferId = 0for all of its requests. - Polls the buffer from a background task (typically the BackgroundTask).
Because of the buffer-identifier uniqueness rule, any application FB that targets the same drive object must avoid i_bufferId = 0. If application code uses 0 and the HMI happens to issue a parameter read at the same time, one of the two completions will be lost; the symptom is an HMI that "freezes" a parameter value or a SIMOTION trace that stops refreshing.
9. Performance and Concurrency
The two paths behave very differently under load. The numbers below are typical for a SIMOTION D435-2 (firmware V5.2 SP3) controlling one S120 CU320-2 PN with active STARTER online routing through the same D4x5. They are intended as an order-of-magnitude indication, not a contract.
| Scenario | _writeDriveParameter |
FBLDPV1WriteOneParameter (buffer size 8) |
|---|---|---|
| 1 write / servo cycle, 1 ms | Works but blocks ~1.5 ms per write → task overrun above 2 writes/cycle | Works, ~0.1 ms CPU per fire-and-forget call |
| 10 writes per servo cycle | Task overrun guaranteed, drive returns 0xF2 (channel busy) for ~70 % of calls | All 10 queued in 1 ms, processed in ~10–15 ms total; zero task overruns |
| 100 writes/second sustained | CPU load on the SIMOTION task ~25 %, drive ACKs all | CPU load < 1 %, drive ACKs all |
| 1000 writes/second burst | Drives starts NACKing, queue backs up, watchdog timeouts possible | Buffer fills, oldest entries roll over, application must throttle |
0x7001 for the rejected slot. A burst that exceeds the drive's acyclic channel queue is not – the drive returns 0xF2, the SIMOTION IO layer times out, and the call reports 0x8002 after i_timeout seconds.10. Implementing a Custom Buffer Identifier Scheme
The simplest robust scheme is a single static range. For each drive object that the application writes to, declare a constant block:
// constants block (ST)
CONST
// Message Handling owns 0 on every DO. App uses 1..15.
BUFID_RAMP_TIME : DINT := 1;
BUFID_P_GAIN : DINT := 2;
BUFID_FILTER_TIME : DINT := 3;
// etc.
END_CONST
For a more dynamic scheme, allocate a small pool and check out a free identifier on demand. The "free-list" pattern is implemented by an LDPV1-aware function block called FBLDPV1AllocBufferId that some projects ship internally; it is not part of the standard library. A typical implementation returns the lowest free slot in 0..7 and marks it used until the corresponding o_done or o_error fires.
5 to different parameters on the same drive, neither aware of the other. The failure shows up only at the worst possible moment, usually during a customer FAT.11. Error Codes and Diagnostics
The error codes raised on o_errorId span both LDPV1-internal failures and DP-V1 responses from the drive. The most useful set for a SIMOTION D + S120 combination is reproduced below. Always cross-check against the S120 parameter list (LH1) and the SIMOTION LDPV1 manual for the firmware version you run on the D controller.
o_errorId |
Source | Meaning | Typical corrective action |
|---|---|---|---|
| 0x0001 | LDPV1 | Internal state machine error (illegal call sequence) | Reset i_execute on every transition; ensure o_busy is FALSE before re-arming. |
| 0x7001 | LDPV1 | Buffer full – request rejected | Increase buffer size at FBLDPV1Init or throttle caller. |
| 0x7002 | LDPV1 | Invalid handle | Re-resolve the drive handle after topology reconfiguration. |
| 0x7003 | LDPV1 | Invalid value length | Match i_valueLength to the parameter's data type (1, 2, 4 or 8 bytes). |
| 0x8001 | Drive / IO | BUSY – drive did not answer within the polling window | Retry; check the DP-V1 channel with STARTER. |
| 0x8002 | Drive / IO | Timeout – drive did not respond within i_timeout
|
Increase i_timeout; check CU320-2 / CX32-2 health. |
| 0xF2 | Drive (DP-V1) | Channel busy – drive's acyclic queue is full | Reduce write rate; verify the drive is not in commissioning mode. |
| 0xF3 | Drive (DP-V1) | Sequence error – request arrived while previous one was in progress | Same as 0xF2; indicates a caller is firing the Command Library on the same DO. |
| 0x1001–0x1FFF | Drive (PROFIdrive) | Parameter-specific fault; low byte contains the S120 fault code | Decode via parameter list LH1, section "Faults and Warnings". |
12. SIMOTION D Hardware Considerations
On SIMOTION D4x5 / D4x5-2 / D410, the DP-V1 channel used by both libraries is the internal PROFIdrive channel between the SIMOTION runtime and the integrated (or attached) SINAMICS. There is no PROFINET or PROFIBUS in the picture – the drive objects sit on the SIMOTION-internal drive bus. This has three practical consequences:
- No bus cycle time – the DP-V1 round-trip is bounded by the servo cycle, not by PROFINET send-clock. The worst-case round-trip is 1–2 servo cycles plus drive processing time.
-
The LDPV1 buffer is per-DO, not per-bus – each drive object (CU, TM, Active Line Module, Motor Module) requires its own
FBLDPV1Buffer. - Message Handling traffic shares the same internal channel – if you starve Message Handling, the HMI will lag and the web-server diagnostics will time out, even though there is no external network involved.
13. Best-Practices Checklist
- Use the LDPV1 library (not the Command Library) for any write that is issued more than once during a single SIMOTION task cycle.
- Allocate the buffer identifier range per drive object. Keep
0reserved for Message Handling. - Choose job identifiers from a single counter (e.g. an
UDINTthat wraps at 2^31) so completion correlation is unambiguous. - Size the buffer at
FBLDPV1Initfor the peak outstanding jobs, not the average. A buffer of 8 is typical; 16 is a good default for projects that mix HMI + trace + application writes. - Always re-arm the FB by calling it with
i_execute := FALSEwheno_doneoro_errorfires; the FB is edge-triggered and will not accept a second command while it still showso_busy = TRUE. - Do not mix
_writeDriveParameterand LDPV1 on the same DO without an external mutex – the Command Library bypasses the buffer and will race against any LDPV1 call in flight. - Document the buffer-identifier scheme inside the project documentation, not only in the source code.
14. Troubleshooting Matrix
| Symptom | Most likely cause | First action |
|---|---|---|
| HMI parameter reads time out only when the application writes parameters | Application is using i_bufferId = 0 on a DO that Message Handling also targets |
Re-map the application's buffer identifiers to a disjoint range (e.g. 1..15) |
Application parameter write never reports o_done
|
Two FBs share the same buffer identifier; the first's completion was overwritten | Audit all i_bufferId literals in the project |
| Drive reports 0xF2 (channel busy) during commissioning | Mix of _writeDriveParameter and LDPV1 on the same DO |
Remove _writeDriveParameter calls from the application or serialise them with the buffer |
| Task overrun in a 1 ms MotionTask after adding parameter writes |
_writeDriveParameter called in a cyclic task |
Move the write to the BackgroundTask or convert to LDPV1 |
| Web server parameter page returns "no data" after topology re-configuration | Message Handling's buffer is still pointing at the old drive handle | Restart the SIMOTION runtime (re-init restores Message Handling) |
| Buffer overflow on a DO with a 30 s command storm | Buffer size < peak outstanding jobs | Increase buffer at FBLDPV1Init; add a token-bucket throttle in the caller |
15. Reference Documents
The LDPV1 library manual, the SIMOTION D programming manual, and the SINAMICS S120 parameter list are the primary references for this material. When troubleshooting, always match the version of the LDPV1 library to the SIMOTION SCOUT version installed – library V3.x, V4.x and V5.x have slightly different error-code sets.
What is the practical difference between _writeDriveParameter and FBLDPV1WriteOneParameter?
_writeDriveParameter is a synchronous, blocking call that holds the SIMOTION task until the drive acknowledges. FBLDPV1WriteOneParameter is asynchronous: the request is queued in a per-DO FBLDPV1Buffer and the caller continues. Use the LDPV1 path for any parameter write issued more than once per task cycle; the Command Library is fine for one-shot commissioning.
Do job identifiers need to be unique across the whole SIMOTION project?
No. i_jobId is an application tag echoed back in o_jobId; the LDPV1 library does not interpret it. It only has to be unique enough for the caller to correlate a completed slot to the request it issued. The buffer identifier i_bufferId is the field that the library does check, and that one must be unique per FBLDPV1Buffer instance.
Why does the SIMOTION Message Handling always use buffer identifier 0?
The Project Generator reserves slot 0 of every per-DO FBLDPV1Buffer for its own use (HMI, Trace, STARTER routing, web server). Application code must therefore never use 0 on the same drive object, or the HMI's parameter read will be overwritten by the application write. Allocate a disjoint range (e.g. 1..15) for application FBs.
Do I need to specify a Data Set number when writing parameters from SIMOTION D?
No. FBLDPV1WriteOneParameter automatically selects the right Data Set based on the parameter number (DS0 for user parameters p/r/c, DS47 for the fault buffer, etc.). The DS is an attribute of the drive parameter, not a SIMOTION-side input.
What error code do I get when the LDPV1 buffer is full?
The FB returns o_error = TRUE with o_errorId = 0x7001. Increase the buffer length in FBLDPV1Init or throttle the caller so the number of outstanding requests never exceeds the buffer size. The default buffer length is 8 slots per drive object.
Can I mix _writeDriveParameter and FBLDPV1WriteOneParameter on the same drive object?
Technically yes, but not without an external mutex. The Command Library bypasses the LDPV1 buffer and goes straight to the drive's acyclic channel, so it will race against any LDPV1 call still in flight and trigger DP-V1 sequence errors (0xF3) on the drive. The safe pattern is to pick one library per drive object and use the other only for the rare one-shot commissioning write.