4. instrument_control_auxiliary
Example can be found here Controlling an Instrument.
4.1. Instrument Control Auxiliary
- module:
instrument_control
- synopsis:
provide a simple interface to control instruments using SCPI protocol.
The functionalities provided in this package may be used directly inside ITF tests using the corresponding auxiliary, but also using a CLI.
Warning
|
InstrumentControl Auxiliary |
|
Library of SCPI commands |
|
Library of instruments communicating via VISA |
4.1.1. InstrumentControl Auxiliary
- module:
instrument_control_auxiliary
- synopsis:
Auxiliary used to communicate via a VISA connector using the SCPI protocol.
- class pykiso.lib.auxiliaries.instrument_control_auxiliary.instrument_control_auxiliary.InstrumentControlAuxiliary(com, instrument='', write_termination='\\n', output_channel=None, **kwargs)[source]
Auxiliary used to communicate via a VISA connector using the SCPI protocol.
Constructor.
- Parameters:
com (
CChannel
) – VISAChannel that supports VISA communicationinstrument – name of the instrument currently in use (will be used to adapt the SCPI commands)
write_termination – write termination character
output_channel (
int
) – output channel to use on the instrument currently in use (if more than one)
- handle_query(query_command)[source]
- Send a query request to the instrument. Uses the ‘query’ method of the
channel if available, uses ‘cc_send’ and ‘cc_receive’ otherwise.
- Parameters:
query_command (
str
) – query command to send- Return type:
Optional
[str
]- Returns:
Response message, None if the request expired with a timeout.
- handle_read()[source]
Handle read command by calling associated connector cc_receive.
- Return type:
Optional
[str
]- Returns:
received response from instrument otherwise empty string
- handle_write(write_command, validation=None)[source]
Send a write request to the instrument and then returns if the value was successfully written. A query is sent immediately after the writing and the answer is compared to the expected one.
- Parameters:
write_command (
str
) – write command to sendvalidation (
Tuple
[str
,Union
[str
,List
[str
]]]) – tuple of the form (validation command (str), expected output (str or list of str))
- Return type:
str
- Returns:
status message depending on the command validation: SUCCESS, FAILURE or NO_VALIDATION
- query(query_command)[source]
- Send a query request to the instrument. Uses the ‘query’ method of the
channel if available, uses ‘cc_send’ and ‘cc_receive’ otherwise.
- Parameters:
query_command (
str
) – query command to send- Return type:
Union
[bytes
,str
]- Returns:
Response message, None if the request expired with a timeout.
4.1.2. Library of SCPI commands
- module:
lib_scpi_commands
- synopsis:
Library of helper functions used to send requests to instruments with SCPI protocol. This library can be used with any VISA instance having a write and a query method.
- class pykiso.lib.auxiliaries.instrument_control_auxiliary.lib_scpi_commands.LibSCPI(visa_object, instrument='')[source]
Class containing common SCPI commands for write and query requests.
Constructor.
- Parameters:
visa_object – any visa object having a write and a query method
instrument (
str
) – name of the instrument in use. If registered, the commands adapted to this instrument’s capabilities are used instead of the default ones.
- disable_output()[source]
Disable output on the currently selected output channel of an instrument.
- Return type:
str
- Returns:
the writing operation’s status code
- enable_output()[source]
Enable output on the currently selected output channel of an instrument.
- Return type:
str
- Returns:
the writing operation’s status code
- get_command(cmd_tag, cmd_type, cmd_validation=None)[source]
Return the pre-defined command.
- Parameters:
cmd_tag (
str
) – command tag corresponding to the command to executecmd_type (
str
) – either ‘write’ or ‘query’cmd_validation (
tuple
) – expected output after validation (only used in write commands)
- Return type:
Tuple
- Returns:
the associated command plus a tuple containing the associated query and the expected response (if cmd_validation is not none) otherwise None
- get_current_limit_high()[source]
Returns the current upper limit (in V) of an instrument.
- Return type:
str
- Returns:
the query’s response message
- get_current_limit_low()[source]
Returns the current lower limit (in V) of an instrument.
- Return type:
str
- Returns:
the query’s response message
- get_identification()[source]
Get the identification information of an instrument.
- Returns:
the instrument’s identification information
- get_nominal_current()[source]
Query the nominal current of an instrument on the selected channel (in A).
- Return type:
str
- Returns:
the nominal current
- get_nominal_power()[source]
Query the nominal power of an instrument on the selected channel (in W).
- Return type:
str
- Returns:
the nominal power
- get_nominal_voltage()[source]
Query the nominal voltage of an instrument on the selected channel (in V).
- Return type:
str
- Returns:
the nominal voltage
- get_output_channel()[source]
Get the currently selected output channel of an instrument.
- Return type:
str
- Returns:
the currently selected output channel
- get_output_state()[source]
Get the output status (ON or OFF, enabled or disabled) of the currently selected channel of an instrument.
- Return type:
str
- Returns:
the output state (ON or OFF)
- get_power_limit_high()[source]
Returns the power upper limit (in W) of an instrument.
- Return type:
str
- Returns:
the query’s response message
- get_remote_control_state()[source]
Get the remote control mode (ON or OFF) of an instrument.
- Returns:
the remote control state
- get_status_byte()[source]
Get the status byte of an instrument.
- Returns:
the instrument’s status byte
- get_target_current()[source]
Get the desired output current (in A) of an instrument.
- Return type:
str
- Returns:
the target current
- get_target_power()[source]
Get the desired output power (in W) of an instrument.
- Return type:
str
- Returns:
the target power
- get_target_voltage()[source]
Get the desired output voltage (in V) of an instrument.
- Return type:
str
- Returns:
the target voltage
- get_voltage_limit_high()[source]
Returns the voltage upper limit (in V) of an instrument.
- Return type:
str
- Returns:
the query’s response message
- get_voltage_limit_low()[source]
Returns the voltage lower limit (in V) of an instrument.
- Return type:
str
- Returns:
the query’s response message
- measure_current()[source]
Return the measured output current of an instrument (in A).
- Return type:
str
- Returns:
the measured current
- measure_power()[source]
Return the measured output power of an instrument (in W).
- Return type:
str
- Returns:
the measured power
- measure_voltage()[source]
Return the measured output voltage of an instrument (in V).
- Return type:
str
- Returns:
the measured voltage
- set_current_limit_high(limit_value)[source]
Set the current upper limit (in A) of an instrument.
- Parameters:
limit_value (
float
) – limit value to be set on the instrument- Return type:
str
- Returns:
the writing operation’s status code
- set_current_limit_low(limit_value)[source]
Set the current lower limit (in A) of an instrument.
- Parameters:
limit_value (
float
) – limit value to be set on the instrument- Return type:
str
- Returns:
the writing operation’s status code
- set_output_channel(channel)[source]
Set the output channel of an instrument.
- Parameters:
channel (
int
) – the output channel to select on the instrument- Return type:
str
- Returns:
the writing operation’s status code
- set_power_limit_high(limit_value)[source]
Set the power upper limit (in W) of an instrument.
- Parameters:
limit_value (
float
) – limit value to be set on the instrument- Return type:
str
- Returns:
the writing operation’s status code
- set_remote_control_off()[source]
Disable the remote control of an instrument. The instrument will respond to query and read commands only.
- Returns:
the writing operation’s status code
- set_remote_control_on()[source]
Enables the remote control of an instrument. The instrument will respond to all SCPI commands.
- Returns:
the writing operation’s status code
- set_target_current(value)[source]
Set the desired output current (in A) of an instrument.
- Parameters:
value (
float
) – value to be set on the instrument- Return type:
str
- Returns:
the writing operation’s status code
- set_target_power(value)[source]
Set the desired output power (in W) of an instrument.
- Parameters:
value (
float
) – value to be set on the instrument- Return type:
str
- Returns:
the writing operation’s status code
- set_target_voltage(value)[source]
Set the desired output voltage (in V) of an instrument.
- Parameters:
value (
float
) – value to be set on the instrument- Return type:
str
- Returns:
the writing operation’s status code
4.1.3. Library of instruments communicating via VISA
- module:
lib_instruments
- synopsis:
Dictionaries containing the appropriate SCPI commands for some instruments.