Controlling Newport 1918 Power Meter with Python

Newport 1918 power meter

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

Installing the powermeter and usbdriver

Click here to download the newport powermeter Application and driver

  • On a 32 bit computer:
    1. Unzip the file
    2. Install the drivers and the power application found PowerMeter 3.0.2\win32
    3. run both PMSetup32.msi and USBDriverSetup32.msi (in sub folder). This should install drivers and the newport powermeter application at C:\Program Files\Newport
    4. 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:
    1. Unzip the file.
    2. Install the drivers and the power application found PowerMeter 3.0.2\x86Onx64
    3. 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
    4. 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.

Getting the Product ID

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,

  1. Open the Windows Device Manager
  2. Expand the Human Interface Devices node
  3. Double-click the device of interest — the USB Human Interface Device Properties window appears
  4. Click the Details tab.
  5. In the Property drop-down box, select Hardware Ids. The product id is some thinglike PID_ABC1, then use product_id = 0xABC1.

See Here fore more detailed explaination !

Additional notes

  • 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:
  1. newp_usb_init_system – this function opens all USB instruments.
  2. newp_usb_get_device_info – this function retrieves the USB address of all open instruments.
  3. newp_usb_get_ascii – this function reads the response data from an instrument.
  4. newp_usb_send_ascii – this function sends the passed in command to an instrument.
  5. newp_usb_send_binary – this function sends the passed in binary data to an instrument.
  6. 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

2 thoughts on “Controlling Newport 1918 Power Meter with Python

  1. Thanks so much for this. I had to modify the libname directory to ‘..\Program Files\..’ instead of ‘..\Program Files (x86)\..’, but it worked great. I can confirm that my product ID 0xCEC7 is the same as yours.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>