Optical power meters in-conjunction with a detector are used to measure power from a laser source or monochromatic output. At work, we use Newport 1918 power meter. This power meter comes with its own software. However, I was interested in controlling this instrument with python. I made a class for this instrument . If you are interested you can download it at my Github repostitory .
This python module contains higher level functions to communicate with Newport 1918 power meter on a Windows computer. It uses python ctypes to access methods in the Newport’s usbdll.dll driver.
For connecting the hardware to the computer, see the reference manual
- On a 32 bit computer:
- Unzip the file
- Install the drivers and the power application found PowerMeter 3.0.2\win32
- run both PMSetup32.msi and USBDriverSetup32.msi (in sub folder). This should install drivers and the newport powermeter application at C:\Program Files\Newport
- LIBNAME (argument that is needed to intialize the instrument) in the case will be r’C:\Program Files\Newport\Newport USB Driver\Bin\usbdll.dll’
- On a 64 bit computer:
- Unzip the file.
- Install the drivers and the power application found PowerMeter 3.0.2\x86Onx64
- run both PMSetup32on64.msi and USBDriverSetup32on64.msi (in sub folder). This should install drivers and the newport powermeter application at C:\Program Files (x86)\Newport
- LIBNAME (argument that is needed to intialize the instrument) in the case will be r’C:\Program Files (x86)\Newport\Newport USB Driver\Bin\usbdll.dll’
Before you run the python module, make sure that you can run the newport powermeter application. This will ensure that the drivers are installed properly and there is no problem communicating with the instrument.
The variable “product_id” is needed to intialize the instrument. For my case, the product_id was 0xCEC7. I am not sure if this will change on another computer. To find the product_id or PID,
- Open the Windows Device Manager
- Expand the Human Interface Devices node
- Double-click the device of interest — the USB Human Interface Device Properties window appears
- Click the Details tab.
- In the Property drop-down box, select Hardware Ids. The product id is some thinglike PID_ABC1, then use product_id = 0xABC1.
- There are many methods in the usbdll.dll, you can see all the methods in NewPDll.h. The methods I use to connect/disconnection and read/write commands are:
- newp_usb_init_system – this function opens all USB instruments.
- newp_usb_get_device_info – this function retrieves the USB address of all open instruments.
- newp_usb_get_ascii – this function reads the response data from an instrument.
- newp_usb_send_ascii – this function sends the passed in command to an instrument.
- newp_usb_send_binary – this function sends the passed in binary data to an instrument.
- newp_usb_uninit_system – this function closes all USB instruments.
- A full list of commands that can be sent to the instrument can be found in the reference manual