Matlab-Driver-for-Thorlabs-power-meter

版本 3.30.0.0 (11.1 KB) 作者: Zimo Zhao
Matlab driver for Thorlabs power meter
421.0 次下载
更新时间 2023/5/31

View Matlab-Driver-for-Thorlabs-power-meter on File Exchange

Matlab Driver for Thorlabs Power Meter

This is a Matlab class to control Thorlabs power meters. (Multiple meters are supported)

For Python wrapper, please go the following page:

Link to a typical Thorlabs Power Meter.

User Instructions

  1. Download the Optical Power Monitor from the Thorlabs website. [The latest version is 4.0.4100.700 - Accessed on 01 SEP 2022]

  2. Read the manual in the installation folder or the software help page.

  3. Following the instructions in section 9: Write Your Own Application. The common path of the *.dll files on Windows is: C:\Program Files\IVI Foundation\VISA\VisaCom64\Primary Interop Assemblies

  4. This scripts need only the .net wrapper dll so follow the instruction for C#/.Net.

  5. Two ways of utilising the dynamic link library (*.dll) files provided by Thorlabs:

    1. Copy *.dll files needed to ''Thorlabs_DotNet_dll'' folder (e.g. Thorlabs.TLPM_64.Interop.dll).

    2. Edit MOTORPATHDEFAULT below to point to the location of the DLLs.

      No significant difference was noticed between "Thorlabs.TLPMX_64.Interop.dll" and "Thorlabs.TLPM_64.Interop.dll". But if you are going to use "Thorlabs.TLPMX_64.Interop.dll", please change:

      TLPMDLL='Thorlabs.TLPM_64.Interop.dll';
      TLPMCLASSNAME='Thorlabs.TLPM_64.Interop.TLPM';

      into

      TLPMDLL='Thorlabs.TLPMX_64.Interop.dll';
      TLPMCLASSNAME='Thorlabs.TLPM_64.Interop.TLPMX';
  6. Connect your Power Meter with sensor to the PC USB port and power it on.

  7. Please refer to the examples provided

For developers

  1. The definition for all the classes can be found in the C# exmple provided by Thorlab. (Shipped together with the software.) [The typical path for x64 system is C:\Program Files (x86)\IVI Foundation\VISA\WinNT\TLPM\Example]

Example Single Usage

close all
clear
meter_list=ThorlabsPowerMeter;                              % Initiate the meter_list
DeviceDescription=meter_list.listdevices;               	% List available device(s)
test_meter=meter_list.connect(DeviceDescription);           % Connect single/the first devices
%or                                                         % Connect single/the first devices
%test_meter=meter_list.connect(DeviceDescription,1);        % Connect single/the first devices
test_meter.setWaveLength(635);                              % Set sensor wavelength
test_meter.setDispBrightness(0.3);                          % Set display brightness
test_meter.setAttenuation(0);                               % Set Attenuation
test_meter.sensorInfo;                                      % Retrive the sensor info
test_meter.setPowerAutoRange(1);                            % Set Autorange
% or
% test_meter.setPowerRange(0.01);                           % Set manual range
pause(5)                                                    % Pause the program a bit to allow the power meter to autoadjust
test_meter.setAverageTime(0.01);                            % Set average time for the measurement
test_meter.setTimeout(1000);                                % Set timeout value 
% test_meter.darkAdjust;                                      % (PM400 ONLY)
% test_meter.getDarkOffset;                                   % (PM400 ONLY)
for i=1:1:100   
    test_meter.updateReading(0.5);                          % Update the power reading(with interal period of 0.5s)
    fprintf('%.10f%c\r',test_meter.meterPowerReading,test_meter.meterPowerUnit);
end
test_meter.updateReading_V(0.5);                            % To demonstrate that only certain sensors can use this function
                                                            % A warning message is expected here for most of the models
test_meter.disconnect;                                      % Disconnect and release

Example Multiple Usage

