Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose Shunt Calibration and Offset Nulling Calibration Functions in Bindings #188

Open
kaliopelegend29 opened this issue Sep 2, 2022 · 3 comments · Fixed by #468 or #469
Open

Comments

@kaliopelegend29
Copy link

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

@zhindes
Copy link
Collaborator

zhindes commented Sep 19, 2022

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!

@nicjohnston
Copy link

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.

@zhindes
Copy link
Collaborator

zhindes commented Mar 8, 2023

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants