Getting Started with IVI-COM and Python for the Lambda Genesys Power Supply



Similar documents
To perform Ethernet setup and communication verification, first perform RS232 setup and communication verification:

Getting Started Guide

Agilent Technologies. Connectivity Guide. USB/LAN/GPIB Interfaces. Agilent Technologies

IVI Configuration Store

R&S AFQ100A, R&S AFQ100B I/Q Modulation Generator Supplement

B&K Precision 1785B, 1786B, 1787B, 1788 Power supply Python Library

Metasys System Direct Connection and Dial-Up Connection Application Note

Using HyperTerminal with Agilent General Purpose Instruments

Quick Note 32. Using Digi RealPort with a Digi TransPort Router. UK Support September 2012

Connecting the DG-102S VoIP Gateway to your network

Application Note CTAN #374

Huawei E169 & E220 Status Lights

Tutorial: Configuring GOOSE in MiCOM S1 Studio 1. Requirements

Title Release Notes PC SDK Date Dealt with by, telephone. Table of Content GENERAL... 2

Work with Arduino Hardware

1. MOXA NPort Express TCP/IP to RS-232 server

Centurion PLUS CPC4 Download Guide

Application Note: Connecting to a 2500 Series Processor using PLC Workshop

IVI Instrument Driver Programming Guide (Visual Basic 6.0 Edition)

ReadMe File. Installing the Unified Messaging Application for

enervista UR Setup Software Quick Connect Instructions:

XStream Remote Control: Configuring DCOM Connectivity

JAVS Scheduled Publishing. Installation/Configuration... 4 Manual Operation... 6 Automating Scheduled Publishing... 7 Windows XP... 7 Windows 7...

1. TIB388 about the Windows compatibility of all Mutoh devices subdivided in

R&S AFQ100A, R&S AFQ100B I/Q Modulation Generator Supplement

ezvsp User's Manual ( Version 2.1d ) Sollae Systems Co., Ltd.

Ethernet. Customer Provided Equipment Configuring the Ethernet port.

SECTION 3 - INSTALLATION

User Manual. Thermo Scientific Orion

WindO/I-NV2 Utility Pass-Through Tool

Guide to Installing BBL Crystal MIND on Windows 7

Using MCC GPIB Products with LabVIEW

Getting Started with IVI Drivers

VIRTUAL INSTRUMENTATION

DUKANE Intelligent Assembly Solutions

SatTerm-G SOFTWARE MANUAL FOR A3LA-IG

SUDT AccessPort TM Advanced Terminal / Monitor / Debugger Version 1.37 User Manual

BASLER ACE QUICK INSTALLATION GUIDE

Title Release Notes PC SDK Date Dealt with by, telephone. Table of Content GENERAL Corrected Issues PDD...

HP Point of Sale (POS) Peripherals Configuration Guide ap5000 VFD Windows (non-opos)

Short Manual Intellect v SP2 module Unipos Contents:

About This Guide SolarEdge Configuration Tool Software Guide. About This Guide

EVALUATION ONLY. WA2088 WebSphere Application Server 8.5 Administration on Windows. Student Labs. Web Age Solutions Inc.

The care and feeding of Pythons at the Redmond Zoo. (Using Micro Python and pyboard with Windows)

Programming Guide. Agilent Technologies PSG Signal Generators. Manufacturing Part Number: E Printed in USA December 2003

SAPIP GUI INSTALLATION. Table of Contents

PM1122 INT DIGITAL INTERFACE REMOTE

LockView CompX Database & Network Configuration & Installation Manual

Test Center Enterprise. ios Device Onboarding Guide

Web Remote Control SA Software Installation and Setup

3.1 RS-232/422/485 Pinout:PORT1-4(RJ-45) RJ-45 RS-232 RS-422 RS-485 PIN1 TXD PIN2 RXD PIN3 GND PIN4 PIN5 T PIN6 T PIN7 R+ PIN8 R-

Midland BT Updater BTUpdater Program Program file (x86) ), Midland

Part Number Revision A, January Monitoring System Rack Configuration and Utilities Guide

Getting Started Guide

Remote Access Server - Dial-Out User s Guide

Guest PC. for Mac OS X. User Guide. Version 1.6. Copyright Lismore Software Systems, Ltd. All rights reserved.

