Send Square Voltage Pulses to Elvis Board through daq toolbox
2 views (last 30 days)
Show older comments
Hi Everyone,
I want to send a square pulse with dynamic duration [in the first run it is 0.5 seconds and then I want to change it to 2 seconds] using the digital I/O ports on elvisII board. I don't know how to incorporate time while I'm doing outputsinglescan. The following is the code I'm running. How can I know the ones which equal 5V are applied for how long and how to control it.
% Create a session
s = daq.createSession('ni');
% Add digital channels 0-->8
addDigitalChannel(s,'Dev1','port0/line0','OutputOnly');
addDigitalChannel(s,'Dev1','port0/line1','OutputOnly');
addDigitalChannel(s,'Dev1','port0/line2','OutputOnly');
addDigitalChannel(s,'Dev1','port0/line3','OutputOnly');
addDigitalChannel(s,'Dev1','port0/line4','OutputOnly');
addDigitalChannel(s,'Dev1','port0/line5','OutputOnly');
addDigitalChannel(s,'Dev1','port0/line6','OutputOnly');
addDigitalChannel(s,'Dev1','port0/line7','OutputOnly');
addDigitalChannel(s,'Dev1','port0/line8','OutputOnly');
t = 1:10;
sw1_1 = ones(1,length(t));
sw1_2 = zeros(1,length(t));
sw1_3 = zeros(1,length(t));
sw2_1 = zeros(1,length(t));
sw2_2 = zeros(1,length(t));
sw2_3 = zeros(1,length(t));
row1 = ones(1,length(t));
row2 = ones(1,length(t));
row3 = ones(1,length(t));
step1 = [sw1_1' sw1_2' sw1_3' sw2_1' sw2_2' sw2_3' row1' row2' row3'];
step = step1(1,:);
outputSingleScan(s,step)
pause(7);
%Set them back to zero
sw1_1 = zeros(1,length(t)); sw1_2 = zeros(1,length(t)); sw1_3 = zeros(1,length(t));
sw2_1 = ones(1,length(t)); sw2_2 = ones(1,length(t)); sw2_3 = ones(1,length(t));
step1 = [sw1_1' sw1_2' sw1_3' sw2_1' sw2_2' sw2_3' row1' row2' row3'];
step = step1(1,:);
outputSingleScan(s,step)
0 Comments
Answers (0)
See Also
Categories
Find more on Data Acquisition Toolbox Supported Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!