This content is not available in your preferred language.

The content is shown in another available language. Your browser may include features that can help translate the text.

Accessing NI MAX Tasks from NI-DAQmx Python Library

Updated Dec 13, 2022

Environment

Software

  • Measurement & Automation Explorer (MAX)

Driver

  • NI-DAQmx

Programming Language

  • Python

I am using the Python Library for NI-DAQmx and I want to access an already created task from the NI MAX Database, but i cannot find this in the Python Documentation for NI-DAQmx. Is this possible?

Yes, the NI-DAQmx Python Library is capable of accessing an already created task from the NI MAX Database. In order to do so you will need to follow the bellow presented steps:
  • Access the Python Console
  • Import the NI-DAQmx library by entering the following command: "import nidaqmx"

  • In order to access the NI MAX Database, you will have to instantiate a System object that contains the information regarding the connected devise, tasks and so on. This is achieved by the following command: "<object name>  = nidaqmx.system.system.System()"

  • Now, you can access the collection of tasks stored in your system, and visualize the names of those tasks by entering: "<system object name>.tasks.task_names".

  • In order to access one of the tasks, you will need to instantiate a PersistedTask object. PersistedTask is a class that stores the task information in the Database. You can do this in two ways:
  1. Statically: <persisted task object name> = nidaqmx.system.storage.persisted_task.PersistedTask('<task name from the collection obtained at previous step>')
  2. Programmatically: <persisted task object name> = nidaqmx.system.storage.persisted_task.PersistedTask(<system object name>.tasks.task_names[<index of the task you want to access>]). Bare in mind that the indexing starts at 0.

  • Now that you accessed the task in the database you will need to load it, so the System will know that you are currently using and reserve it and create a Task object. The command for this is: "<task object name> = <persisted task object name>.load().

  • Now that you have a task object created, you can execute all the task methods implemented in the Python Library for NI-DAQmx.