⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 amplifier.m

📁 A graphical user interface designed to control a confocal microscope.
💻 M
字号:
function State=Amplifier(Obj,Sensit,Offset,Bias,CutOffFreq,LNAmp,Invert)
% Amplifier sets up the amplifier SR570 through the SR232 port.
% State=Amplifier(Obj,Sensit,Offset,Bias,CutOffFreq,LNAmp,Invert);
%
% Input Arguments: 
% Obj: Handle to the communication port
% Sensit: sensitivity control, scale from 0 to 27
% Offset: input offset control, scale from -1000 to 1000
% Bias: voltage bias, scale from -5000 to 5000
% CutOffFreq: 3dB cutoff frequency, possible values are 100, 300 and 1000 KHz
% LNAmp: gain mode of the amplifier, possible values are 0, 1, 3 
% Invert: ste the signal sense, 1 means invert, 0 means non-invert
% (read the amplifier manual for more information about these parameters)
%
% Output Arguments:
% State: return 1 is no error occurs while running and 0 if error occurs 
%
% Usage:
%   Obj=serial('COM1');
%   set(Obj,'BaudRate',9600,'DataBits',8,'FlowControl','none','Parity','none','StopBits',2,'Terminator','CR/LF')
%   fopen(Obj);
%   State=Amplifier(Obj,20,0,0,300,1,1);
%   fclose(Obj);
%   delete(Obj);

% Check valid input argument
% Sensitivity: scale from 0 to 27
Sensit=round(Sensit);
Sensit= ((0 <= Sensit) & (Sensit <= 27))*Sensit ;
% Offset: scale from -1000 to 1000
Offset=round(Offset);
Offset= ((-1000 <= Offset) & (Offset <= 1000))*Offset ;
% Bias: scale from -5000 to 5000
Bias=round(Bias);
Bias= ((-5000 <= Bias) & (Bias <= 5000))*Bias ;
% Filter: reset, 12dB lowpass, cutoff frequency from 0 to 1MHz
CutOffFreq= (CutOffFreq==100)*0 + ...
            (CutOffFreq==300)*1 + ...
            (CutOffFreq==1000)*2 + 13;
% Gain Mode: scale from 0 to 2
LNAmp=round(LNAmp);
LNAmp= ((0 <= LNAmp) & (LNAmp <= 2))*LNAmp ;
% Invert
Invert=round(Invert);
Invert= (Invert == 1)*Invert ;

% Send data to the amplifier
try
    % Sensitivity: uncalibrated, scale from 0 to 27
    fprintf(Obj,'SUCM0');
    fprintf(Obj,['SENS' num2str(Sensit)]);

    % Input Offset: uncalibrated, scale from -1000 to 1000
    fprintf(Obj,'IOON1');
    fprintf(Obj,'IOUC1');
    fprintf(Obj,['IOUV' num2str(Offset)]);
    
    % Bias: turn on, scale from -5000 to 5000
    fprintf(Obj,'BSON1');
    fprintf(Obj,['BSLV' num2str(Bias)]);

    % Filter: reset, 12dB lowpass, cutoff frequency: 100K, 300K or 1MHz
    fprintf(Obj,'ROLD');
    fprintf(Obj,'FLTT4');
    fprintf(Obj,['LFRQ' num2str(CutOffFreq)]);

    % Gain mode: 
    fprintf(Obj,['GNMD' num2str(LNAmp)]);

    % Invert
    fprintf(Obj,['INVT' num2str(Invert)]);
    
    % Everthing is fine
    State=1;
catch
    % An error occurs while writing the port
    State=0;
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -