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 Pickering PXI Installer Package. This can be found at the following addresses:


Install Using pip

To install Python Pilpxi 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 Pilpxi manually please copy the pilpxi module from the extracted directory to your working directory.


Using Pilpxi

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

List cards

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

Open Card

Cards are opened when the Pi_Card constructor is called. It takes bus and slot numbers in a tuple as parameters as shown below:

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-Pilpxi 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 blank subunit:

Operate Resistor Cards

Resistor cards come in two varieties: Programmable Resistor, and Precision Resistor. Programmable Resistors are controlled like Switch Cards shown above. Precision 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 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. It returns the set voltage. 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 functions for controlling them. To set voltage use BattSetVoltage() providing the subunit and voltage. To retrieve the set voltage 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. It returns the set current. To enable output use BattSetEnable() providing the subunit and the state to be set. To retrieve the present output state use BattGetEnable(). It returns the state. On supported battery simulator cards, BattMeasureVoltage() and BattMeasureCurrentmA() functions are available to measure live actual voltage and current values from the card's output. 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. It returns the range. 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. It returns the state of the requsted bit. 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 pilpxi.Attributes.TS_TEMPERATURES_C or pilpxi.Attributes.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 handling

Most of the functions in Pilpxi will raise an exception on errors. To handle pilpxi.Error exceptions and obtain error messages and (optionally) an error code from the driver:

Close Cards

A card should be closed when it is no longer being used. To close a card CloseSpecifiedCard is used as shown below:

Migrating from old versions of the Python Pilpxi wrapper

From wrapper version 1.0 onwards, major changes were made to the Python pilpxi 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.