Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Read analog input module on cRIO-9056 with python and niDAQmx

Solved!
Go to solution

Dear community,

 

I am not used to National Instrument devices, so this question may be obvious.

 

I am using a compactRIO 9056 device with two NI-9223 modules connected on it in oder to measure voltages signals in real time. 

I am trying to read the analog input channels of the modules with python using the niDAQmx library with the python code attached to this post. However, I keep getting the following error message :

DaqError: Device identifier is invalid.

Device Specified: cRIO1
Suggested Device(s): SimDev1

Task Name: _unnamedTask<5>
Status Code: -200220

 

However, I can see my device with NI-MAX, and it succeeds all the tests I can do with it. I can even define a task on NI-MAX and take some data. (see ni-max window)

 

I don't understand what I am doing wrong with my python code. Is the device compatible with the NI-DAQmx library ?

The NI-DAQmx Device Drive version I used is 2025-Q2 patch 1. And the python library version is 1.0.2.

 

Thank you for you help,

 

 

Download All
0 Kudos
Message 1 of 3
(110 Views)
Solution
Accepted by topic author plagabbe

NI MAX accesses the resources on the cRIO through remote session. However, you cannot do the same with Python. There are two ways to use python with cRIO:

  1. Install NI gRPC Device Server on cRIO, then use Python gRPC Client API (not DAQmx API) on the Windows host.
  2. Install Python and DAQmx library on the cRIO, then run the Python script directly on the cRIO via SSH. See Setting up CompactRIO for Python Development
-------------------------------------------------------
Applications Engineer | TME Systems
https://tmesystems.net/
Message 2 of 3
(94 Views)
Solution
Accepted by topic author plagabbe

Dear Zyong,

 

Thank you for your answer. I did install miniconda directly on my cRIO device, and run my python script on it, and it works.

Just a detail that was not mentioned in the tutorial. By default, the LANG environment variable is set to L1 (I don't know why.), and the nidaqmx library require an UTF-8 encoding. So I should set the LANG variable value before running my python script by running the command:

export LANG=en_US.UTF-8

I wrote this command in the .bashrc file of my cRIO so I don't have to run it each time I want to connect to my device.

 

Thanks for your help.

0 Kudos
Message 3 of 3
(44 Views)