Sys. Id.¶
The SysIdModule class provides methods to interact with Sys. Id. modules.
Note
The Sys. Id. module requires an instance of the ScopeModule in the
project to acquire the data that it will process.
Creating and controlling a Sys. Id. module¶
The following example demonstrates how to set up and run a system identification experiment. It creates a Scope and Sys. Id module. Then, it configures the injection, the system transfer function and 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.INPUT_HOLD,
peak_to_peak=0.2,
order=12,
repetitions=10,
pre_excit_time_s=0.1
)
# Get and configure the first transfer function
tf = sys_id.list_transfer_functions()[0]
tf.set_transfer_function("I_L", "duty")
target.enable_pwm()
# Start the excitation injection
sys_id.inject_excitation()
# Wait until the frequency response is estimated
cockpit.wait_until(sys_id.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])¶
- 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.csvand.mat.timeout – Maximum time to wait for a response in seconds.
- Raises:
InvalidStateError – If Cockpit cannot export the result.
- 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
SysIdInjectionModeor 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:
InvalidParamsError – If an injector setting is not valid.
NotFoundError – If
injector_nameis not defined in the user code.InvalidStateError – If Cockpit cannot update the injector settings.
- list_transfer_functions(*, timeout: float | None | UseDefaultTimeout = UseDefaultTimeout.TOKEN) list[SysIdTransferFunction]¶
Returns the list of transfer functions currently in the module.
- Parameters:
timeout – Maximum time to wait for a response in seconds.
- Returns:
A list of transfer function objects through which the numerator and denominator variable names can be read and changed.
- 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.
- is_capture_done(*, timeout: float | None | UseDefaultTimeout = UseDefaultTimeout.TOKEN) bool¶
Checks whether the frequency response estimation was completed.
- Parameters:
timeout – Maximum time to wait for a response in seconds.
- Returns:
Trueif the estimation was completed,Falseotherwise.
Example:
# Wait until the frequency response is estimated before exporting it. cockpit.wait_until(sys_id.is_capture_done)
- class imperix.SysIdTransferFunction(module: SysIdModule, data: dict[str, Any])¶
Representation of a transfer function variable from the Cockpit Sys. Id. module
- property numerator: str¶
Name of the numerator variable.
- property denominator: str¶
Name of the denominator variable
- 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.