Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Python API Measurement usage

Highlighted

Hello everyone.

 

This is my first post on this forum, so please bear with me Smiley Happy. I had a lot of tries to make the program work but then I succumbed to the erros that I had...

 

I have a USB-6216 device which will be used to read data from 2 sensors. One will output pulses and the other will output an analog value. The cycle for the measurement will be 50 ms. My task is to have a python script that reads the data from the USB and after some postprocessing, outputs the data to a file (with a new file generated every 5 min). I managed to do the postprocessing and also the outputting of data but I am having serious difficulty setting up the data acqusition tasks.

 

I managed to also make the acquisition of Analog Data work using Software-Timed Acqusitions. I had a while loop run every 50ms while reading a sample every cycle.

 

Unfortunately, a specific requirement is to use Hardware-Timed Acquisitions. I want to store the number of pulses detected and the analog measurement in the on-board FIFO and then when the 50 ms are up, send the data over the USB to the PC. I thought about implementing this using the Watchdog timer. I aimed to reset the task every 50 ms using it, but I am not sure if this is the correct usage of the Watchdog.

This is what I tried to do so far (for the digital pulse input task):

with  nidaqmx.Task() as task:
   task.di_channels.add_di_chan("Dev1/port0")
   task.timing.cfg_implicit_timing(sample_mode=AcquisitionType.CONTINUOUS)
   system.watchdog.WatchdogTask("Dev1",task,0.05)
   print(task.read())

Any help is very much appreciated.

Thank you in advance.

 

Regards,

Eduard

 

0 Kudos
Message 1 of 1
(211 Views)