Command Line Interface User Guide for Intel Server Management Software

Software for Agilent Technologies Vector Series Network Analyzers

FileMaker 12. ODBC and JDBC Guide

USER GUIDE. Ethernet Configuration Guide (Lantronix) P/N: Rev 6

T-BOXN12R. First steps with T-BOXN12R. You can make it wireless. Date: Version 1.0

Installing S500 Power Monitor Software and LabVIEW Run-time Engine

PN L, Revision B, October Epic 950 TM. Master Programmer User s Guide

Current Cost Data Cable User Guide. Installing and configuring the data cable

NStar Build 648. Release Notes. Page 1 of 17

LockView 4.2 CompX Database & Network Configuration & Installation Manual

SMS Alarm Messenger. Setup Software Guide. SMSPro_Setup. Revision [Version 2.2]

CONFIGURATION AND APPLICATIONS DEPLOYMENT IN WEBSPHERE 6.1

Gauge Drawing Tool Slider Drawing Tool Toggle Button Drawing Tool One-Way List Drawing Tool... 8

Programming Guide. (With Remote Operation and File Downloads) Agilent Technologies Signal Generators

2-Port RS232/422/485 Combo Serial to USB2.0 Adapter (w/ Metal Case and Screw Lock Mechanism) Installation Guide

Contents. 1 Introduction Purpose Target audience Overview... 3

Iridium Extreme TM Satellite Phone. Data Services Manual

Prestige 314 Read Me First

INSTALLATION GUIDE. AXIS Camera Station

Adafruit's Raspberry Pi Lesson 5. Using a Console Cable

The RT module VT6000 (VT6050 / VT6010) can be used to enhance the RT. performance of CANoe by distributing the real-time part of CANoe to a

Different Ways of Connecting to. 3DLevelScanner II. A.P.M Automation Solutions LTD. Version 3.0

R&S AFQ100A, R&S AFQ100B I/Q Modulation Generator Supplement

Configuring the Network Automation Engine (NAE)

How To Use An Nio V (Ios) With A Simioni V2 (V2.3) And V2

Moxa Device Manager 2.0 User s Guide

Installation Guide PSP Installation. Rev SRP-350plusII SRP-352plusII.

LAN Interface. TDK-Lambda Americas Inc.

Special Note Ethernet Connection Problems and Handling Methods (CS203 / CS468 / CS469)

Intelligent Power Protector User manual extension for Microsoft Virtual architectures: Hyper-V 6.0 Manager Hyper-V Server (R1&R2)

User s Manual TCP/IP TO RS-232/422/485 CONVERTER. 1.1 Introduction. 1.2 Main features. Dynamic DNS

Hypercom Key Loading and Management (HKLM) RS232 PPP Key Injection PC Setup Guide

Lab Diagramming External Traffic Flows

TSX ETZ Configuration of your computer for TSX ETZ direct connection by serial link. Eng V1.0

USB PC Adapter V4 Configuration

Web Enabled Software for 8614xB-series Optical Spectrum Analyzers. Installation Guide

4469 en / c. Ready. Run Start. Stop LCL RMT. Reset USB MODULE. Communications module. User Guide

Status Monitoring. Using Drivers by Seagull to Display Printer Status Information WHITE PAPER

InventoryControl for use with QuoteWerks Quick Start Guide

IP Link Device Interface Communication Sheet

T3 Mux M13 Multiplexer

ABB solar inverters. Installation and setup instruction Aurora Manager TL software and ABB PVI-USB-RS232_485 adapter

Operating Instructions

Issue Tracking Anywhere Installation Guide

Transcription:

Page 1 of 16 1. Introduction This is a guide to writing programs using the Python language with the Lambda IVI-COM drivers. Python is praised for being simple but powerful. It is open-source and may be installed at no cost. Many standard libraries and 3d party extensions are available. IVI (Interchangeable Virtual Instrument) is a design by the global IVI Foundation to simplify the way equipment is used with computer automation programs. This guide will allow you to remotely control the Genesys power supply using the RS-232/485, IEEE-488 or LAN interfaces. 2. Table of Contents 1. Introduction...1 2. Table of Contents...1 3. Requirements...2 4. Installation Instructions...3 5. Your First Program Using Python...5 6. The Initialize Step...8 7. Catching Errors with Exceptions...12 8. Catching Errors with SYST:ERR?...13 9. Programming with the RS-232/485 Port...14 1. Programming with the LAN Port...16 Table of Figures Figure 1. Launching IVI "Help"...4 Figure 2. Sample of IVI "Help"...4 Figure 3. Launching PythonWin...5 Figure 4. Intellisense...6 Figure 5. Example Python Session...7 Figure 6. Simulating an Instrument...1 Figure 7. Enabling Automatic Error Query...1 Figure 8. Enabling a Simulated RS-232 Instrument...11 Figure 7. Using COMexception to Catch Errors...12 Figure 8. Using SYST:ERR to Catch Errors...13 Figure 9. Initializing the RS-232 Port...14

