05-04-2024 07:16 AM
Hi,
I have a PXI-1033 with PXI-4071, PXI-4130 and PXI-4022 cards. I installed ni-pxiplatformservices_20.5.0, ni-dcpower_20.6.0, ni-dmm_20.0.0, ni-serial_20.0.0, ni-visa_20.0.0 on Windows 7 Pro.
I control devices using Python. Two cards 4130 and 4071 work without problems. However, the PXI-4022 card is detected in NI MAX (screenshot), but I cannot use it. As if there was no full driver.
In Python I get the message from 4022: DriverError: -1074118656: Device was not recognized. The device is not supported with this driver or version.
Can you help me get PXI-4022 working properly in Python?
Andrew
CODE:
import nidcpower
import nidmm
import time
with nidcpower.Session(resource_name="Dev2", channels = 0, reset= False, options={'simulate': False, 'driver_setup': {'Model': '4130', 'BoardType': 'PXIe'}}, independent_channels=False, grpc_options=None) as sessionDEV1Ch0:
sessionDEV1Ch0.voltage_level = 0.0
sessionDEV1Ch0.commit()
measurement_type = (nidcpower.MeasurementTypes.VOLTAGE)
sessionDEV1Ch0.initiate()
time.sleep(1)
t = sessionDEV1Ch0.measure(measurement_type)
print ('Meas SMU ch0: ', t)
with nidcpower.Session(resource_name="Dev2", channels = 1, reset= False, options={'simulate': False, 'driver_setup': {'Model': '4130', 'BoardType': 'PXIe'}}, independent_channels=False, grpc_options=None) as sessionDEV1Ch1:
sessionDEV1Ch1.voltage_level = 0.0
sessionDEV1Ch1.commit()
measurement_type = (nidcpower.MeasurementTypes.VOLTAGE)
sessionDEV1Ch1.initiate()
time.sleep(1)
t = sessionDEV1Ch1.measure(measurement_type)
print ('Meas SMU ch1: ', t)
#
with nidmm.Session("Dev2") as sessionDEV2:
sessionDEV2.configure_measurement_digits(nidmm.Function.DC_VOLTS, 10.0, 7.5)
print("Meas 4071: " + str(sessionDEV2.read()))
with nidmm.Session("Dev3") as sessionDEV3:
sessionDEV3.configure_measurement_digits(nidmm.Function.DC_VOLTS, 10.0, 7.5)
print("Meas 4022: " + str(sessionDEV3.read()))
Solved! Go to Solution.
05-05-2024 06:53 PM
Based on the user manual of 4022 - https://download.ni.com/support/manuals/374305c.pdf
There is some active circuit with limited control options that uses NI DMM driver (precisely only one).
As per your image, Dev3 is the 4022, and in your code, you init and try to read from Dev3, whereas Dev3 does not have DMM functionality.
What you must be doing is, connect the 4022 with your DUT, and DMM (4071). In your code, configure 4022 in the mode of choice and read the measurement using your 4071.
05-06-2024 07:31 AM - edited 05-06-2024 07:32 AM
Thank you Santhosh for your help. It's works. I connected it to the 4071 card and I receive a voltage signal at its input.
However, I have a problem with configuring the ranges. Can you give me an example of 4022 card configuration in a given range, e.g. 100nA? I can't write this in Python code.
05-06-2024 09:20 AM
The PXI-4022 is not supported by the nidmm Python module.
In order to control it via Python you will need to call the raw C function niDMM_4022Control(). Python offers multiple mechanisms for this, e.g. ctypes. The library is nidmm_64.dll (assuming 64-bit Windows process), libnidmm.so (Linux), nidmm_32.dll (Windows 32-bit).
Now, why is it not supported in the nidmm Python module? The PXI-4022 uses only this single function and does not adhere to the session mechanisms that all other devices supported by the NI-DMM driver do. It's not an IVI-compliant instrument, and it does not need to be. For reasons lost to time it was added to the NI-DMM driver, when it should more properly have had its own separate driver.
05-06-2024 09:42 AM
Now, why is it not supported in the nidmm Python module? The PXI-4022 uses only this single function and does not adhere to the session mechanisms that all other devices supported by the NI-DMM driver do. It's not an IVI-compliant instrument, and it does not need to be. For reasons lost to time it was added to the NI-DMM driver, when it should more properly have had its own separate driver.
The reason the nidmm Python module does not support PXI-4022 is because it was an obsolete product at the time the Python API was developed, as stated in nimi-python API design guidelines in the project's wiki:
> Don't include obsolete functions / properties
Using ctypes to directly call niDMM_4022Control() on the driver library is also my recommendation.
05-07-2024 12:09 PM
Thank you all for your help. Thanks to you, I was able to communicate with PXI-4022 enabling amplification configuration. I am providing the code below, maybe it will be useful to someone.
Code:
import nidmm
from ctypes import *
dll = cdll.LoadLibrary("nidmm_64.dll")
def c_string(s):
return c_char_p(str(s).encode('utf-8'))
vi = c_int(3) # The number determining the configuration, information below in the comment
ViStatus = dll.niDMM_4022Control(c_string('Dev3'), vi)
print(ViStatus)
#GUARD: 0 - Enables the internal amplifier to be a unity gain buffer for performing 6-wire guarded measurements.
#Current Amp 100 nA: 2 - Enables the low current amplifier and applies a gain of 1E8 V/A.
#Current Amp 10uA: 3 - Enables the low current amplifier and applies a gain of 1E6 V/A.
#Current Amp 1mA: 7 - Enables the low current amplifier and applies a gain of 1E4 V/A.
#Disconnect +IN from AGND: 8 - When one of the current amplification ranges is selected, the +INPUT of the amplifier is tied to analog ground. This is the default case. This default configuration can be overridden by selecting this option to disconnect the +INPUT, and allow the user to provide an external reference. Calling one of the current amplification ranges after calling this node will reconnect the +INPUT to analog ground.
05-08-2024 08:28 AM
Andrew13K,
Thank you for posting that to help the next person with this question! Kudos!