PM100x Visual Csharp
PM100x Visual Csharp
2. Run the Thorlabs Optical Power Meter Utility to verify that your instrument is working with the
computer correctly. Make note of your Device ID in the Connected Devices window (this will be
used in step 10).
4. Start a Visual C# Console Application and give it an appropriate name. We used “PM100x
C_Sharp Example” for this application note.
7. Select Thorlabs.PM100D from the Extensions list and select OK. This is used for the PM100A,
PM100D, PM100USB, PM200, PM16, PM160, and PM160T.
9. Create a new PM100D object. The constructor parameters are a string that contains the device
resource name and two Booleans which tell the device to do an ID query and to reset the
device. The device resource name is listed by the Thorlabs Optical Power Meter Utility.
10. Set the wavelength. The setWavelength method parameter is the wavelength in nm.
11. Get the power from the power meter and display it to the console. The measPower method
parameter is a variable in which we will store the power measurement.
Summary:
This function initializes the instrument driver session and performs the following initialization
actions: (1) Opens a session to the Default Resource Manager resource and a session to the
specified device using the Resource Name specified. (2) Performs an identification query on the
instrument. (3) Resets the instrument to a known state. (4) Sends initialization commands to
the instrument. (5) Returns an instrument handle which is used to distinguish between different
sessions of this instrument driver. Note: Each time this function is invoked a unique session is
opened.
Parameters:
Resource_Name: This parameter specifies the device (resource) with which to establish a
communication session.
ID_Query: This parameter specifies whether an identification query is performed during the
initialization process. False ‐ Skip query. True ‐ Do query.
Reset_Device: This parameter specifies whether the instrument is reset during the initialization
process. False ‐ no reset. True ‐ instrument is reset
Returns:
This function constructs a PM100D object which can be used to communicate with the device.
Summary:
This function sets the user’s wavelength in nanometers [nm]. Remark: Wavelength set value is
used for calculating power.
Parameters:
Wavelength: This parameter specifies the user’s wavelength in nanometers [nm]. Remark:
Wavelength set value is used for calculating power.
Returns:
The function returns an integer which indicates if an error occurred. A return of 0 indicates no
error.
Summary:
This function is used to obtain power readings from the instrument.
Parameters:
Power: A variable to which the power measurement is written.
Returns:
The function returns an integer which indicates if an error occurred. A return of 0 indicates no
error.
namespace PM100x_C_Sharp_Example
{
class Program
{
static void Main(string[] args)
{
//Create PM100D object.
//The device resource name can be found by running the Thorlabs Optical Power
Meter Utility.
PM100D pm = new PM100D("USB0::0x1313::0x8072::P2002734::INSTR",true,true);
//set wavelength
pm.setWavelength(1064);