This python module [newport_1918c.py] contains high 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
This module is written for Python 2.7. It should also work with Python 3+ with minor modifications
Click here to download the newport powermeter Application and driver
-
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.
See Here fore more detailed explaination !
- 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
