07-17-2007 03:43 PM
function laserautocontrol(powerlevel,n)Any help would be greatly appreciated. Thanks.
dio = digitalio('parallel',1);
addline(dio,0,'out','DataInput1');
addline(dio,1,'out','DataInput2');
addline(dio,2,'out','DataInput3');
addline(dio,3,'out','DataInput4');
addline(dio,4,'out','DataInput5');
addline(dio,5,'out','DataInput6');
addline(dio,6,'out','DataInput7');
powerproper = powerlevel/100*120;
initializedata = logical([0 0 0 0 0 0 0]);
startdata = dec2binvec(powerproper,7);
stopdata = logical([0 0 0 0 0 0 0]);
putvalue(dio,initializedata);
tic;
for i=1:n
putvalue(dio,startdata);
putvalue(dio,stopdata);
pause(0.01);
end
putvalue(dio,stopdata);
toc;
delete(dio)
clear dio
07-18-2007 11:17 AM
Hello,
Let me preface this by saying that I am not at all familiar with programming NI devices in MATLAB. However, from what I can tell, it looks like you are using software timing to control the output frequency. Your PCI-6221 does support correlated digital I/O. This means that you can supply a pulse train to time your digital I/O in hardware. This is much more deteriministic than timing the output in software, and can also go at much faster rates. I would suggest generating a pulse train with one of your device's counters and then using this to time a correlated digital output task. Let me know if you have any questions about this.
Unfortunately, while many people in these forums could help you program this in LabVIEW, you're not going to find many MATLAB experts around here. I am sorry to say that I can't really help you with the MATLAB programming aspect. If no one here is able to offer you more advice, I would suggest visiting the MATLAB forums to see if anyone there has any suggestions.
Good luck with your application!
07-18-2007 11:39 AM - edited 07-18-2007 11:39 AM
Message Edited by caballero on 07-18-2007 12:39 PM
07-18-2007 05:25 PM - edited 07-18-2007 05:25 PM
Message Edited by caballero on 07-18-2007 06:26 PM