I am running into a repeatable issue regarding sampling behavior when using variable-step solvers and XML‑RPC automation in PLECS Standalone. I would appreciate your insights on whether this is expected behavior or if there is a configuration I am missing.
Simulation Setup
-
PLECS Standalone
-
Solver Type: Variable-step
-
Solver: RADAU (stiff)
-
PWM Frequency: 33 kHz (generated inside a DLL that interacts with the control model)
-
Simulation is automated via XML‑RPC and waveforms are exported to CSV after each run.
Case 1 — CSV exported via XML‑RPC (sim.capture(...))
When running the simulation through automation and exporting scope data to CSV using XML‑RPC or the sim.capture() API, I get:
-
non‑uniform timestamps
-
Δt changes at every sample (as expected from variable-step integration)
-
Eg : time: 0, 1.2e‑6, 2.7e‑6, 3.0e‑6, 9.8e‑6, 10.1e‑6, …
This means the solver’s actual variable step sizes are being captured.
This causes a problem because I cannot directly compute an FFT unless I resample the data myself.
Case 2 — CSV exported from PLECS Scope GUI
If I run the simulation normally and then:
-
Open a PLECS Scope
-
Load the trace
-
File → Export → CSV
Then the exported CSV contains:
-
perfectly uniform time steps
-
exactly 30 μs per sample, matching the fundamental sampling period I expected
-
Eg : 0, 30e‑6, 60e‑6, 90e‑6….
This CSV is FFT‑friendly without resampling.
1. Why does XML‑RPC scope capture produce variable-step timestamps, while the PLECS Scope GUI exports a uniformly sampled CSV?
Is the Scope GUI applying internal resampling before exporting?
2. Is there an XML‑RPC API option that allows me to export the uniformly sampled waveform exactly the same way the Scope GUI does?
3. What is the recommended method to obtain FFT‑compatible, uniformly sampled data when running PLECS in variable-step mode through automation?
I want to avoid:
-
manually interpolating large CSV files in Python
-
switching to fixed-step (the model runs significantly slower at required sub‑microsecond steps due to the DLL generating 33 kHz PWM)
Additional Notes
I attempted to use the “Variable Integration / Sample-Hold” block to enforce a fixed 30 µs sampling rate, but this only samples the signal, not the scope time grid.
The main goal is to replicate exactly the same uniformly-sampled CSV that PLECS GUI exports — but programmatically.