Page 2 of 16 3. Requirements A. Windows Operating System: This tutorial is written using Windows XP SP2. Because of the requirement for VISA hardware drivers and COM objects, this tutorial cannot say that other operating systems are supported. B. Python Software: This tutorial requires the following downloads: 1. Python version 2.5.2. Earlier versions have not been tested. The comtypes package may not be compatible with earlier versions of Python. http://www.python.org/download/ Used here: python-2.5.2.msi 2. PythonWin build 211 Python extensions for Windows. This is a Windows graphical development environment for compiling Python projects. http://sourceforge.net/project/platformdownload.php?group_id =7818 Used here: pywin32-211.win32-py2.5.exe 3. comtypes version.4.2 This is a 3d party Python extension to allow early binding of COM objects with unknown interfaces. http://pypi.python.org/pypi/comtypes/.4.2 Used here: comtypes-.4.2.win32.exe C. IVI Drivers: The Lambda Genesys IVI driver package must be installed. It is available as a download from: http://www.lambda-hp.com/product_html/genesys1u.htm Click on the Documentation Download Drivers link to register. Install the file LambdaGenPS.2.x.x.x.msi on your computer D. VISA Drivers: The IVI drivers are built upon a layer of hardware drivers called VISA (for Virtual Instrument Software Architecture ). These drivers may be obtained from a variety of companies who support test and measurement.

Page 3 of 16 The runtime versions of the VISA drivers are acceptable, but you will not have the communications utilities or the IVI configuration manager to create logical device names. E. Electrical Interface: almost all personal computers have an RS-232 port or a local area network (LAN) port. If your Genesys power supply uses the RS-485 or IEEE-488 (IEMD option) ports, you will need to install these interface cards into your computer or laptop. F. Prior Experience with Python: This tutorial assumes very little prior experience with Python programming. It will do nothing more than use the PythonWin Interactive screen to create the Genesys supply IVI-COM object and send a few commands. 4. Installation Instructions Download the files listed in the Requirements section above. Then: A. Install the Python Program You will create a folder such as: C:\Python25\ B. Install the PythonWin Program You will create a folder and program such as: C:\Python25\Lib\site-packages\pythonwin\ Pythonwin.exe C. Install the Python comtypes Extension You will create a folder such as: C:\Python25\Lib\site-packages\comtypes\ D. Install the Genesys IVI Drivers You will create a folder and library such as: C:\Program Files\IVI\Bin\ LaGen.dll E. Install the VISA Drivers You will create a folder such as: C:\VXIPNP\ or C:\Program Files\VISA\ or other

Page 4 of 16 F. Additional Help A discussion of the Python interface for COM objects may be found at: http://starship.python.net/crew/theller/comtypes/ Information on the IVI-COM drivers, including the commands and settings, is installed by the Lambda Genesys IVI driver package. A Getting Started and language reference Help is included. This help file may be opened through the Start menu as shown below: Figure 1. Launching IVI "Help" Below is a sample of the Help file s contents: Figure 2. Sample of IVI "Help"

Page 5 of 16 5. Your First Program Using Python A. Launch PythonWin. On the Windows Start menu, launch PythonWin as shown below. Figure 3. Launching PythonWin

