Jump to content

DAQ: Difference between revisions

From Photonicamp Wiki
No edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 2: Line 2:
For more information regarding a DAQ, please visit this [https://www.ni.com/en/shop/data-acquisition.html?srsltid=AfmBOop-ShC6qXu4ureq48jENtLwW7mANszhvf_x35Bpx6UD8beugJyp link].
For more information regarding a DAQ, please visit this [https://www.ni.com/en/shop/data-acquisition.html?srsltid=AfmBOop-ShC6qXu4ureq48jENtLwW7mANszhvf_x35Bpx6UD8beugJyp link].


In our lab, we are using a DAQ NI USB-6259:
== NI DAQ USB-6259 ==
In the Optomechanics lab and [[LCO]], we are mainly using NI DAQs, such as the USB-6259 model:


[[File:Daq.jpg|300px|Picture of our DAQ, model NI USB-6259]]
[[File:Daq.jpg|300px|Picture of our DAQ, model NI USB-6259]]


'''Specifications'''
=== Specifications ===
Detailed specifications can be found on the website of [https://www.ni.com/docs/en-US/bundle/pci-pcie-pxi-pxie-usb-6259-specs/page/specs.html?srsltid=AfmBOoq6huevEadUGbvg0VDbnbNFntNGujrl4xMiuFrHO2soOgXV2_Wf National Instruments]
Detailed specifications can be found on the website of [https://www.ni.com/docs/en-US/bundle/pci-pcie-pxi-pxie-usb-6259-specs/page/specs.html?srsltid=AfmBOoq6huevEadUGbvg0VDbnbNFntNGujrl4xMiuFrHO2soOgXV2_Wf National Instruments]
Specific specs:
Specific specs:
Multichannel maximum: 1.00 MS/s. This rate is shared among all input channels.
Multichannel maximum: 1.00 MS/s. This rate is shared among all input channels.


'''Ghosting'''
=== Ghosting ===
When reading multiple signals simultaneously, it is possible that the signal of channel X will be partially visible in the signal recorded by channel Y due to what is called ghosting. Please find more information about ghosting [https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000YHy6CAG&l=pt-BR here].
When reading multiple signals simultaneously, it is possible that the signal of channel X will be partially visible in the signal recorded by channel Y due to what is called ghosting. Please find more information about ghosting [https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000YHy6CAG&l=pt-BR here].


'''An example of a python script to read out channels''' <syntaxhighlight lang="python" line="1" start="1">
== NI DAQ USB-600X ==
[[File:NIDAQ USB-6009.png|alt=NI DAQ USB-6009|thumb|NI DAQ USB-6009]]
We also use these smaller DAQs for simpler setups.
 
=== Specifications ===
Full specifications at [https://download.ni.com/support/manuals/375296c.pdf National Instruments website].
 
The USB-6009 model presents up to 48 kS/s and 13/14 bit input resolution, depending on configuration.
 
== Measurement Computing DAQ ==
There are also a couple of MC DAQs such as USB-1208LS and USB-1408FS, with similar specs to the NI USB-600X. More information at [https://digilent.com/shop/mcc-usb-1208fs-plus-ls-1408fs-plus-series-multifunction-usb-daq-devices/ Digilent].
 
== Data acquisition ==
 
=== National Instruments (NI DAQmx) ===
NI DAQs use the [https://pypi.org/project/nidaqmx/ nidaqmx] python package, which depends on the installation of [https://www.ni.com/en/support/downloads/drivers/download.ni-daq-mx.html NI DAQ drivers].
 
==== An example of a python script to read out channels ====
Note that in the example below, we use shorts in between the three main signals to read in order to reduce ghosting. The shorts need to be read out to be effective. <syntaxhighlight lang="python" line="1" start="1">
import nidaqmx
import nidaqmx


Line 35: Line 54:




</syntaxhighlight>'''An example of a python script to set an output voltage'''<syntaxhighlight lang="python">
</syntaxhighlight>
 
==== An example of a python script to set an output voltage ====
<syntaxhighlight lang="python"  line="1" start="1">
import nidaqmx
import nidaqmx


Line 42: Line 64:
DAQtaskAO.write(data=5.2, auto_start = True); #5.2 Volt will be set at channel ao0.
DAQtaskAO.write(data=5.2, auto_start = True); #5.2 Volt will be set at channel ao0.


</syntaxhighlight>
=== Measurement Computing ===
MC DAQs use the [https://pypi.org/project/mcculw/ mcculw] python package, which depends on the proper [https://digilent.com/reference/software/start MC drivers] to be installed.
==== A quick example to read the voltage in one of the channels ====
<syntaxhighlight lang="python3" line="1">
from mcculw import ul
from mcculw.enums import ULRange
from mcculw.ul import ULError
board_num = 0
channel = 0
ai_range = ULRange.BIP5VOLTS
try:
    # Get a value from the device
    value = ul.a_in(board_num, channel, ai_range)
    # Convert the raw value to engineering units
    eng_units_value = ul.to_eng_units(board_num, ai_range, value)
    # Display the raw value
    print("Raw Value: " + str(value))
    # Display the engineering value
    print("Engineering Value: " + '{:.3f}'.format(eng_units_value))
except ULError as e:
    # Display the error
    print("A UL error occurred. Code: " + str(e.errorcode)
          + " Message: " + e.message)
</syntaxhighlight>
</syntaxhighlight>

Latest revision as of 14:15, 6 December 2024

For more information regarding a DAQ, please visit this link.

NI DAQ USB-6259

In the Optomechanics lab and LCO, we are mainly using NI DAQs, such as the USB-6259 model:

Picture of our DAQ, model NI USB-6259

Specifications

Detailed specifications can be found on the website of National Instruments Specific specs: Multichannel maximum: 1.00 MS/s. This rate is shared among all input channels.

Ghosting

When reading multiple signals simultaneously, it is possible that the signal of channel X will be partially visible in the signal recorded by channel Y due to what is called ghosting. Please find more information about ghosting here.

NI DAQ USB-600X

NI DAQ USB-6009
NI DAQ USB-6009

We also use these smaller DAQs for simpler setups.

Specifications

Full specifications at National Instruments website.

The USB-6009 model presents up to 48 kS/s and 13/14 bit input resolution, depending on configuration.

Measurement Computing DAQ

There are also a couple of MC DAQs such as USB-1208LS and USB-1408FS, with similar specs to the NI USB-600X. More information at Digilent.

Data acquisition

National Instruments (NI DAQmx)

NI DAQs use the nidaqmx python package, which depends on the installation of NI DAQ drivers.

An example of a python script to read out channels

Note that in the example below, we use shorts in between the three main signals to read in order to reduce ghosting. The shorts need to be read out to be effective.

import nidaqmx

DAQtaskAI = nidaqmx.Task(); #create a task object
DAQtaskAI.ai_channels.add_ai_voltage_chan("Dev1/ai0",min_val=0,max_val=10) # add an input channel to the task. min_val and max_val are the minimum and maximum voltage that will be applied. #Transmission
DAQtaskAI.ai_channels.add_ai_voltage_chan("Dev1/ai1",min_val=0,max_val=10) # Short
DAQtaskAI.ai_channels.add_ai_voltage_chan("Dev1/ai2",min_val=0,max_val=10) # MZI signal
DAQtaskAI.ai_channels.add_ai_voltage_chan("Dev1/ai3",min_val=0,max_val=10) # Short
DAQtaskAI.ai_channels.add_ai_voltage_chan("Dev1/ai4",min_val=0,max_val=10) # HCN signal

DAQtaskAI.timing.cfg_samp_clk_timing(rate=100000,samps_per_chan=500000) #set sampling parameters. In this example the sampling rate per channel is 100 kHz and data will be collected during 5 seconds.

#measure
data = DAQtaskAI.read(number_of_samples_per_channel = 500000, timeout = 5);

transmission = data[0]
mzi    = data[2]
hcn    = data[4]

An example of a python script to set an output voltage

import nidaqmx

DAQtaskAO = nidaqmx.Task(); #create a task object
DAQtaskAO.ao_channels.add_ao_voltage_chan("Dev1/ao0");
DAQtaskAO.write(data=5.2, auto_start = True); #5.2 Volt will be set at channel ao0.

Measurement Computing

MC DAQs use the mcculw python package, which depends on the proper MC drivers to be installed.

A quick example to read the voltage in one of the channels

from mcculw import ul
from mcculw.enums import ULRange
from mcculw.ul import ULError

board_num = 0
channel = 0
ai_range = ULRange.BIP5VOLTS

try:
    # Get a value from the device
    value = ul.a_in(board_num, channel, ai_range)
    # Convert the raw value to engineering units
    eng_units_value = ul.to_eng_units(board_num, ai_range, value)

    # Display the raw value
    print("Raw Value: " + str(value))
    # Display the engineering value
    print("Engineering Value: " + '{:.3f}'.format(eng_units_value))
except ULError as e:
    # Display the error
    print("A UL error occurred. Code: " + str(e.errorcode)
          + " Message: " + e.message)