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

5 vues (au cours des 30 derniers jours)
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?

Réponses (1)

Amit Doshi
Amit Doshi le 7 Sep 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:

Catégories

En savoir plus sur Data Acquisition Toolbox dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by