Borrar filtros
Borrar filtros

How do you send a digital signal as an output to NI DAQ system?

63 visualizaciones (últimos 30 días)
Taeksoo Kim
Taeksoo Kim el 14 de Jul. de 2020
Comentada: LO el 15 de Jul. de 2020
Hi,
I'm starting to learn DAQ in simulink and I have a question on how to send Digital I/O signals to my daq device (NI USB-6009). So, here is my simple test set for Digital I/O connections.
Basically, I'm trying to send a sample of digital (or binary) data to the DAQ and make the valve which is connected to DAQ to be open or closed. The simulation itself runs fine without any error. However, the valve does not close or open, which means that the binary data sent out did not trigger the voltage output in the DAQ. I don't know what I'm doing wrong. I would really appreciate if you could tell me how to resolve this issue.
(I used the information in https://www.mathworks.com/help/daq/digitaloutputsinglesample.html for the Simulink)

Respuestas (2)

LO
LO el 15 de Jul. de 2020
See the properties of your daq by typing its device name in command line. See how the channels are called and which types you have. you have to use the digital output code d = daq("ni"); addoutput(d,"Dev1","Port0/Line0","Digital") For example. But you can use also port 1 and other lines. It depends. Use the ni max software to test the channel. In that software you can also find a help to properly configure the output and know which gpio to use.

Taeksoo Kim
Taeksoo Kim el 15 de Jul. de 2020
Thanks for your response. So I tried to put the command, " code d = daq("ni"); addoutput(d,"Dev1","Port0/Line0","Digital") ". However, I was keep getting the message as the followings:
I have checked the Matlab app and "Data Acquisition Toolbox" was installed, so I don't know why these errors are keep coming up.
On the other hand, I tried something like this:
However, I don't know how to receive or send the digital signal from here.
I also tried checking with NI Max Software and all the digital ports were working fine, except the one that was connected to the valve. For more information, I have also attached the picture of the connections between the solenoid valve and the DAQ.
Thank you very much in advance !!
  1 comentario
LO
LO el 15 de Jul. de 2020
you are using the wrong code (at least in the first lines I can read)
d = daq.getDevices;
s = daq.createSession('ni');
Fs = s.Rate; % set rate if you need to acquire data
s.DurationInSeconds = duration; % video duration in seconds
duration = s.DurationInSeconds; % set duration
ch1 = addCounterOutputChannel(s,'Dev1','ctr0','PulseGeneration'); % valve trigger
ch1.Frequency = PULSE_FREQ; % this is going to be the valve activation freq (you can set it to 1 if you want 1 pulse only)
ch1.DutyCycle = 0.1; % default value 0.1, amount of time the pulse stays active (from 0 to 1)
ch1.Terminal % it tells you which ports are being used just to make sure you are connecting the cables right)
it is also possible to send a single pulse without starting any session
you can get the code - if I remember well - directly from the NIMAX software (or from the MATLAB NI-DAQ TOOLBOX which should help you to interface your device)

Iniciar sesión para comentar.

Categorías

Más información sobre Periodic Waveform Generation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by