% Written by Tom Spinka on Sept. 28, 2007 for controlling the grating angle
% in a Lambda-Physik FL3001/3002 dye laser to select a given wavelength.
% This function needs to be extendable to using a measured wavelength
% calibration curve.
function [WaveRead,CurrentCnts] = DyeLaserMoveToWavelength(WaveNM, order, Bd, Dye)
% Obtain the stored grating calibration constant from the dye laser. This
% code will be replaced with a measured calibration curve so that the exact
% position code can be sent instead of calculated.
Err = DyeLaserWrite(Bd, Dye, ['?G',13]);
[Err, GratingCalConstAscii] = DyeLaserRead(Bd, Dye, 7);
GratingCalConst = DyeLaserAsciiToDec(GratingCalConstAscii(1:6));
Counts = (WaveNM * order - (GratingCalConst/1000)) / 0.00315;
if((ceil(Counts) > 285715) || (floor(Counts) < 0))
WaveRead = 'Wavelength not accessible in the given grating order.';
else
GratPos = ceil(Counts);
GratPosCnts = DyeLaserDecToAscii(GratPos, 6);
Err = DyeLaserWrite(Bd, Dye, ['?A',13]);
[Err, CurrentPos] = DyeLaserRead(Bd, Dye, 19);
Err = DyeLaserWrite(Bd, Dye, ['SA',GratPosCnts,CurrentPos(7:18),13]);
while(not(strcmp(CurrentPos(1:6),GratPosCnts)))
pause(0.1);
Err = DyeLaserWrite(Bd, Dye, ['?A',13]);
[Err, CurrentPos] = DyeLaserRead(Bd, Dye, 19);
end
end
CurrentCnts = DyeLaserAsciiToDec(CurrentPos(1:6));
WaveRead = (((CurrentCnts) * 0.00315) + (GratingCalConst/1000)) / (order);