nidaqmx-python icon indicating copy to clipboard operation
nidaqmx-python copied to clipboard

Expose Shunt Calibration and Offset Nulling Calibration Functions in Bindings

Open kaliopelegend29 opened this issue 3 years ago • 3 comments

Shunt Cal and Offset Nulling Cal in LV Example

Requesting support for the equivalent to the above portion of the LabVIEW shipping example Bridge - Continuous Input.vi be exposed in the nidaqmx-python bindings. The above example shows the bridge calibration functions: DAQmx Perform Shunt Calibration.vi and DAQmx Perform Bridge Offset Nulling Calibration.vi.

Exposing bindings for bridge, strain, and thermocouple lead functions would be ideal.

It appears that someone else is interested in this functionality as well:

https://forums.ni.com/t5/Multifunction-DAQ/NiDaqmx-Python-Perform-Bridge-Offset-Nulling-Calibration/td-p/4166367

Based on some cursory digging, the necessary functions are exported in the c library:

C library functions

kaliopelegend29 avatar Sep 02 '22 14:09 kaliopelegend29

We aren't planning on adding device calibration support, and these entrypoints were caught up in that decision. I agree that they should be added. There isn't any plan to do that in the near-term, so if you wanted to contribute - feel free!

zhindes avatar Sep 19 '22 16:09 zhindes

Is there any chance this has changed in the last 6 months? I'm working on a cDAQ system with strain gauges, the offset nulling and shunt calibration are critical features for us.

nicjohnston avatar Mar 07 '23 23:03 nicjohnston

Sorry, no change. However, you could do this yourself, if you wanted. Under the hood we use ctypes to load the nidaqmx DLL and call functions on it. You can see how we load it in _import_lib. We call functions directly on that ctypes object. For example, here is where we call DAQmxCreateAIAccel4WireDCVoltageChan on the DLL. You can see that we define the function types and call it.

cfunc = lib_importer.windll.DAQmxCreateAIAccel4WireDCVoltageChan
if cfunc.argtypes is None:
    with cfunc.arglock:
        if cfunc.argtypes is None:
            cfunc.argtypes = [
                lib_importer.task_handle, ctypes_byte_str,
                ctypes_byte_str, ctypes.c_int, ctypes.c_double,
                ctypes.c_double, ctypes.c_int, ctypes.c_double,
                ctypes.c_int, ctypes.c_int, ctypes.c_double, c_bool32,
                ctypes_byte_str]

error_code = cfunc(
    self._handle, physical_channel, name_to_assign_to_channel,
    terminal_config.value, min_val, max_val, units.value, sensitivity,
    sensitivity_units.value, voltage_excit_source.value,
    voltage_excit_val, use_excit_for_scaling, custom_scale_name)

For the functions you care about, you can look at the NIDAQmx.h header file for their signature.

int32 __CFUNC     DAQmxPerformBridgeOffsetNullingCal(TaskHandle taskHandle, const char channel[]);
int32 __CFUNC     DAQmxPerformBridgeOffsetNullingCalEx(TaskHandle taskHandle, const char channel[], bool32 skipUnsupportedChannels);
int32 __CFUNC     DAQmxPerformThrmcplLeadOffsetNullingCal(TaskHandle taskHandle, const char channel[], bool32 skipUnsupportedChannels);
// Note: This function is deprecated.  Use DAQmxPerformStrainShuntCalEx instead.
int32 __CFUNC     DAQmxPerformStrainShuntCal     (TaskHandle taskHandle, const char channel[], float64 shuntResistorValue, int32 shuntResistorLocation, bool32 skipUnsupportedChannels);
int32 __CFUNC     DAQmxPerformStrainShuntCalEx   (TaskHandle taskHandle, const char channel[], float64 shuntResistorValue, int32 shuntResistorLocation, int32 shuntResistorSelect, int32 shuntResistorSource, bool32 skipUnsupportedChannels);
// Note: This function is deprecated.  Use DAQmxPerformBridgeShuntCalEx instead.
int32 __CFUNC     DAQmxPerformBridgeShuntCal     (TaskHandle taskHandle, const char channel[], float64 shuntResistorValue, int32 shuntResistorLocation, float64 bridgeResistance, bool32 skipUnsupportedChannels);
int32 __CFUNC     DAQmxPerformBridgeShuntCalEx   (TaskHandle taskHandle, const char channel[], float64 shuntResistorValue, int32 shuntResistorLocation, int32 shuntResistorSelect, int32 shuntResistorSource, float64 bridgeResistance, bool32 skipUnsupportedChannels);

zhindes avatar Mar 08 '23 17:03 zhindes