Page 6 of 16 B. Create the Power Supply Object At the Python >>> prompt, type the lines: >>> PS1 = CreateObject( "LambdaGenPS.LambdaGenPS") PS1 is an arbitrary name created to identify the reference to the power supply object. You may choose any name. The first time you run the CreateObject command, a list of Generating comtypes. notices are displayed. After this, when you begin to type commands to the PS1 object, you will see the Intellisense list boxes appear as shown below: Figure 4. Intellisense C. Initialize the Genesys Power Supply Once the COM object is created, the first step is to initialize it. This step is used to select the instrument (including what bus it is using and it s address) and do other things. In the Figure 5 example below, the step: PS1.Initialize( "GPIB::6::INSTR", False, False, ) will assign a name PS1 and open communication with a Genesys power supply at IEEE address 6. This step will also verify that communication can be established with the power supply. See section 6 for much more information on the Initialize step.

Page 7 of 16 D. Communicate with the Genesys Power Supply Once the Genesys IVI-COM object is initialized (named PS2 in the figure below), you can start communicating with it. The Intellisense (see Figure 4) guides you through the choices of properties and methods for the PS2 object. More specific details about them may be found in the IVI online Help as shown in Figure 2. PythonWin 2.5.2 (r252:6911, Feb 21 28, 13:11:45) [MSC v.131 32 bit (Intel)] on win32. Portions Copyright 1994-28 Mark Hammond - see 'Help/About PythonWin' for further copyright information. >>> PS2 = CreateObject( "LambdaGenPS.LambdaGenPS") >>> PS2.Initialize( "GPIB::6::INSTR", True, True, "") >>> PS2.Output.VoltageLimit = 5 >>> PS2.Output.CurrentLimit = 1 >>> PS2.Output.Enabled = True >>> PS2.Output.MeasureVoltage( ) 5.19999999999998 >>> PS2.Identity.InstrumentModel u'gen3-25-iemd' >>> PS2.Utility.Reset( ) >>> PS2.Close( ) >>> PS2.Release( ) L >>> Figure 5. Example Python Session

Page 8 of 16 6. The Initialize Step Once the COM object is created, the first step is to initialize it. An example is shown in the third command in Figure 5: PS1.Initialize( "GPIB::6::INSTR", False, False, ) This important step will: 1. Use a resource descriptor to: a. Identify the port type (IEEE, RS-232/485 or LAN). b. Describe the instrument s address on the bus. 2. Optionally, verify the supply s identity. 3. Optionally, reset the supply. 4. Optionally, set IVI options such as simulation and error checking. The initialize step will also verify that communication can be established with the power supply. A. Parameter 1: Select the Instrument This is a string name that specifies the Genesys port type and address. The name may be one of: 1. VISA resource descriptor. If you only have the VISA runtime engine installed, you must use this form. Examples of use are: For the IEEE bus: "GPIB::6::INSTR" for supply at IEEE address 6. For the RS-232/485 bus: "ASRL1::INSTR" for supply connected to the computer s serial port 1. The address and Baud rate are given in the option string, which is the fourth parameter. "COM1" is an alias which can usually be used for the computer s serial port 1. The address and Baud rate are given in the option string, which is the fourth parameter.

Page 9 of 16 For the LAN bus: "TCPIP::192.168.47.92::INSTR" for a supply connected to a local network. The supply s IP address, as read on it s front panel, is 192.168.47.92. "TCPIP::GENH3-25-827::INSTR" for a supply connected to a local network. The supply s hostname, as read on it s web LAN settings page, is GENH3-25-827. 2. IVI Logical Name. If you have a utility that can manage the IVI configuration, you can use Python to initialize an IVI logical device. This allows the use of the IVI interchangeability feature which means you can swap one manufacturer s power supply for another s without changing the Python program. IVI configuration utilities include the National Instruments Measurement and Automation Explorer (NI-MAX), the Agilent VEE Pro Instrument Manager and others. B. Parameter 2: Identity Query If this parameter is set to True, then the Initialize method will read the power supply s identity string ( *IDN? ) and verify that a Genesys supply is being initialized. C. Parameter 3: Reset If this parameter is set to True, then the Initialize method will reset the power supply. This includes setting the voltage and current to zero and the output off. Other settings are set to the default; see the User Manual. D. Parameter 4: Option String The fourth parameter may be empty, empty double quotes (a NULL string), or one of the following. Other parameter settings are available, only the most popular are shown below. See IVI Help, shown in Figure 1, for more options.

