How do you send a digital signal as an output to NI DAQ system?
63 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
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.
0 comentarios
Taeksoo Kim
el 15 de Jul. de 2020
1 comentario
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)
Ver también
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!