Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Vernier SensorDAQ digital outputs activation with NI DAQ MX Python

Hi everybody.

 

I am making an application with the Vernier Sensor DAQ to control temperature in a closed mini-chamber with the LM35 and a light bulb  as an actuator.

 

To activate the light source, I need to configure and set a digital output of the DAQ for a certain time to keep the temperature radiating the focus. I'm using the NI DAQ MX Python API (https://nidaqmx-python.readthedocs.io/en/latest/)

Unfortunately I'm inexperienced with python and interpreting the documentation of that API, however I built this code, but when executing it does not activate any of the four digital outputs of the SensorDAQ:

 

import numpy as np
import nidaqmx as daq
import math
import pylab as plt

from nidaqmx.constants import LineGrouping
from nidaqmx import system
s = system.System()
print(list(s.devices)) # data dev correspondiente

def activa_salida_digital():
    #nidaqmx._task_modules.channels.channel.Channel
    #nidaqmx.system._collections.PhysicalChannelCollection
    app= 'Dev8/port0/line0'
    with daq.Task() as task:
        task.do_channels.add_do_chan(
            app,
            line_grouping=LineGrouping.CHAN_FOR_ALL_LINES)
     
        try:
            print('N Lines 1 Sample Boolean Write (Error Expected): ')
            print(task.write([True, False, True, False]))
        
        except daq.DaqError as e:
            print(e)
        
        print('1 Channel N Lines 1 Sample Unsigned Integer Write: ')
        print(task.write(8))
    
        print('1 Channel N Lines N Samples Unsigned Integer Write: ')
        print(task.write([1, 2, 4, 8], auto_start=True))

 

I attach the connection diagram:

VernierDAQ_sch.jpg

 

0 Kudos
Message 1 of 1
(2,224 Views)