How to acquire data through Analog Input and use in a Digital Output with NI myDAQ?

2 visualizzazioni (ultimi 30 giorni)
I'm using a DAQ to acquire data through an Analog Port (AI:0) and need to use it to control 2 Digital Ports (D0:4;5 & D0:6;7). Using inputsingleScan I can only acquire 1 single scan from the Analog Input. I need to constantly update this scan in order to control the Digital Output. startForeground and startBackground seem to only work with Analog inputs and outputs.
I am taking data from a Photo-transistor and using it to change the direction of 2 motors.
So my question is, how can I continuously take scans using the Analog input to update the operations on the Digital Output?

Risposte (1)

Amit Doshi
Amit Doshi il 7 Set 2017
Hello Danté,
You could use 'addlistener' to add a listener function to the session. This function is called every time the DataAvailable event occurs. Refer the below link :
Inside that function, you can loop through the acquired data and use the 'outputSingleScan' function to output the data to a digital channel. Refer the below link:

Categorie

Scopri di più su Data Acquisition Toolbox in Help Center e File Exchange

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by