close all
clear
meter_list=ThorlabsPowerMeter;                              % Initiate the meter_list
DeviceDescription=meter_list.listdevices;                   % List available device(s)
test_meter_A=meter_list.connect(DeviceDescription,1);       % Connect multiple devices
test_meter_B=meter_list.connect(DeviceDescription,2);       % Connect multiple devices
test_meter_A.setWaveLength(635);                            % Set sensor wavelength
test_meter_B.setWaveLength(780);                            % Set sensor wavelength
test_meter_A.setDispBrightness(0.3);                        % Set display brightness
test_meter_B.setDispBrightness(0.7);                        % Set display brightness
test_meter_A.setAttenuation(-10);                           % Set Attenuation
test_meter_B.setAttenuation(10);                            % Set Attenuation
% test_meter_A.sensorInfo;                                  % Retrive the sensor info
% test_meter_B.sensorInfo;                                  % Retrive the sensor info
% test_meter_A.darkAdjust;                                  % (PM400 ONLY)
% test_meter_A.getDarkOffset;                               % (PM400 ONLY)
% test_meter_B.darkAdjust;                                  % (PM400 ONLY)
% test_meter_B.getDarkOffset;                               % (PM400 ONLY)
for i=1:1:100   
    test_meter_A.updateReading(0.5);                        % Update the reading (with interal period of 0.5s)
    fprintf('%.10f%c\r',test_meter_A.meterPowerReading,test_meter_A.meterPowerUnit);
end
fprintf('\r');
for i=1:1:100
    test_meter_B.updateReading(0.5);                        % Update the reading (with interal period of 0.5s)
    fprintf('%.10f%c\r',test_meter_B.meterPowerReading,test_meter_B.meterPowerUnit);
end
test_meter_A.disconnect;                                    % Disconnect and release
test_meter_B.disconnect;                                    % Disconnect and release

Author Information

Initially Developed On

  • Optical Power Monitor
    • Device: PM400
    • Application version: 3.1.3778.562
    • Driver version: TLPM__32 5.1.3754.327
  • Matlab
    • 2020b

Latest Test Pass On

  • Optical Power Monitor
    • Device: PM400
    • Application version: 4.0.4100.700
    • Driver version: TLPMX__32 5.3.4101.525
  • Matlab
    • 2022a

Version History

1.00 ----- 21 May 2021 ----- Initial Release

1.01 ----- 17 Aug 2021 ----- Clarify the way of utilizing *.dll files

2.00 ----- 27 Aug 2021 ----- Support multiple power meters connection

2.01 ----- 26 Sep 2021 ----- Add force connection function to bypass the device availability check.

3.00 ----- 01 Feb 2022 ----- Add functions: setPowerRange, setPowerAutoRange, setTimeout, setAverageTime, updateReading_V.

3.10 ----- 01 SEP 2022 ----- Test the script on latest TLPM driver and MATLAB. Some bugs are corrected as well.

3.20 ----- 03 Jan 2023 ----- Update README about the similar Python scripts

引用格式

Zimo Zhao (2024). Matlab-Driver-for-Thorlabs-power-meter (https://github.com/Tinyblack/Matlab-Driver-for-Thorlabs-power-meter/releases/tag/v3.30), GitHub. 检索来源 .

MATLAB 版本兼容性
创建方式 R2020b
兼容 R2019a 到 R2022a 的版本
平台兼容性
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
3.30.0.0

See release notes for this release on GitHub: https://github.com/Tinyblack/Matlab-Driver-for-Thorlabs-power-meter/releases/tag/v3.30

3.20.0.0

See release notes for this release on GitHub: https://github.com/Tinyblack/Matlab-Driver-for-Thorlabs-power-meter/releases/tag/v3.20

3.11

See release notes for this release on GitHub: https://github.com/Tinyblack/Matlab-Driver-for-Thorlabs-power-meter/releases/tag/v3.11

3.00

See release notes for this release on GitHub: https://github.com/Tinyblack/Matlab-Driver-for-Thorlabs-power-meter/releases/tag/v3.00

2.00

See release notes for this release on GitHub: https://github.com/Tinyblack/Matlab-Driver-for-Thorlabs-power-meter/releases/tag/v2.00

1.01

See release notes for this release on GitHub: https://github.com/Tinyblack/Matlab-Driver-for-Thorlabs-power-meter/releases/tag/v1.01

1.0

要查看或报告此来自 GitHub 的附加功能中的问题,请访问其 GitHub 仓库
要查看或报告此来自 GitHub 的附加功能中的问题,请访问其 GitHub 仓库