📄 sawsignal.m
字号:
function Mirror=SawSignal(OutpFs,MaxValue,RaisT,FallT,NumbLines,NumbPixels,OffSet,Alpha,LS)
% SawSignal generate the output signals to move mirrors X and Y.
% Mirror=SawSignal(OutpFs,MaxValue,RaisT,FallT,NumbLines,NumbPixels,OffSet,Alpha,LS);
%
% Input Arguments:
% OutpFs: Output Sample Frequency (Hz)
% MaxValue: Maximun Value of Ramp (%)
% RaisT: Raising Part of the Ramp (s)
% FallT: Falling Part of the Ramp (s)
% NumbLines: Number of Lines per Image
% NumbPixsels: Number of Pixels per Line
% OffSet: 1x2 array with the offset values for coordinate X and Y (in pixels of the image).
% Alpha: Rotation Angle (degrees). Positive angles means counterclockwise rotation.
% LS: Line Scan, 0 means Off, 1 means On
%
% Output Arguments:
% Mirror: Nx2 array. First column is Mirror X and Second column is Murror Y.
%
% Usage:
% Mirror=SawSignal(100e3,100,1.7e-3,0.3e-3,240,320,[160.5,120.5],0,0);
% Check valid values for MaxValue
% Possible values for MaxValue: 5, 2.5, 1.25, 0.625
MaxValue= ((MaxValue~=200)&(MaxValue~=400)&(MaxValue~=800))*1 + ...
(MaxValue==200)*0.5 + ...
(MaxValue==400)*0.25 + ...
(MaxValue==800)*0.125;
% Mirror X
% Points in the Raising Part of the Ramp
XRaisP= round(OutpFs*RaisT);
% Points in the Falling Part of the Ramp
XFallP= round(OutpFs*FallT);
% Signal amplitud
XMaxValue=7.5*MaxValue;
% First Line Signal for Mirror X
MirrorX= [ [0:XRaisP-1]' * ( XMaxValue/XRaisP ); ...
XMaxValue - [0:XFallP-1]' * ( XMaxValue/XFallP )];
% Repeat the same signal for all the lines
MirrorX= MirrorX*ones(1,NumbLines);
% Reshape the matrix in a column vector
MirrorX= MirrorX(:);
% Mirror Y
% Points in the Raising Part of the Ramp
YRaisP= round(NumbLines*OutpFs*(RaisT+FallT));
% Signal amplitud
YMaxValue=12*MaxValue*NumbLines/(0.75*NumbPixels) * (LS==0);
% First Line Signal for Mirror Y
MirrorY= [ [0:YRaisP-1]' * ( YMaxValue/YRaisP )];
% Mirror array
Mirror= [MirrorX, MirrorY];
% Rotation matrix
Alpha= Alpha*pi/180;
R= [cos(Alpha) sin(Alpha); -sin(Alpha) cos(Alpha)];
% OffSet:
% Pixels -> Voltage
UseF=1/1.328125;
CX=inv([1 1;320 1])*[-.5; .5]*UseF*7.5;
CY=inv([1 1;240 1])*[-.5; .5]*12;
OffSet(1)=CX(1)*OffSet(1)+CX(2);
OffSet(2)=CY(1)*OffSet(2)+CY(2);
OffSet=round(10000*OffSet)/10000;
% Check valid values for MaxValue
% when it is invalid, the OffSet is centered in the image
OffSet(1)= (abs(OffSet(1))<=.5*(07.5-XMaxValue))*OffSet(1) ;
OffSet(2)= (abs(OffSet(2))<=.5*(12.0-YMaxValue))*OffSet(2) ;
% Center the points
Mirror= Mirror - ones(YRaisP,1)*[0.5*XMaxValue, 0.5*YMaxValue];
Mirror= Mirror*R + ones(YRaisP,1)*OffSet;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -