Skip to content

Commit

Permalink
reworked and file renamed as per suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
WayneDroid committed Apr 22, 2024
1 parent 688c1c0 commit 1c0f681
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
using the DAQ device's internal clock.
"""

import pprint
import time

import nidaqmx
from nidaqmx.constants import AcquisitionType

pp = pprint.PrettyPrinter(indent=4, compact=True)

with nidaqmx.Task() as task:
task.ai_channels.add_ai_voltage_chan("Dev1/ai0")
Expand All @@ -16,11 +20,12 @@
task.start()

try:
print("Press Ctrl+C to stop")
print("Press Ctrl+C to stop.")
while True:
print("Reading Data: ")
data = task.read(number_of_samples_per_channel=100)
print(data)
print(f"Acquired data: {pp.pformat(data)}")
print("Press Ctrl+C to stop.")
time.sleep(0.5)
except KeyboardInterrupt:
pass
finally:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
"""Example of analog input voltage acquisition.
"""Example of analog input voltage acquisition with events.
This example demonstrates how to continuously acquire buffered voltage measurements using
a DAQmx device. It uses software events to ensure that the program does not become
unresponsive while waiting for samples to become available.
This example demonstrates how to use Every N Samples events to
acquire a continuous amount of data using the DAQ device's
internal clock. The Every N Samples events indicate when data is
available from DAQmx.
"""

import pprint
import time

import nidaqmx
from nidaqmx.constants import AcquisitionType
Expand All @@ -18,6 +20,8 @@ def callback(task_handle, every_n_samples_event_type, number_of_samples, callbac
"""Callback function for reading singals."""
print("Every N Samples callback invoked.")
pp.pprint(task.read(number_of_samples_per_channel=100))
print("Press Enter to stop.")
time.sleep(0.5)

return 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,13 @@
software timing.
"""

import pprint

import nidaqmx
from nidaqmx.constants import ThermocoupleType, TemperatureUnits

pp = pprint.PrettyPrinter(indent=4)


with nidaqmx.Task() as task:
task.ai_channels.add_ai_thrmcpl_chan(
"Dev1/ai0", units=TemperatureUnits.DEG_C, thermocouple_type=ThermocoupleType.K
)

print("Reading Data: ")
data = task.read()
pp.pprint(data)
print(f"Acquired data: {data}")
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,12 @@
of data using the DAQ device's internal clock.
"""

import pprint

import nidaqmx
from nidaqmx.constants import AcquisitionType

pp = pprint.PrettyPrinter(indent=4)


with nidaqmx.Task() as task:
task.ai_channels.add_ai_voltage_chan("Dev1/ai0")
task.timing.cfg_samp_clk_timing(1000.0, sample_mode=AcquisitionType.FINITE, samps_per_chan=1000)

print("Reading Data: ")
task.start()
data = task.read()
pp.pprint(data)
task.stop()
print(f"Acquired data: {data}")
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,10 @@
This example demonstrates how to acquire a voltage measurement using software timing.
"""

import pprint

import nidaqmx

pp = pprint.PrettyPrinter(indent=4)


with nidaqmx.Task() as task:
task.ai_channels.add_ai_voltage_chan("Dev1/ai0")

print("Reading Data: ")
data = task.read()
pp.pprint(data)
print(f"Acquired data: {data}")

0 comments on commit 1c0f681

Please sign in to comment.