Page 1 of 16 Option String = Simulate=True Enabling the Simulate mode allows you to run the Python program even if no power supply is actually connected to the system. Commands are simulated and responses are fixed default values. >>> GenPS = CreateObject( "LambdaGenPS.LambdaGenPS") >>> GenPS.Initialize( "TCPIP::192.168.14.57::INSTR",False,False,"Simulate=True") >>> GenPS.Output.Enabled = True >>> GenPS.Output.Enabled True >>> GenPS.Identity.InstrumentModel u'genvvv-aaa-lan' >>> GenPS.Output.MeasureVoltage( ) 1.5 >>> Figure 6. Simulating an Instrument Option String = QueryInstrStatus=True This will cause an *ESR? query to be automatically sent after every command. If a command error, or other error, is returned, a COM exception will be thrown. See section 7 below for an example. >>> PS2.Initialize( "GPIB::6::INSTR", True, True, "QueryInstrStatus=True") Figure 7. Enabling Automatic Error Query

Page 11 of 16 Multiple Option Strings Multiple options are set by using a comma separator between the option parameter strings. Below is an example of simulating an RS-232 power supply: >>> PS1 = CreateObject( "LambdaGenPS.LambdaGenPS") >>> PS1.Initialize( "COM1",False,False,"Simulate=True,DriverSetup=SerialAddress=6,BaudRate=96") >>> PS1.Identity.InstrumentFirmwareRevision u'sim2..3.' >>> PS1.Output.VoltageLimit = 1 >>> PS1.Output.MeasureVoltage( ) 1.5 >>> Figure 8. Enabling a Simulated RS-232 Instrument

Page 12 of 16 7. Catching Errors with Exceptions When an IVI-COM method is called, it will return with a non-zero HRESULT value that describes a type of COM error. It will also throw a COMexception event. By default, COMexceptions will only report errors detectable by the computer, including unopened ports, cable disconnections or no responses from the power supply. By modifying the Initialize step (see section 6), the COMexception can be thrown for instrument errors such as an illegal command or a setting out of range. To do this, change the fourth parameter (Option String) in the Initialize step to: QueryInstrStatus=True This will cause the IVI driver check after every command to make sure the command was accepted by the power supply. If a command error occurred then a COMexception will be thrown. This method is shown in the Python session below. Notice the traceback after trying to set the supply above its rating, to one thousand volts: PythonWin 2.5.2 (r252:6911, Feb 21 28, 13:11:45) [MSC v.131 32 bit (Intel)] on win32. Portions Copyright 1994-28 Mark Hammond - see 'Help/About PythonWin' for further copyright information. >>> PS1 = CreateObject( "LambdaGenPS.LambdaGenPS") >>> # Notice, in line below, no spaces after commas >>> PS1.Initialize( "GPIB::6::INSTR",False,False,"QueryInstrStatus=True") >>> PS1.Output.Enabled = True >>> PS1.Output.VoltageLimit = 1 Traceback (most recent call last): File "<interactive input>", line 1, in <module> File "C:\Python25\Lib\site-packages\comtypes\ init.py", line 231, in setattr value) COMError: (-2147192831, None, (u'lambdagenps: Instrument error detected. Use ErrorQuery() to determine the error(s).', u'lambdagenps.lambdagenps.1', None,, None)) >>> Figure 9. Using COMexception to Catch Errors Although this COMexception method will display all types of errors at any time, this example does not show how to programmatically handle the exception. This example also does not show how to report the instrument error code or description.

Page 13 of 16 8. Catching Errors with SYST:ERR? For a program to be reliable, it is necessary to check for instrument errors. The COMexception example in the above section will catch an error event, but it does not report the instrument error code or description and it does not give any way to handle an error. A solution to handle instrument errors is shown below. The power supply has a system error queue that reports error codes and descriptions in a human readable string. The IVI-COM DirectIO method is used to send and read SCPI commands directly to the power supply. PythonWin 2.5.2 (r252:6911, Feb 21 28, 13:11:45) [MSC v.131 32 bit (Intel)] on win32. Portions Copyright 1994-28 Mark Hammond - see 'Help/About PythonWin' for further copyright information. >>> PS1 = CreateObject( "LambdaGenPS.LambdaGenPS") >>> # In next step, do not enable driver to do QueryInstrStatus >>> PS1.Initialize( "GPIB::6::INSTR",False,False, ) >>> # Enable the error queue and clear it >>> PS1.System.DirectIO.WriteString( "SYST:ERR:ENAB") >>> PS1.System.DirectIO.WriteString( "SYST:ERR?") >>> PS1.System.DirectIO.ReadString( ) u',"no error"' >>> # Now, send an illegal setting >>> PS1.Output.CurrentLimit = 1 >>> PS1.System.DirectIO.WriteString( "SYST:ERR?") >>> PS1.System.DirectIO.ReadString( ) u'-222,"data out of range;address 6"' >>> Figure 1. Using SYST:ERR to Catch Errors Note that setting CurrentLimit = 1 is not an error for the IVI driver so no COMexception was thrown. It is, however, an error for the power supply so the system error queue reported it. The response from the ReadString may be managed using the normal Python string functions.

