README

Installation Instructions

We provide both a python module that can be installed to the system using pip and can be added manually to a project by copying a file into the directory that you are working in. For either installation method please make sure that you have installed ClientBridge. If you intend to use ClientBridge with PXI please make sure you also install Pickering PXI Installer Package. These can be found at the following addresses:

Please note that there is an additional dependency 'enum34' for Python 2.x and Python 3.x versions < 3.4. This package must be installed prior to using the wrapper with older versions of Python.


Install Using pip

To install Python Pilxi using pip open a command line prompt and navigate to the directory the driver has been extracted to. From there enter the following command:


Install Manually

To install Python Pilxi manually please copy pilxi directory containing __init__.py to your project.


Using Pilxi

Pilxi can be used to control our 40/50/60 series pickering products.

Open a session with LXI

In order to query an LXI unit and open/operate cards, you must first open a session. This can be done by passing an IP address to the pilxi.Pi_Session constructor. To use local PXI cards, pass "PXI" in place of the IP address.

List cards

To get a list of the available cards IDs use GetUsableCards(). This will return a list of card IDs. To list the bus and slot number for all of the cards use FindFreeCards(), which takes in the total card count. Please see below for worked examples on how to use both of these functions:

Open Card

There are three ways to open a card:

  • Using the Bus and Device number
  • Using the Card ID and Access mode
  • Using an alias specified using Resource Manager

To open a card at a specific bus and device location, use Pi_Session.OpenCard(bus, device). When opening a card with Bus and Slot number only one program can access the card at a time, which means that you cannot have another program monitor the card. To do that the card needs to be opened with the Card ID and specifying the Access mode to allow multiple programs at once. The Card ID can be obtained from the list of cards show in the earlier example. Please see below for a worked example on how to use pi_card in either way:

Aliases must be specified in the Resource Manager application. From there you can save a copy of the resource file locally which can be copied into your project directory for easy access. You can then open a card by alias using the pilxi.Pi_Card_ByAlias class:

Operate Switching cards

There are three main types of switching cards: - Switches - Multiplexer - Matrix

To operate Switches and Multiplexers use OpBit() providing subunit, switch point, and switch state. Matrices can be controller using OpCrosspoint() which requires the subunit, row, column, and switch state. Please see below for worked examples on using these functions:

Using Subunit States

The Python-Pilxi wrapper contains methods to read entire subunit states, e.g. the current switch configuration of a switching or matrix card, manipulate these states and apply the state back to the card in one single operation. This means, for example, multiple crosspoints can be connected at once, or the user may have multiple desired matrix/switch states and alternate between them.

Example for manipulating matrix card states:

Example for manipulating switching card states:

It is also possible to obtain a subunit state object representing a clear subunit:

Operate Resistor Cards

Resistor cards come in two varieties: Programmable Resitor, and Presision Resistor. Programmable Resistors are controlled like Switch Cards shown above. Presision Resistor Cards have specific resistor functions. To set a resistance ResSetResistance is used and to get the current resistance ResGetResistance is used as shown below:

Operate Attenuator

Attenuators have specific functions for controlling them. To set attenuation use SetAttenuation() providing the subunit and attenuation expressed in decibels. To retrieve the current attenuation use GetAttenuation() giving the subunit. It returns an error code and the attenuation expressed in decibels. Please see below for worked examples on how to use these functions:

Operate Power Supply

Power Supplies have specific functions for controlling them. To set voltage use PsuSetVoltage() providing the subunit and voltage. To retrieve voltage use PsuGetVoltage() giving the subunit. To enable output use PsuEnable providing the subunit and the state to be set. Please see below for worked examples on how to use these functions:

Operate Battery Simulator

Battery Simulators have specific methods for controlling them. To set voltage use BattSetVoltage() providing the subunit and voltage. To retrieve the voltage set use BattGetVoltage() giving the subunit. To set current use BattSetcurrent() providing the subunit and current. To retrieve the set current use BattGetcurrent() giving the subunit. To enable output use BattSetEnable() providing the subunit and the state to be set. To retrieve the present output state use BattGetEnable(). On supported Battery Simulator cards, real channel voltage and current can be measured back using BattMeasureVoltage() and BattMeasureCurrentmA() methods. Please see below for worked examples on how to use these functions:

If you attempt to enable the outputs of a battery simulator card without the hardware interlock, BattSetEnable() will throw an exception (error code 70, hardware interlock error). Therefore it is important to call functions in a try block and handle errors appropriately.

41-752A-01x functionality

The 41-752A-01x battery simulator cards have extra capabilities beyond what is supported by other cards. Please consult your manual for information on your product's capabilities. Worked examples on using the extra functionality are below:

Operate Thermocouple Simulator

Thermocouple Simulators have specific functions for controlling them. To set the range use VsourceSetRange() providing the subunit and the range. To retrieve the range use VsourceGetRange() providing the subunit. To set the voltage use VsourceSetVoltage() providing the subunit and the voltage in millivolts. To retrieve the voltage use VsourceGetVoltage() providing the subunit. It returns the voltage in millivolts. To enable or disable outputs use OpBit() providing the subunit, bit number for the channel isolations, and the state that should be set. To retrieve the state of the outputs use ViewBit() providing the subunit and bit number for the channel isolations. Please refer to the product manual for more information on what subunit and bits to operate. To retrieve temperature readings from a connected thermocouple compensation block us VsourceGetTemperatures() providing either card.ATTR["TS_TEMPERATURES_C"] or card.ATTR["TS_TEMPERATURES_F"] for temperature unit. It will return a list of four temperatures. Please see below for worked examples on how to use these functions:

Error Codes

Most of the functions in python-pilxi will raise an exception on any errors. The exception is defined in the python module you are using e.g. pilxi, pi620lx, pipslx.

Close Card/Session

A card and session can be closed when it is no longer used, or the object's destructor can be called:

Using Pipslx

Pipslx python module can be used to control Pickering Power Sequencer, for example 600-200-001. (Remote AC power management switch)

Here is a code snippet, how to connect to Power Sequencer, begin the startup and shutdown sequences, as well as getting and setting individual channel states:

Using Pi620lx

The Pi620lx python module can be used to control Pickering 41-620 Function Generator cards installed in an LXI chassis. The 41-620 3-channel function generator card can be used to generate arbitrarily defined waveforms, as well as standard waveforms such as sine, square and triangle with variable attenuation and DC offsets.

Here is some example code for controlling the 41-620 card using Pi620lx:

Migrating from old versions of the pilxi Python wrapper

From wrapper version 4.0 onwards, major changes were made to the Python pilxi wrapper API. Most notably, opening/listing cards and error handling conventions have changed. The new wrapper does not rely on returning an integer error code from every method, as is conventional in a C program. Instead. Python-style exceptions are raised, and the exception contains attributes giving the integer error code, and a human-readable description of the error.

Old wrapper example:

New wrapper example:

Function signatures remain largely identical between versions of the wrapper, except error codes are not returned. Therefore, previously a function returning a value would also return an error code:

Would now become:

Errors would be caught in a try/except block.

How did we do?
0 out of 0 people found this helpful.