|
STAR
Cal STAR — firmware, DAQ server, and engine design
|
Functions | |
| int | _uint32_to_int32 (int u) |
| Optional[float] | k_type_voltage_to_temp_c (float v_volts) |
| Optional[float] | k_type_adc_to_temp_c (int adc_code, float adc_ref_voltage=2.5, float adc_full_scale=ADC32_FULL_SCALE) |
| Optional[float] | rtd_resistance_to_temp_c (float r_ohm, float r0=PT1000_R0) |
| Optional[float] | rtd_voltage_to_temp_c (float v_volts, float r0=PT1000_R0, float excitation_ua=RTD_EXCITATION_UA) |
| Optional[float] | raw_rtd_to_temp_c (float raw_value, float r0=PT100_R0, float scale_to_ohms=0.001) |
| Optional[float] | raw_rtd_adc_to_temp_c (int adc_code, float r0=PT1000_R0, float excitation_ua=RTD_EXCITATION_UA, float adc_ref_voltage=2.5, float adc_full_scale=ADC32_FULL_SCALE) |
| Optional[float] | code_to_force (int code_uint32, float sensitivity_mv_per_v, float pga_gain, float full_scale_value) |
| Optional[list[float]] | _load_pt_polynomial (int channel_id) |
| float | hp_pt_adc_to_psi (int adc_code, float full_scale_psi, float sense_resistor_ohms, float adc_ref_voltage=2.5) |
| Optional[float] | pt_adc_to_psi (int adc_code, int channel_id) |
| Optional[float] | raw_to_physical (str stype, int raw_value, *, Optional[int] channel_id=None, float rtd_r0=PT1000_R0, float rtd_adc_ref_v=2.5, float rtd_excitation_ua=RTD_EXCITATION_UA, float tc_adc_ref_v=2.5, float lc_sensitivity_mv_per_v=2.0, float lc_pga_gain=128.0, float lc_full_scale_value=100.0) |
Variables | |
| list | K_TYPE_INVERSE |
| float | PT_A = 3.9083e-3 |
| float | PT_B = -5.775e-7 |
| float | PT1000_R0 = 1000.0 |
| float | PT100_R0 = 100.0 |
| float | RTD_EXCITATION_UA = 1000.0 |
| float | ADC32_FULL_SCALE = 2147483648.0 |
Sense conversions: K-type thermocouple, Pt100/Pt1000 RTD, load cell. Ported from diablo_server/frontend/lib/sense-conversions.ts (DiabloAvionics sense_testing_gui.py). Used by calibration_server.py as fallback when RobustCalibrationFramework has no calibration points, or for quick raw→physical conversion. Single source of truth for calibration service.
|
protected |
Load calibration polynomial coefficients [A, B, C, D] for a PT channel from the latest JSON file in tools/calibration/calibrations/. Polynomial: psi = A*adc^3 + B*adc^2 + C*adc + D
Definition at line 231 of file sense_conversions.py.
Referenced by pt_adc_to_psi().
|
protected |
Interpret uint32 as int32 (for 32-bit signed ADC codes).
Definition at line 97 of file sense_conversions.py.
Referenced by code_to_force(), k_type_adc_to_temp_c(), and raw_rtd_adc_to_temp_c().
| Optional[float] sense_conversions.code_to_force | ( | int | code_uint32, |
| float | sensitivity_mv_per_v, | ||
| float | pga_gain, | ||
| float | full_scale_value ) |
Ratiometric load-cell force from raw 32-bit ADC code. Reference = excitation, so voltage cancels. full_scale_value is in desired units (e.g. lbf, kg). Returns None if invalid params.
Definition at line 207 of file sense_conversions.py.
References _uint32_to_int32().
Referenced by raw_to_physical().
| float sense_conversions.hp_pt_adc_to_psi | ( | int | adc_code, |
| float | full_scale_psi, | ||
| float | sense_resistor_ohms, | ||
| float | adc_ref_voltage = 2.5 ) |
4-20 mA HP PT: psi = (i_ma - 4) / 16 * full_scale_psi. v_sense = (adc/2^31)*adc_ref_voltage, i_ma = v_sense/sense_resistor_ohms * 1000. Wire codes are unsigned 0..2^31-1 (match FSW calibration_main convert_hp_pt_to_pressure).
Definition at line 261 of file sense_conversions.py.
| Optional[float] sense_conversions.k_type_adc_to_temp_c | ( | int | adc_code, |
| float | adc_ref_voltage = 2.5, | ||
| float | adc_full_scale = ADC32_FULL_SCALE ) |
Convert K-type TC raw ADC code to temperature (°C). Assumes 32-bit signed ADC: voltage = (adc / adc_full_scale) * adc_ref_voltage.
Definition at line 124 of file sense_conversions.py.
References _uint32_to_int32(), and k_type_voltage_to_temp_c().
Referenced by raw_to_physical().
| Optional[float] sense_conversions.k_type_voltage_to_temp_c | ( | float | v_volts | ) |
Convert K-type thermocouple voltage (V) to temperature (°C). Returns None if out of range.
Definition at line 106 of file sense_conversions.py.
Referenced by k_type_adc_to_temp_c().
| Optional[float] sense_conversions.pt_adc_to_psi | ( | int | adc_code, |
| int | channel_id ) |
Convert raw ADC code to PSI using the stored cubic calibration polynomial. Returns None if no calibration is available for the channel. Polynomial: psi = A*adc^3 + B*adc^2 + C*adc + D (coeffs[0..3] = A, B, C, D)
Definition at line 294 of file sense_conversions.py.
References _load_pt_polynomial().
Referenced by raw_to_physical().
| Optional[float] sense_conversions.raw_rtd_adc_to_temp_c | ( | int | adc_code, |
| float | r0 = PT1000_R0, | ||
| float | excitation_ua = RTD_EXCITATION_UA, | ||
| float | adc_ref_voltage = 2.5, | ||
| float | adc_full_scale = ADC32_FULL_SCALE ) |
Convert RTD raw ADC code to temperature (°C). Assumes ADC measures differential voltage across RTD with known excitation current.
Definition at line 188 of file sense_conversions.py.
References _uint32_to_int32(), and rtd_voltage_to_temp_c().
Referenced by raw_to_physical().
| Optional[float] sense_conversions.raw_rtd_to_temp_c | ( | float | raw_value, |
| float | r0 = PT100_R0, | ||
| float | scale_to_ohms = 0.001 ) |
Convert raw resistance counts (often 24-bit or 32-bit milliohms) to temperature (°C). Default assumes value is milliohms (scale_to_ohms=0.001).
Definition at line 173 of file sense_conversions.py.
References rtd_resistance_to_temp_c().
| Optional[float] sense_conversions.raw_to_physical | ( | str | stype, |
| int | raw_value, | ||
| * | , | ||
| Optional[int] | channel_id = None, | ||
| float | rtd_r0 = PT1000_R0, | ||
| float | rtd_adc_ref_v = 2.5, | ||
| float | rtd_excitation_ua = RTD_EXCITATION_UA, | ||
| float | tc_adc_ref_v = 2.5, | ||
| float | lc_sensitivity_mv_per_v = 2.0, | ||
| float | lc_pga_gain = 128.0, | ||
| float | lc_full_scale_value = 100.0 ) |
Convert raw value to physical unit by sensor type. Returns PSI for PT (if calibration available), °C for TC/RTD, force (lbf/kg) for LC, or None if conversion fails. RTD raw_value is ADC counts (not milliohms); uses raw_rtd_adc_to_temp_c.
Definition at line 308 of file sense_conversions.py.
References code_to_force(), k_type_adc_to_temp_c(), pt_adc_to_psi(), and raw_rtd_adc_to_temp_c().
| Optional[float] sense_conversions.rtd_resistance_to_temp_c | ( | float | r_ohm, |
| float | r0 = PT1000_R0 ) |
Convert RTD resistance (Ω) to temperature (°C). IEC 60751. Supports Pt100 (r0=100) and Pt1000 (r0=1000) via r0 parameter. Returns None if out of range.
Definition at line 141 of file sense_conversions.py.
Referenced by raw_rtd_to_temp_c(), and rtd_voltage_to_temp_c().
| Optional[float] sense_conversions.rtd_voltage_to_temp_c | ( | float | v_volts, |
| float | r0 = PT1000_R0, | ||
| float | excitation_ua = RTD_EXCITATION_UA ) |
Convert RTD differential voltage (V) to temperature (°C). excitation_ua = IDAC current in µA (default 1000).
Definition at line 158 of file sense_conversions.py.
References rtd_resistance_to_temp_c().
Referenced by raw_rtd_adc_to_temp_c().
| float sense_conversions.ADC32_FULL_SCALE = 2147483648.0 |
Definition at line 94 of file sense_conversions.py.
| list sense_conversions.K_TYPE_INVERSE |
Definition at line 19 of file sense_conversions.py.
| float sense_conversions.PT1000_R0 = 1000.0 |
Definition at line 90 of file sense_conversions.py.
| float sense_conversions.PT100_R0 = 100.0 |
Definition at line 91 of file sense_conversions.py.
| float sense_conversions.PT_A = 3.9083e-3 |
Definition at line 88 of file sense_conversions.py.
| float sense_conversions.PT_B = -5.775e-7 |
Definition at line 89 of file sense_conversions.py.
| float sense_conversions.RTD_EXCITATION_UA = 1000.0 |
Definition at line 92 of file sense_conversions.py.