
tic
ao=analogoutput('nidaq')
addchannel(ao, 0);
ch0=ao.Channel
frequency  = 1;
amplitude  = 5;
offset     = 0;
dutycycle  = 70;
sampleRate=500;
set(ao,'SampleRate',sampleRate);

%------------------------------------------------------

numPoints = sampleRate/frequency;
t = linspace(0,2*pi,numPoints+1);
t = t(1:end-1);
   tmp = mod(t,2*pi);
   w0 = 2*pi*dutycycle/100;
   nodd = (tmp < w0);
   y = 2*nodd-1;
%waveData = offset + amplitude*y;
waveData=2;
% valor=5;
set(ao, 'TriggerType', 'Immediate');
set(ao, 'RepeatOutput', 3);
tic
putdata(ao, [waveData]');
% while valor~=0,
%     
%     disp('introduza o valor: ');
%     valor=input('');
%     waveData =offset+valor;
%    
%     
%     start(ao);
% 
% 
% disp('pp');
% % trigger(ao);
% %stop(ao);
% end
start(ao);
toc
disp('pp');
pause;
% delete(ao);
z=0;
putdata(ao, [z]');
start(ao);
% trigger(ao);
stop(ao);
delete(ao);
toc