Sys. Id.

The following example demonstrates how to set up and run a system identification experiment. It creates the ScopeModule which is necessary to acquire the data for sys. id. It configures the injection, the system transfer function and then injects an excitation through the Sys. Id. injector block in the user code. The Sys. Id. module automatically calculates the results after the Scope data acquisition is done.

# Create a Scope module
scope = project.modules.create(ModuleType.SCOPE)
scope.add_variables(["I_L", "duty"])

# Create and configure a Sys. Id. module
sys_id = project.modules.create(ModuleType.SYS_ID)
sys_id.set_injector(
   "sys_id_input",
   mode=SysIdInjectionMode.OPEN_LOOP,
   peak_to_peak=0.2,
   order=12,
   repetitions=10,
   pre_excit_time_s=0.1
)
sys_id.set_transfer_function("I_L", "duty")

target.enable_pwm()

# Start the excitation injection
sys_id.inject_excitation()

# Wait until the Scope has acquired the data for Sys. Id.
cockpit.wait_until(scope.is_capture_done, timeout=15.0, interval=0.2)

target.disable_pwm()

# Export the data in the CSV format
sys_id.export(r"C:\imperix\captures\buck_bode_plot.csv")

API Reference

class imperix.SysIdModule(cockpit: Cockpit, data: dict[str, Any])
set_injector(injector_name: str | None = None, *, mode: SysIdInjectionMode | str | None = None, peak_to_peak: float | None = None, order: int | None = None, repetitions: int | None = None, pre_excit_time_s: float | None = None, timeout: float | None | UseDefaultTimeout = UseDefaultTimeout.TOKEN) None

Configure the Injector and the PRBS excitation.

Parameters:
  • injector_name – Sets the active Sys. Id. Injector.

  • mode – Injection mode. Use SysIdInjectionMode or the matching string value.

  • peak_to_peak – Peak to peak value of the PRBS.

  • order – PRBS order, from 7 to 22

  • repetitions – Number of PRBS periods, from 1 to 1000.

  • pre_excit_time_s – Duration (seconds) of the PRBS signal injected before the configured repetitions

  • timeout – Maximum time to wait for a response in seconds.

Raises:

InvalidStateError – If Cockpit cannot update the injector settings.

set_transfer_function(numerator: str, denominator: str, *, timeout: float | None | UseDefaultTimeout = UseDefaultTimeout.TOKEN) None

Set the numerator and denominator of the transfer function whose frequency response is to be estimated.

Parameters:
  • numerator – Numerator variable name.

  • denominator – Denominator variable name.

  • timeout – Maximum time to wait for a response in seconds.

Raises:

InvalidStateError – If Cockpit cannot update the transfer function.

inject_excitation(*, timeout: float | None | UseDefaultTimeout = UseDefaultTimeout.TOKEN) None

Inject the configured excitation through the active Sys. Id. Injector.

Parameters:

timeout – Maximum time to wait for a response in seconds.

Raises:

InvalidStateError – If the excitation cannot be started.

export(path: str | PathLike[str], *, timeout: float | None | UseDefaultTimeout = UseDefaultTimeout.TOKEN) None

Export the frequency response data to a CSV or MAT file.

Parameters:
  • path – Absolute path where the file will be written, as a string or Path. The file extension selects the export format. The supported extensions are .csv and .mat.

  • timeout – Maximum time to wait for a response in seconds.

Raises:

InvalidStateError – If Cockpit cannot export the result.

class imperix.SysIdInjectionMode(*values)

Injection mode for a Sys. Id. excitation.

Values:
  • CLOSED_LOOP: Add excitation to the input signal.

  • OPEN_LOOP: Add excitation to the average of the input signal.

CLOSED_LOOP = 'closed_loop'
OPEN_LOOP = 'open_loop'