Page 14 of 16 9. Programming with the RS-232/485 Port Writing IVI-COM programs for the RS-232/485 ports is the same as the example above for the IEEE interface. The only change is in the initialize option string A. RS-232 Initialize For the IEEE Initialize, the entire connection is defined in the VISA resource name string. For the RS-232/485 port, The VISA name only selects the computer s COM port (COM1, COM2 etc.). The Genesys address and the Baud rate are specified in the fourth parameter of the call to Initialize. This fourth parameter is an option string. In the example below, the following settings are shown: - ASRL1 = the computer s COM1 port is selected - DriverSetup= is the required start of the RS-232 string. - SerialAddress=6 is the Genesys front panel address setting. It may be a number from to 3. - BaudRate=96 is the Genesys front panel serial bits-per-second. It may be 12, 24, 48, 96 or 192 PythonWin 2.5.2 (r252:6911, Feb 21 28, 13:11:45) [MSC v.131 32 bit (Intel)] on win32. Portions Copyright 1994-28 Mark Hammond - see 'Help/About PythonWin' for further copyright information. >>> PS1 = CreateObject( "LambdaGenPS.LambdaGenPS") >>> # In next step, "ASRL1::INSTR" is the generic name for COM1 >>> PS1.Initialize( "ASRL1::INSTR",True,True,"DriverSetup=SerialAddress=6,BaudRate=96") >>> PS1.Identity.InstrumentManufacturer u'lambda' >>> PS1.Utility.Reset( ) >>> PS1.Output.CurrentLimit = 5 >>> PS1.value.Output.CurrentLimit 5. >>> Figure 11. Initializing the RS-232 Port

B. Catching Errors Page 15 of 16 For the serial RS-232 port, any setting out of range or other illegal command will generate a COMexception. There is no need to Initialize the driver with "QueryInstrStatus=True".

Page 16 of 16 1. Programming with the LAN Port Writing IVI-COM programs for the LAN port is the same as the example above for the IEEE interface. The only change is in the initialize option string. A. LAN Initialize with IP Address Like the IEEE Initialize, the entire LAN connection is defined in the VISA resource name string. Below is an example if the power supply auto-ip address is 169.254.7.58. PythonWin 2.5.2 (r252:6911, Feb 21 28, 13:11:45) [MSC v.131 32 bit (Intel)] on win32. Portions Copyright 1994-28 Mark Hammond - see 'Help/About PythonWin' for further copyright information. >>> PS1 = CreateObject( "LambdaGenPS.LambdaGenPS") >>> PS1.Initialize( "TCPIP::169.254.7.58::INSTR",False,False, ) >>> # Read the network hostname >>> PS1.System.DirectIO.WriteString( "SYST:COMM:LAN:HOST?") >>> PS1.System.DirectIO.ReadString( ) u'gen6-85-181' >>> B. LAN Initialize with Hostname If the LAN power supply is connected through a network server, it s hostname may be registered by the NBNS or DNS services. In this case, the hostname may be used in the VISA resource name string instead of the IP address. Below is an example if the power supply hostname is GENH3-25-827. PythonWin 2.5.2 (r252:6911, Feb 21 28, 13:11:45) [MSC v.131 32 bit (Intel)] on win32. Portions Copyright 1994-28 Mark Hammond - see 'Help/About PythonWin' for further copyright information. >>> PS2 = CreateObject( "LambdaGenPS.LambdaGenPS") >>> PS2.Initialize( "TCPIP::GENH3-25-827::INSTR",True,True, ) >>> PS2.Identity.InstrumentModel u'genh3-25-lan' >>>