API Reference
Sfc5xxxShdlcDevice
- class Sfc5xxxShdlcDevice(connection, slave_address)[source]
Sfc5xxx device.
This is a low-level driver which just provides all SHDLC commands as Python methods. Typically, calling a method sends one SHDLC request to the device and interprets its response. There is no higher level functionality available, please look for other drivers if you need a higher level interface.
There is no (or very few) caching functionality in this driver. For example if you call
get_serial_number()100 times, it will send the command 100 times over the SHDLC interface to the device. This makes the driver (nearly) stateless.- __init__(connection, slave_address)[source]
Create an Sfc5xxx device instance on an SHDLC connection.
Note
This constructor does not communicate with the device, so it’s possible to instantiate an object even if the device is not connected or powered yet.
- Parameters:
connection (ShdlcConnection) – The connection used for the communication.
slave_address (byte) – The address of the device. The default address of the SFC5xxx is 0.
- get_product_type(as_int=False)[source]
Get the product type. The product type (sometimes also called “device type”) can be used to detect what kind of SHDLC product is connected.
- Parameters:
as_int (bool) – If
True, the product type is returned as an integer, otherwise as a string of hexadecimal digits (default).- Returns:
The product type as an integer or string of hexadecimal digits.
- Return type:
string/int
- get_product_subtype()[source]
Get the product subtype. Some product types exist in multiple slightly different variants, this command allows to determine the exact variant of the connected device. Sometimes this is called “device subtype”.
Note
This command is not supported by every product type.
- Returns:
The product subtype as a byte (the interpretation depends on the connected product type).
- Return type:
byte
- get_product_name()[source]
Get the product name of the device.
Note
This command is not supported by every product type.
- Returns:
The product name as an ASCII string.
- Return type:
string
- get_article_code()[source]
Get the article code of the device.
Note
This command is not supported by every product type.
- Returns:
The article code as an ASCII string.
- Return type:
string
- get_serial_number()[source]
Get the serial number of the device.
- Returns:
The serial number as an ASCII string.
- Return type:
string
- get_version()[source]
Get the version of the device firmware, hardware and SHDLC protocol.
- Returns:
The device version as a Version object.
- Return type:
Version
- read_device_status(clear=True, as_exception=False)[source]
Read and optionally clear the device status and the last error. The status and error code interpretation is documented in the device interface specification.
- Parameters:
clear (bool) – If
True, the status flags on the device get cleared.as_exception (bool) – If
True, the last error is returned as anShdlcDeviceErrorobject instead of a byte.
- Returns:
The device status as a 32-bit unsigned integer containing all status flags, and the last error which occurred on the device. If
as_exceptionisTrue, it’s returned as anShdlcDeviceErrorobject orNone, otherwise as a byte.- Return type:
int, byte/ShdlcDeviceError/None
- get_slave_address()[source]
Get the SHDLC slave address of the device.
Note
See also the property
slave_addresswhich returns the device’s slave address without sending a command. This method really sends a command to the device, even though the slave address is actually already known by this object.- Returns:
The slave address of the device.
- Return type:
byte
- set_slave_address(slave_address, update_driver=True)[source]
Set the SHDLC slave address of the device.
Note
The slave address is stored in non-volatile memory of the device and thus persists after a device reset. So the next time connecting to the device, you have to use the new address.
Warning
When changing the address of a slave, make sure there isn’t already a slave with that address on the same bus! In that case you would get communication issues which can only be fixed by disconnecting one of the slaves.
- Parameters:
slave_address (byte) – The new slave address [0..254]. The address 255 is reserved for broadcasts.
update_driver (bool) – If
True, the propertyslave_addressof this object is also updated with the new address. This is needed to allow further communication with the device, as its address has changed.
- get_baudrate()[source]
Get the SHDLC baudrate of the device.
Note
This method really sends a command to the device, even though the baudrate is already known by the used
ShdlcPortobject.- Returns:
The baudrate of the device [bit/s].
- Return type:
int
- set_baudrate(baudrate, update_driver=True)[source]
Set the SHDLC baudrate of the device.
Note
The baudrate is stored in non-volatile memory of the device and thus persists after a device reset. So the next time connecting to the device, you have to use the new baudrate.
Warning
If you pass
Trueto the argumentupdate_driver, the baudrate of the underlayingShdlcPortobject is changed. As the baudrate applies to the whole bus (with all its slaves), you might no longer be able to communicate with other slaves. Generally you should change the baudrate of all slaves consecutively, and only setupdate_drivertoTruethe last time.- Parameters:
baudrate (int) – The new baudrate. See device documentation for a list of supported baudrates. Many devices support the baudrates 9600, 19200 and 115200.
update_driver (bool) – If true, the baudrate of the
ShdlcPortobject is also updated with the baudrate. This is needed to allow further communication with the device, as its baudrate has changed.
- get_reply_delay()[source]
Get the SHDLC reply delay of the device.
See
set_reply_delay()for details.- Returns:
The reply delay of the device [μs].
- Return type:
byte
- set_reply_delay(reply_delay_us)[source]
Set the SHDLC reply delay of the device.
The reply delay allows to increase the minimum response time of the slave to a given value in Microseconds. This is needed for RS485 masters which require some time to switch from sending to receiving. If the slave starts sending the response while the master is still driving the bus lines, a conflict on the bus occurs and communication fails. If you use such a slow RS485 master, you can increase the reply delay of all slaves to avoid this issue.
- Parameters:
reply_delay_us (byte) – The new reply delay [μs].
- factory_reset()[source]
Perform a factory reset (restore the off-the-shelf factory configuration).
Warning
This resets any configuration done after leaving the factory! Keep in mind that this command might also change communication parameters (i.e. baudrate and slave address) and thus you might have to adjust the driver’s parameters to allow further communication with the device.
- get_setpoint(scaling)[source]
Get the current flow setpoint.
- Parameters:
scaling (Sfc5xxxScaling) – Defines with which scale resp. unit the setpoint should be returned.
- Returns:
The current setpoint with the specified scaling.
- Return type:
float
- set_setpoint(setpoint, scaling)[source]
Set the flow setpoint which is used by the flow controller as reference input.
- Parameters:
setpoint (float) – The new setpoint with the specified scaling.
scaling (Sfc5xxxScaling) – Defines with which scale resp. unit the setpoint is passed.
- get_setpoint_persist()[source]
Get the setpoint persist configuration.
- Returns:
Whether the setpoint should persist after a device reset or not.
- Return type:
bool
- set_setpoint_persist(persist)[source]
Set the setpoint persist configuration.
Allows to define if a setpoint should persist after a device reset (soft or hardreset) or if it should be set to zero. Default is
False, i.e. the setpoint is set to zero after a device reset.- Parameters:
persist (bool) – Whether the setpoint should persist after a reset or not.
- set_setpoint_and_read_measured_value(setpoint, scaling)[source]
Set the flow setpoint and return the last measured flow value in one command.
This is the same as calling
set_setpoint()andread_measured_value(), but it’s more efficient since only one SHDLC command is executed.- Parameters:
setpoint (float) – The new setpoint with the specified scaling.
scaling (Sfc5xxxScaling) – Defines with which scale resp. unit the setpoint is passed and the measured flow is returned.
- Returns:
The last measured flow with the specified scaling.
- Return type:
float
- read_measured_value(scaling)[source]
Read the last measured flow value.
- Parameters:
scaling (Sfc5xxxScaling) – Defines with which scale resp. unit the measured flow should be returned.
- Returns:
The last measured flow with the specified scaling.
- Return type:
float
- read_measured_value_buffer(scaling, max_reads=100)[source]
Read the measured flow value buffer.
The MFC has an internal ring buffer in which the measured flow values are automatically stored in a regular interval. The size of the buffer is between 85 and 256 (depends on the specific device configuration). This method sends “read buffer” commands to the device until the whole buffer was read out (since the SHDLC frame length is limited, it’s not possible to read out the whole buffer with a single command). The received values will automatically be removed from the buffer in the device, so you will only get the values received since the last call to this method.
Warning
If you call this method too rarely, the buffer in the device will overrun, i.e. the oldest values are lost. You should check for lost values by reading the property
lost_valuesof the returned object. This method does not raise an exception if there are values lost since depending on the use-case, this might be expected behavior.Note
If the buffer gets filled faster than you read it out, it’s not possible to read out the whole buffer. In that case, the property
remaining_valuesof the returned object will hold a value greater than zero. You might want to check this property to be sure the whole buffer was read out. However, often that’s not needed since sooner or later you will also get a buffer overrun in this situation.- Parameters:
scaling (Sfc5xxxScaling) – Defines with which scale resp. unit the measured flow values should be returned.
max_reads (int) – The maximum count of read commands which should be sent until the read operation will be aborted. This abort condition is needed to avoid an infinite loop if the buffer gets filled faster than it can be read out.
- Returns:
An object containing the buffered flow values and some metadata. See
Sfc5xxxReadBufferResponsefor details.- Return type:
- get_valve_input_source()[source]
Get the valve input source configuration.
- Returns:
The current valve input source configuration.
- Return type:
- set_valve_input_source(source)[source]
Set the valve input source configuration.
By default, the valve is controlled by the flow controller according the setpoint and measured flow. But with this configuration you can take over the valve control and set the valve to a specific value. This configuration is volatile, i.e. it is reset to its default value after a device reset.
Note
When changing the valve input source to
USER_DEFINED. you also need to specify the user defined value by calling the methodset_user_defined_valve_value().- Parameters:
source (Sfc5xxxValveInputSource) – The valve input source to set.
- get_user_defined_valve_value()[source]
Get the current user defined valve value.
- Returns:
The current user defined valve value [0..1]. Zero means “fully closed”, 1.0 means “fully open”.
- Return type:
float
- set_user_defined_valve_value(value)[source]
Set the user defined valve value.
Note
Writing the user defined valve value has no effect as long as the valve input source is not set to
USER_DEFINED. So you’ll also have to callset_valve_input_source()to change the valve input source.- Parameters:
value (float) – The new user defined valve value as a normalized value in the range [0..1]. Zero means “fully closed”, 1.0 means “fully open”.
- get_user_defined_medium_unit(substitute_wildcards=False)[source]
Get the currently configured user defined medium unit.
- Parameters:
substitute_wildcards (bool) – By default, the user defined medium unit is set to “undefined” values, which means to fall back to the calibration unit. With this parameter you can choose whether you want to get the actually configured user defined unit (which then might be undefined), or whether the calibration unit should be returned instead in that case. Default is
False, i.e. you will get the actual configuration without falling back to the calibration unit.- Returns:
The current user defined medium unit.
- Return type:
- set_user_defined_medium_unit(unit)[source]
Set the user defined medium unit.
This is the unit which will be used when reading or writing flow values like setpoint or measured flow with the scaling
USER_DEFINED. This allows to always work with the same flow unit, no matter what’s the actual calibration unit of the MFC.Note
This setting is stored permanently in the device, i.e. it persists after a device reset.
- Parameters:
unit (Sfc5xxxMediumUnit) – The user defined medium unit to set.
- get_user_defined_fullscale()[source]
Get the fullscale flow in the currently set user defined unit.
- Returns:
The fullscale flow in the current user defined unit.
- Return type:
float
- get_user_controller_gain()[source]
Get the current user controller gain.
- Returns:
The current user controller gain (normalized value, default 1.0).
- Return type:
float
- set_user_controller_gain(gain)[source]
Set the current user controller gain.
This allows to adjust the speed of the flow controller by changing its overall gain.
Note
This value is stored permanently in the device, i.e. it persists after a device reset.
- Parameters:
gain (float) – The new gain to set (normalized value, default 1.0).
- get_pressure_dependent_gain_enable()[source]
Get the state of the pressure dependent gain setting.
- Returns:
Whether the pressure dependent gain is enabled or not.
- Return type:
bool
- set_pressure_dependent_gain_enable(enable)[source]
Set the state of the pressure dependent gain setting.
If the pressure dependent gain is enabled, you’ll have to set the actual inlet pressure with the method
set_inlet_pressure_for_gain_correction().Note
This value is stored permanently in the device, i.e. it persists after a device reset.
- Parameters:
enable (bool) – Whether the pressure dependent gain should be enabled or not.
- get_inlet_pressure_for_gain_correction()[source]
Get the currently configured inlet pressure as used for the pressure dependent controller gain.
- Returns:
The currently configured inlet pressure [bar].
- Return type:
float
- set_inlet_pressure_for_gain_correction(pressure)[source]
Set the inlet pressure used for the pressure dependent controller gain.
Note
This value is stored permanently in the device, i.e. it persists after a device reset.
- Parameters:
pressure (float) – The new pressure [bar] to set.
- get_gas_temperature_compensation_enable()[source]
Get the state of the gas temperature compensation setting.
- Returns:
Whether the gas temperature compensation is enabled or not.
- Return type:
bool
- set_gas_temperature_compensation_enable(enable)[source]
Set the state of the gas temperature compensation setting.
If the gas temperature compensation is enabled, you’ll have to set the actual inlet gas temperature with the method
set_inlet_gas_temperature_for_compensation().Note
This value is stored permanently in the device, i.e. it persists after a device reset.
- Parameters:
enable (bool) – Whether the gas temperature compensation should be enabled or not.
- get_inlet_gas_temperature_for_compensation()[source]
Get the currently configured inlet gas temperature as used for the gas temperature compensation.
- Returns:
The currently configured inlet gas temperature [°C].
- Return type:
float
- set_inlet_gas_temperature_for_compensation(temperature)[source]
Set the inlet gas temperature used for the gas temperature compensation.
Note
This value is stored permanently in the device, i.e. it persists after a device reset.
- Parameters:
temperature (float) – The new temperature [°C] to set.
- measure_raw_flow()[source]
Measure the raw flow ticks.
- Returns:
Measured raw flow ticks.
- Return type:
int
- measure_temperature()[source]
Measure the sensor temperature.
- Returns:
Measured temperature [°C].
- Return type:
float
- measure_raw_thermal_conductivity(close_valve=True)[source]
Measure the raw thermal conductivity.
- Parameters:
close_valve (bool) – If
True(default), the valve will be forcibly closed for 500ms before measuring the thermal conductivity. This is needed to guarantee a correct and stable measurement. If you are sure that the valve is closed anyway, you could set this toFalseto speed up the measurement.- Returns:
Measured raw thermal conductivity ticks.
- Return type:
int
- get_number_of_calibrations()[source]
Get the number of possible calibrations. Each calibration can either contain a valid calibration or not. Use
get_calibration_validity()to determine which indices contain a valid calibration.- Returns:
The number of calibrations the device memory can hold.
- Return type:
int
- get_calibration_validity(index)[source]
Check whether there exists a valid calibration block at a specific index or not.
- Parameters:
index (int) – The index of the calibration to check.
- Returns:
Whether at the specified index exists a valid calibration block or not.
- Return type:
bool
- get_calibration_gas_description(index)[source]
Get the gas description of a specific calibration index.
- Parameters:
index (int) – The index of the calibration to read from.
- Returns:
Gas description string.
- Return type:
str
- get_calibration_gas_id(index)[source]
Get the gas ID of a specific calibration index.
- Parameters:
index (int) – The index of the calibration to read from.
- Returns:
Gas ID.
- Return type:
int
- get_calibration_gas_unit(index)[source]
Get the gas unit of a specific calibration index.
- Parameters:
index (int) – The index of the calibration to read from.
- Returns:
Gas unit.
- Return type:
- get_calibration_fullscale(index)[source]
Get the fullscale flow of a specific calibration index.
- Parameters:
index (int) – The index of the calibration to read from.
- Returns:
Fullscale flow in the unit of the calibration.
- Return type:
float
- get_calibration_initial_conditions(index)[source]
Get the initial calibration conditions of a specific calibration index.
- Parameters:
index (int) – The index of the calibration to read from.
- Returns:
Initial calibration conditions.
- Return type:
- get_calibration_recalibration_conditions(index)[source]
Get the recalibration conditions of a specific calibration index.
- Parameters:
index (int) – The index of the calibration to read from.
- Returns:
Recalibration conditions.
- Return type:
- get_calibration_thermal_conductivity_reference(index)[source]
Get the thermal conductivity reference value of a specific calibration index.
- Parameters:
index (int) – The index of the calibration to read from.
- Returns:
Thermal conductivity reference value ticks.
- Return type:
int
- get_current_gas_description()[source]
Get the gas description of the currently active calibration.
- Returns:
Gas description string.
- Return type:
str
- get_current_gas_id()[source]
Get the gas ID of the currently active calibration.
- Returns:
Gas ID.
- Return type:
int
- get_current_gas_unit()[source]
Get the gas unit of the currently active calibration.
- Returns:
Gas unit.
- Return type:
- get_current_fullscale()[source]
Get the fullscale flow of the currently active calibration.
- Returns:
Fullscale flow in the unit of the calibration.
- Return type:
float
- get_current_initial_calibration_conditions()[source]
Get the initial calibration conditions of the currently active calibration.
- Returns:
Initial calibration conditions.
- Return type:
- get_current_recalibration_conditions()[source]
Get the recalibration conditions of the currently active calibration.
- Returns:
Recalibration conditions.
- Return type:
- get_current_thermal_conductivity_reference()[source]
Get the thermal conductivity reference value of the currently active calibration.
- Returns:
Thermal conductivity reference value ticks.
- Return type:
int
- activate_calibration(index)[source]
Activate a specific gas calibration block and run the flow controller.
- Parameters:
index (int) – The index of the calibration to activate.
- read_user_memory(address, length)[source]
Read data from the user memory.
- Parameters:
address (int) – The address to read from.
length (int) – Number of bytes to read.
- Returns:
The read data.
- Return type:
bytes
- write_user_memory(address, data)[source]
Write data to the user memory.
- Parameters:
address (int) – The address to write to.
data (bytes-like) – Data to write.
- update_firmware(image, emergency=False, status_callback=None, progress_callback=None)[source]
Update the firmware on the device.
This method allows you to download a new firmware (provided as a *.hex file) to the device. A device reset is performed after the firmware update.
Note
This can take several minutes, don’t abort it! If aborted, the device stays in the bootloader and you need to restart the update with
emergency=Trueto recover.Warning
If the Sfc5xxx is connected through RS485 together with other SHDLC devices on the same bus, make sure that no other device has the slave address 0 and baudrate 115200! These connection settings are used by the bootloader and thus two devices would respond to the bootloader commands. If an update fails because of this, you will have to disconnect the other device with address 0 and do an emergency update to recover this device.
- Parameters:
image – The image to flash, either as a :py:
Sfc5xxxFirmwareImageobject, a file-like object, or the filename (str) to the *.hex file.emergency (bool) – Must be set to
Trueif the device is already in bootloader mode,Falseotherwise.status_callback (callable) – Optional callback for status report, taking a string as parameter.
progress_callback (callable) – Optional callback for progress report, taking a float as parameter (progress in percent).
- Raises:
ShdlcFirmwareImageIncompatibilityError – If the image is not compatible with the connected device.
Exception – On other errors.
Sfc5xxxFirmwareImage
Definitions
Sfc5xxxScaling
- class Sfc5xxxScaling(value)[source]
An enum containing all available scaling variants with their corresponding byte values how they are transmitted over SHDLC.
- NORMALIZED = 0
Normalized to range [0…1].
- PHYSICAL = 1
Physical value with unit and fullscale of calibration.
- USER_DEFINED = 2
User defined unit and scaling as configured.
Sfc5xxxValveInputSource
- class Sfc5xxxValveInputSource(value)[source]
An enum containing all available valve input sources with their corresponding byte values how they are transmitted over SHDLC.
- CONTROLLER = 0
Driven by the flow controller (default).
- FORCE_CLOSED = 1
Force closed (valve remains fully closed).
- FORCE_OPEN = 2
Force open (valve remains fully open).
- HOLD = 3
Hold the voltage on the valve.
- USER_DEFINED = 16
Apply user defined value (needs to be configured!).
Units
Sfc5xxxUnitPrefix
- class Sfc5xxxUnitPrefix(value)[source]
An enum containing all available medium unit prefixes with their corresponding byte values how they are transmitted over SHDLC.
- YOCTO = -24
Yocto (10^-24).
- ZEPTO = -21
Zepto (10^-21).
- ATTO = -18
Atto (10^-18).
- FEMTO = -15
Femto (10^-15).
- PICO = -12
Pico (10^-12).
- NANO = -9
Nano (10^-9).
- MICRO = -6
Micro (10^-6).
- MILLI = -3
Milli (10^-3).
- CENTI = -2
Centi (10^-2).
- DECI = -1
Deci (10^-1).
- ONE = 0
No prefix (10^0).
- DECA = 1
Deca (10^1).
- HECTO = 2
Hecto (10^2).
- KILO = 3
Kilo (10^3).
- MEGA = 6
Mega (10^6).
- GIGA = 9
Giga (10^9).
- TERA = 12
Tera (10^12).
- PETA = 15
Peta (10^15).
- EXA = 18
Exa (10^18).
- ZETTA = 21
Zetta (10^21).
- YOTTA = 24
Yotta (10^24).
- UNDEFINED = 127
Undefined.
- __init__(value, description, symbol)[source]
Constructor
- Parameters:
value (int) – The integer value.
description (str) – The prefix description.
symbol (str) – The prefix symbol.
- description
The prefix description (str).
- symbol
The prefix symbol (str).
Sfc5xxxUnit
- class Sfc5xxxUnit(value)[source]
An enum containing all available medium units with their corresponding byte values how they are transmitted over SHDLC.
- NORM_LITER = 0
Norm Liter (0°C, 1013hPa)
- STANDARD_LITER = 1
Standard Liter (20°C, 1013hPa)
- STANDARD_LITER_15C = 2
Standard Liter (15°C, 1013hPa)
- STANDARD_LITER_25C = 3
Standard Liter (25°C, 1013hPa)
- STANDARD_LITER_70F = 4
Standard Liter (70°F, 1013hPa)
- LITER_LIQUI = 8
Liter (liqui).
- GRAM = 9
Gram (g).
- PASCAL = 16
Pascal (Pa).
- BAR = 17
Bar.
- METER_H2O = 18
Meter H2O (mH2O).
- INCH_H2O = 19
Inch H2O (iH2O).
- PERCENT = 250
Percent (%).
- PERMIL = 251
Permil (‰).
- INT8 = 252
8-Bit Signed Integer.
- INT16 = 253
16-Bit Signed Integer.
- INT32 = 254
32-Bit Signed Integer.
- UNDEFINED = 255
Undefined.
- __init__(value, description, symbol)[source]
Constructor
- Parameters:
value (int) – The integer value.
description (str) – The unit description.
symbol (str) – The unit symbol.
Sfc5xxxUnitTimeBase
- class Sfc5xxxUnitTimeBase(value)[source]
An enum containing all available medium unit time bases with their corresponding byte values how they are transmitted over SHDLC.
- NONE = 0
No Time Base.
- MICROSECOND = 1
Microsecond (µs).
- MILLISECOND = 2
Millisecond (ms).
- SECOND = 3
Second (s).
- MINUTE = 4
Minute (min).
- HOUR = 5
Hour (h).
- DAY = 6
Day.
- UNDEFINED = 255
Undefined.
- __init__(value, description, symbol)[source]
Constructor
- Parameters:
value (int) – The integer value.
description (str) – The timebase description.
symbol (str) – The timebase symbol.
Sfc5xxxMediumUnit
- class Sfc5xxxMediumUnit(prefix, unit, timebase)[source]
A class representing the medium unit specification used by various SHDLC commands. It consists of three members:
Prefix (
Sfc5xxxUnitPrefix)Physical Unit (
Sfc5xxxUnit)Unit Timebase (
Sfc5xxxUnitTimeBase)
- __init__(prefix, unit, timebase)[source]
Constructor.
- Parameters:
prefix (Sfc5xxxUnitPrefix) – The unit prefix.
unit (Sfc5xxxUnit) – The physical unit.
timebase (Sfc5xxxUnitTimeBase) – The unit time base.
- prefix
Unit prefix (
Sfc5xxxUnitPrefix).
- unit
Physical unit (
Sfc5xxxUnit).
- timebase
Unit timebase (
Sfc5xxxUnitTimeBase).
Types
Sfc5xxxCalibrationConditions
- class Sfc5xxxCalibrationConditions(company, operator, datetime, temperature, inlet_pressure, differential_pressure, is_real_gas_calibration, accuracy_setpoint, accuracy_fullscale)[source]
A class representing the calibration condition parameters as used to store the initial calibration conditions and recalibration conditions of gas calibration blocks.
The class provides some public members which you can access directly.
- __init__(company, operator, datetime, temperature, inlet_pressure, differential_pressure, is_real_gas_calibration, accuracy_setpoint, accuracy_fullscale)[source]
Constructor.
- Parameters:
company (str) – The company which has created the calibration.
operator (str) – The operator who has created the calibration.
datetime (datetime) – Date and time when the calibration was created.
temperature (float) – System/gas temperature [°C].
inlet_pressure (float) – Absolute pressure of gas inlet [bar].
differential_pressure (float) – Pressure difference between inlet and outlet [bar].
is_real_gas_calibration (bool) – Whether the calibration was performed with the real process gas (true) or if it was calculated from a different gas (false).
accuracy_setpoint (float) – Calibration accuracy in percent of the setpoint.
accuracy_fullscale (float) – Calibration accuracy in percent of fullscale.
- company
The company which has created the calibration (str).
- operator
The operator who has created the calibration (str).
- datetime
Date and time when the calibration was created (datetime).
- temperature
System/gas temperature [°C] (float).
- inlet_pressure
Absolute pressure [bar] of gas inlet (float).
- differential_pressure
Pressure difference [bar] between inlet and outlet (float).
- is_real_gas_calibration
Whether the calibration was performed with the real process gas (true) or if it was calculated from a different gas (false).
- accuracy_setpoint
Calibration accuracy in percent of the setpoint (float).
- accuracy_fullscale
Calibration accuracy in percent of fullscale (float).
Sfc5xxxReadBufferResponse
- class Sfc5xxxReadBufferResponse(scaling, read_count, lost_values, remaining_values, sampling_time, values)[source]
Helper class representing the response to the “read measured value buffer” command, i.e. of the method
read_measured_value_buffer().The class provides some public members which you can access directly.
- __init__(scaling, read_count, lost_values, remaining_values, sampling_time, values)[source]
Creates an instance from the data received from the device.
- Parameters:
scaling (Sfc5xxxScaling) – With which scale resp. unit the measured flow was read (parameter sent to the “read measured value buffer” command).
read_count (int) – How many times the “read measured value buffer” was executed to fetch the values contained in this object.
lost_values (int) – Number of lost values (received from the “read measured value buffer” command).
remaining_values (int) – Number of values remaining in the buffer (received from the last “read measured value buffer” command).
sampling_time (float) – The sampling time of the measured values in Seconds (received from the “read measured value buffer” command).
values (list(float)) – The measured values read from the buffer (received from the “read measured value buffer” command).
- scaling
The scaling of the measured values (
Sfc5xxxScaling).
- read_count
How many times the “read measured value buffer” was executed to fetch the values contained in this object (int).
- lost_values
Number of lost values due to buffer overrun (int).
- remaining_values
Number of values remaining in the buffer after reading it (int). If the whole buffer was read out, this is zero.
- sampling_time
The sampling time of the measured values in Seconds (float).
- values
The measured values read from the buffer (list of float).
Device Errors
- exception Sfc5xxxFunctionalityNotImplementedError[source]
The requested functionality is not implemented (yet) on the device.
- exception Sfc5xxxNvmAddressOutOfRangeError[source]
Address of is outside of the non-volatile memory address space.
- exception Sfc5xxxFrameChecksumError[source]
Frame checksum mismatch detected. If this error occurs, no MISO frame will be sent (internal error only).
- exception Sfc5xxxFrameCompositionError[source]
Illegal frame composition. Probably wrong data size for given subcommand.
- exception Sfc5xxxNoBroadcastResponseAvailableError[source]
Triggered a broadcast response, but no valid response is available at the moment.
- exception Sfc5xxxModifySignalProcessorError[source]
Not possible to modify signal processor while startup or shut down.
- exception Sfc5xxxInvalidCalibrationIndexError[source]
No valid gas calibration block at given index.
- exception Sfc5xxxI2cStartConditionError[source]
I2C lines (SCL or SDA) low before sending start condition.
- exception Sfc5xxxExternalOscillatorStartupError[source]
Could not startup external oscillator. System now runs with internal oscillator (+/- 1%).
- exception Sfc5xxxCommunicationAdapterNotAvailableError[source]
The requested type of communication adapter is not available.
- exception Sfc5xxxCommandNotAllowedInCurrentStateError[source]
This command is not allowed in the current state of the device.
Commands
Sfc5xxxCmdActivateCalibration
- class Sfc5xxxCmdActivateCalibration(index)[source]
Activate Calibration Command
This command loads a calibration from calibration memory and runs the flow controller. If the specified calibration is already active, this command does nothing. The active calibration is stored in non-volatile memory and will automatically be re-activated after a device reset.
Note
Caution: This command will cause a write operation in an EEPROM. Because of the limited write cycles of the EEPROM, this command should not be called periodical (max 50’000 times with a new calibration). Loading the same calibration again is not a problem and will not cause a write operation.
Sfc5xxxCmdMeasureRawFlow
Sfc5xxxCmdMeasureRawThermalConductivity
Sfc5xxxCmdMeasureRawThermalConductivityWithClosedValve
- class Sfc5xxxCmdMeasureRawThermalConductivityWithClosedValve(use_temperature_compensation=None)[source]
Measure Raw Thermal Conductivity With Closed Valve Command
Perform a thermal conductivity measurement and return the measured raw tick value. The valve is automatically closed during the measurement.
Sfc5xxxCmdMeasureTemperature
Sfc5xxxCmdGetBaudrate
Sfc5xxxCmdSetBaudrate
Sfc5xxxCmdGetUserControllerGain
Sfc5xxxCmdSetUserControllerGain
Sfc5xxxCmdGetPressureDependentGainEnable
Sfc5xxxCmdSetPressureDependentGainEnable
Sfc5xxxCmdGetInletPressureForGainCorrection
Sfc5xxxCmdSetInletPressureForGainCorrection
Sfc5xxxCmdGetGasTemperatureCompensationEnable
Sfc5xxxCmdSetGasTemperatureCompensationEnable
Sfc5xxxCmdGetInletGasTemperatureForCompensation
Sfc5xxxCmdSetInletGasTemperatureForCompensation
- class Sfc5xxxCmdSetInletGasTemperatureForCompensation(temperature)[source]
Set Inlet Gas Temperature For Compensation Command
Set the inlet gas temperature used for the temperature compensation.
Note
This configuration is stored in non-volatile memory of the device and thus persists after a device reset.
Sfc5xxxCmdGetProductType
Sfc5xxxCmdGetProductName
Sfc5xxxCmdGetArticleCode
Sfc5xxxCmdGetSerialNumber
Sfc5xxxCmdGetProductSubtype
Sfc5xxxCmdDeviceReset
- class Sfc5xxxCmdDeviceReset[source]
Device Reset Command
Resets the device. This command has the same effect as a power-reset.
Note
The device will reply before executing the reset. After the response is sent, the device needs some time until it is ready for communication again (see post processing time). If the command is sent with broadcast, the reset is done directly after the reception of the command.
Sfc5xxxCmdFactoryReset
- class Sfc5xxxCmdFactoryReset[source]
Factory Reset Command
Perform a factory reset which will restore the off-the-shelf factory configuration. In addition, a device reset will be performed after restoring the factory configuration.
Note
This resets any configuration done after leaving the factory! Keep in mind that this command might also change communication parameters (i.e. baudrate and slave address) and thus you might have to adjust the driver’s parameters to allow further communication with the device.
Sfc5xxxCmdGetNumberOfCalibrations
- class Sfc5xxxCmdGetNumberOfCalibrations[source]
Get Number Of Calibrations Command
Get the number of calibrations, i.e. how many calibration blocks the device memory is able to hold.
Note
Not all calibration blocks actually contain a valid gas calibration. Use the command Get Calibration Validity to check which calibrations are valid and thus can be activated.
Sfc5xxxCmdGetCalibrationValidity
Sfc5xxxCmdGetCalibrationGasDescription
Sfc5xxxCmdGetCalibrationGasId
Sfc5xxxCmdGetCalibrationGasUnit
Sfc5xxxCmdGetCalibrationFullscale
Sfc5xxxCmdGetCalibrationInitialConditions
- class Sfc5xxxCmdGetCalibrationInitialConditions(index)[source]
Get Calibration Initial Conditions Command
Get the initial calibration conditions of a specific calibration index.
- static interpret_response(data)[source]
- Returns:
company (str) - The company which has created the calibration.
operator (str) - The operator who has created the calibration.
year (int) - Year of the calibration date.
month (int) - Month of the calibration date.
day (int) - Day of the calibration date.
hour (int) - Hour of the calibration time.
minute (int) - Minute of the calibration time.
temperature (float) - System/gas temperature [°C] of calibration.
inlet_pressure (float) - Absolute pressure of gas inlet [bar].
differential_pressure (float) - Pressure difference between inlet and outlet [bar].
is_real_gas_calibration (bool) - Whether the calibration was performed with the real process gas (true) or if it was calculated from a different gas (false).
accuracy_setpoint (float) - Calibration accuracy in percent of the setpoint. This accuracy is valid if larger than the accuracy of fullscale.
accuracy_fullscale (float) - Calibration accuracy in percent of fullscale. This value is valid if larger than the accuracy of the setpoint.
- Return type:
tuple
Sfc5xxxCmdGetCalibrationRecalibrationConditions
- class Sfc5xxxCmdGetCalibrationRecalibrationConditions(index)[source]
Get Calibration Recalibration Conditions Command
Get the recalibration conditions of a specific calibration index.
- static interpret_response(data)[source]
- Returns:
company (str) - The company which has created the recalibration.
operator (str) - The operator who has created the recalibration.
year (int) - Year of the recalibration date.
month (int) - Month of the recalibration date.
day (int) - Day of the recalibration date.
hour (int) - Hour of the recalibration time.
minute (int) - Minute of the recalibration time.
temperature (float) - System/gas temperature [°C] of recalibration.
inlet_pressure (float) - Absolute pressure of gas inlet [bar].
differential_pressure (float) - Pressure difference between inlet and outlet [bar].
is_real_gas_calibration (bool) - Whether the recalibration was performed with the real process gas (true) or if it was calculated from a different gas (false).
accuracy_setpoint (float) - Calibration accuracy in percent of the setpoint. This accuracy is valid if larger than the accuracy of fullscale.
accuracy_fullscale (float) - Calibration accuracy in percent of fullscale. This value is valid if larger than the accuracy of the setpoint.
- Return type:
tuple
Sfc5xxxCmdGetCalibrationThermalConductivityReference
Sfc5xxxCmdGetCurrentGasDescription
Sfc5xxxCmdGetCurrentGasId
Sfc5xxxCmdGetCurrentGasUnit
Sfc5xxxCmdGetCurrentFullscale
Sfc5xxxCmdGetCurrentInitialCalibrationConditions
- class Sfc5xxxCmdGetCurrentInitialCalibrationConditions[source]
Get Current Initial Calibration Conditions Command
Get the initial calibration conditions of the currently active calibration.
- static interpret_response(data)[source]
- Returns:
company (str) - The company which has created the calibration.
operator (str) - The operator who has created the calibration.
year (int) - Year of the calibration date.
month (int) - Month of the calibration date.
day (int) - Day of the calibration date.
hour (int) - Hour of the calibration time.
minute (int) - Minute of the calibration time.
temperature (float) - System/gas temperature [°C] of calibration.
inlet_pressure (float) - Absolute pressure of gas inlet [bar].
differential_pressure (float) - Pressure difference between inlet and outlet [bar].
is_real_gas_calibration (bool) - Whether the calibration was performed with the real process gas (true) or if it was calculated from a different gas (false).
accuracy_setpoint (float) - Calibration accuracy in percent of the setpoint. This accuracy is valid if larger than the accuracy of fullscale.
accuracy_fullscale (float) - Calibration accuracy in percent of fullscale. This value is valid if larger than the accuracy of the setpoint.
- Return type:
tuple
Sfc5xxxCmdGetCurrentRecalibrationConditions
- class Sfc5xxxCmdGetCurrentRecalibrationConditions[source]
Get Current Recalibration Conditions Command
Get the recalibration conditions of the currently active calibration.
- static interpret_response(data)[source]
- Returns:
company (str) - The company which has created the recalibration.
operator (str) - The operator who has created the recalibration.
year (int) - Year of the recalibration date.
month (int) - Month of the recalibration date.
day (int) - Day of the recalibration date.
hour (int) - Hour of the recalibration time.
minute (int) - Minute of the recalibration time.
temperature (float) - System/gas temperature [°C] of recalibration.
inlet_pressure (float) - Absolute pressure of gas inlet [bar].
differential_pressure (float) - Pressure difference between inlet and outlet [bar].
is_real_gas_calibration (bool) - Whether the recalibration was performed with the real process gas (true) or if it was calculated from a different gas (false).
accuracy_setpoint (float) - Calibration accuracy in percent of the setpoint. This accuracy is valid if larger than the accuracy of fullscale.
accuracy_fullscale (float) - Calibration accuracy in percent of fullscale. This value is valid if larger than the accuracy of the setpoint.
- Return type:
tuple
Sfc5xxxCmdGetCurrentThermalConductivityReference
Sfc5xxxCmdGetVersion
- class Sfc5xxxCmdGetVersion[source]
Get Version Command
Get the version information for the hardware, firmware and SHDLC protocol.
- static interpret_response(data)[source]
- Returns:
firmware_major (int) - Firmware major version number.
firmware_minor (int) - Firmware minor version number.
firmware_debug (bool) - Firmware debug state. All officially released and delivered firmware versions have this set to false (i.e. 0x00).
hardware_major (int) - Hardware major version number.
hardware_minor (int) - Hardware minor version number.
protocol_major (int) - Protocol major version number.
protocol_minor (int) - Protocol minor version number.
- Return type:
tuple
Sfc5xxxCmdGetUserDefinedMediumUnit
- class Sfc5xxxCmdGetUserDefinedMediumUnit[source]
Get User Defined Medium Unit Command
Get the user defined medium unit.
- static interpret_response(data)[source]
- Returns:
prefix (int) - Medium unit prefix, see appendix for encoding. 0x7F = Use medium unit prefix from calibration.
unit (int) - Medium unit, see appendix for encoding. 0xFF = Use medium unit from calibration.
timebase (int) - Timebase, see appendix for encoding. 0xFF = Use timebase from calibration.
- Return type:
tuple
Sfc5xxxCmdSetUserDefinedMediumUnit
Sfc5xxxCmdGetUserDefinedMediumUnitWithoutWildcards
Sfc5xxxCmdGetUserDefinedFullscale
Sfc5xxxCmdReadDeviceStatus
- class Sfc5xxxCmdReadDeviceStatus(clear)[source]
Read Device Status Command
Read the current device status.
Note
When the device is running, some error situations can be detected. These errors will be memorized as flags in the state register of the device. If one or more of the error flags are set, this will be signalized to the master by setting the “Device Error Flag” in the state information byte of the MISO frame (see frame description). With this command you can readout the state register containing the 32 flags. Find a list of all flags in the appendix.
- static interpret_response(data)[source]
- Returns:
device_status (int) - The device status as a register where 32 independent flags can be signalized. The meaning of the bits is defined in the appendix.
boot_error (int) - If an error occurred during system boot, this will be marked by setting flag #0 in the status register. In addition to the flag, this error code defines what exactly went wrong.
- Return type:
tuple
Sfc5xxxCmdReadMeasuredValue
Sfc5xxxCmdReadMeasuredValueBuffer
- class Sfc5xxxCmdReadMeasuredValueBuffer(scaling)[source]
Read Measured Value Buffer Command
The MFC has an internal ring buffer in which the measured flow values are automatically stored in a regular interval. The size of the buffer is between 85 and 256 (depends on the specific device configuration). With this command you can readout the buffered values (maximum 60 values per transfer, due to the limited space in the data part of the SHDLC frame). If you do not readout the buffer or you are too slow with reading, the oldest values will be lost.
Note
The values which have been read will automatically be cleared from the ring buffer.
- static interpret_response(data)[source]
- Returns:
lost_value_count (int) - If the time between the “Read Measured Value Buffer” command calls is to large, the internal ring buffer will overrun. In this case, the oldest value in the buffer is cleared when a new value enters. This number is a counter which counts the missing values between the function calls (number of values which were not readout by the bus master).
remaining_value_count (int) - The number of values which remains in the buffer after this command call (the number of returned values is limited to 60 values because the maximum allowed data part in the SHDLC frame is 255 bytes).
sampling_time (float) - Time between the measured values in Seconds.
measured_values (list(float)) - The measured values read from the ring buffer (0…60 values) with the specified scaling.
- Return type:
tuple
Sfc5xxxCmdGetReplyDelay
Sfc5xxxCmdSetReplyDelay
Sfc5xxxCmdSetSetpointAndReadMeasuredValue
- class Sfc5xxxCmdSetSetpointAndReadMeasuredValue(scaling, setpoint)[source]
Set Setpoint And Read Measured Value Command
This command is a combination of the two commands “Set Setpoint (0x00)” and “Read Measured Value (0x08)”. It is intended for process data exchange (setpoint and flow) and safes a lot of protocol overhead compared to separate command usage.
Note
If the “setpoint persists” feature is enabled, the setpoint will be stored in non-volatile memory and re-applied after a device reset.
Sfc5xxxCmdGetSetpoint
Sfc5xxxCmdSetSetpoint
Sfc5xxxCmdSetSetpointPersist
- class Sfc5xxxCmdSetSetpointPersist(persist)[source]
Set Setpoint Persist Command
Allows to define if a setpoint should persist after a reset (soft or hardreset) or if it should be set to zero.
Note
This configuration is stored in non-volatile memory of the device and thus persists after a device reset.
Sfc5xxxCmdGetSetpointPersist
Sfc5xxxCmdGetSlaveAddress
Sfc5xxxCmdSetSlaveAddress
- class Sfc5xxxCmdSetSlaveAddress(slave_address)[source]
Set Slave Address Command
Set the SHDLC slave address of the device.
Note
The slave address is stored in non-volatile memory of the device and thus persists after a device reset. So the next time connecting to the device, you have to use the new address. When changing the address of a slave, make sure there isn’t already a slave with that address on the same bus! In that case you would get communication issues which can only be fixed by disconnecting one of the slaves.
Sfc5xxxCmdReadUserMemory
Sfc5xxxCmdWriteUserMemory
Sfc5xxxCmdGetValveInputSource
- class Sfc5xxxCmdGetValveInputSource[source]
Get Valve Input Source Command
Get the input source for the valve, i.e. the input which controls the valve voltage.
- static interpret_response(data)[source]
- Returns:
The current valve input source:
0x00: Controller (default), driven by the flow controller.
0x01: Force closed, valve remains fully closed.
0x02: Force open, valve remains fully open.
0x03: Hold, hold the voltage on the valve.
0x10: User defined, apply user defined value [0..1].
- Return type:
int