Skip to content

PA5 Programmable Attenuator

About the PA5x Methods

This section provides a listing of the available PA5x ActiveX control methods.

Programming Steps

Add the PA5x ActiveX controller to your program. The ActiveX help has examples for setting up ActiveX controllers in MATLAB and Python.

Connect to a PA5 (USB or GB) device with the connectPA5 function.

Control the PA5 with the command and control functions using the ActiveX controller.

ConnectPA5

Establishes a connection with the specified device. The connection is established through either the Optical Gigabit or USB interface. Invoking this method causes the control to search for the specified device and establish a handle to the associated device driver. The method will return a '1' if a connection was successfully established or a '0' if the device is not present or if it is not functioning properly.

Long ConnectPA5(string Interface, int DevNum);

Arguments:

Type Argument Description
string Interface Interface to which the device is connected.
Argument Connection Part #s
'GB' Optical Gigabit PO5/PO5e
'USB' USB UZ2, UB2, UZ1, UZ4
Type Argument Description
int DevNum Logical device number. Starts with 1 and counts upward for each device of a specified type.

Returns:

Type Value Description
int 0 Connection not successful.
int 1 Connection successful.

MATLAB

Connects to PA5#1 via Optical Gigabit

% Connects to PA5 #1 via Optical Gigabit
PA5x1=actxserver('PA5.x');
if PA5x1.ConnectPA5('GB',1)==1 
  e= 'connected'
else
  e= 'Unable to connect'
end

Display

Prints text to the PA5's LED display.

BOOL Display(string Text, int Position);

Arguments:

Type Argument Description
string Text String to be printed to the display (max length eight characters).
int Position Position in display: 0=left, 7=right.

Returns:

Type Value Description
Boolean False (0) Not successful.
Boolean True (-1) Successful.

Displays a warning.

PA5x1.Display('Check Attenuation', 0);

GetError

Use this call to retrieve an error message or to test for an error. Returns a string containing one of the following error messages:

zBus Error: - This shows where the error occurred

Call:PA5setatt - What function call was attempted

zError:One or more arguments out of range. - Error message

string GetError;

Returns:

Type Value Description
string error Error message.

Checks for an error message and displays it on the PA5 if one is returned.

ErrMess = PA5x1.GetError
if length(ErrMess) > 0
  disp ErrMess
end

GetAtten

Returns the current level of attenuation on the PA5 as a value from 0-120. It is not altered by user-defined attenuation levels.

float GetAtten;

Returns:

Type Value Description
float attenuation on PA5

MATLAB

Starts an active X control for the PA5, connects to PA5 #1 through the GB port and gets the current attenuation setting for the PA5.

PA5x1=actxserver('PA5.x')
PA5x1.ConnectPA5('GB', 1) % Connects PA5 via Optical Gigabit
z=PA5x1.GetAtten

Reset

Resets the PA5 and restores the factory defaults.

Factory defaults are: Attenuation=0.0, Step size =3.0, Update=Dynamic.

BOOL Reset;

Arguments:

None

Returns:

Type Value Description
Boolean False (0) Not successful.
Boolean True (-1) Successful.

Starts ActiveX control, connects to the PA5 via the GB interface, and resets the PA5 to the factory defaults (0.0 attenuation).

PA5x1=actxserver('PA5.x');
PA5x1.ConnectPA5('GB', 1) % Connects PA5 via Optibit
PA5x1.Reset

SetAtten

Sets attenuation on the PA5. Attenuation is a floating point value between 0.0 and 120. Values higher and lower than these values will set an error flag. You can use GetError() to check for error messages.

BOOL SetAtten(float AttVal);

Arguments:

Type Argument Description
float AttVal Attenuation (0.0...120.0).

Returns:

Type Value Description
Boolean False (0) Not successful.
True (-1) Successful.

Sets the Attenuation to the value given by "Atten" and checks for an error. If "Atten" is greater than 120 or less than zero an error message is generated.

PA5xl.SetAtten(Atten);
errorl=PA5xl.GetError()
if length(error1)==0
  disp 'Attenuation set correctly'
else
  PA5xl.Display(errorl, 0)
end

SetUser

Sets parameters for User Attenuation mode. For a complete description of how these work, check the TDT online help. A brief description of each function is given below along with an ActiveX example.

Note: User values are used for comparison and display purposes only. They do not affect the values for or . They should only be used to quickly assess signals from several PA5's using the front panel display.

BOOL SetUser(int ParCode, float Val);

Arguments:

Type Argument Description
int ParCode Code for specific parameter.
ParCode Parameter Constants (Name)
1 PA5_USERPAR_BASE: Set base attenuation (0.0 .. 120.0 dB). Base attenuation is used when several stimulus devices (speakers) vary in signal intensity. Setting the base for each speaker will display the same attenuations.
2 PA5_USERPAR_STEP: Set dB step size (0.0 .. 120.0 dB)
3 PA5_USERPAR_REFERENCE: Set Reference dB Level (0.0 .. 120.0 dB). Reference attenuation allows the user to display smaller numbers (including negative ones). For example, for a Reference of 120 the most intense signal would display 120 dB on the front panel and the least intense signal would display 0.0 under user settings.
4 PA5_USERPAR_UPDATE: Sets User Update Parameter. DYNAMIC updates produce a continuous change in attenuation. MANUAL update only changes the attenuation when the Select button (dial) is pressed. The display is dimmed while changing the attenuation. Use PA5_USERUPDATE_DYNAMIC or PA5_USERUPDATE_MANUAL for Val argument.
5 PA5_USERPAR_ABSMIN: Set minimum level of attenuation allowed on the PA5. Used to prevent accidental output of very loud sounds.
Type Argument Description
float Val Value for given parameter code.

Returns:

Type Value Description
0 Not successful.
-1 Successful.

Sets up a series of constants that match the values used for 'SetUser'. Some parameter values for the different User functions are set. Finally the code sends all of the variables to the PA5. The user is given 5 seconds to change the setting and see the difference between the value that the userAtten displays and the base value for the attenuator.

PA5x1=actxserver('PA5.x');
PA5x1.ConnectPA5('GB', 1) % Connects PA5 via Optibit
% Constants used by Setuser
PA5_USERPAR_BASE=1;
PA5_USERPAR_STEP=2;
PA5_USERPAR_REFERENCE=3;
PA5_USERPAR_UPDATE=4;
PA5_USERUPDATE_DYNAMIC=0;
PA5_USERUPDATE_MANUAL=1;
PA5_USERPAR_ABSMIN=5;
% Parameter values used for Setuser
Base=5;
Step=5;
Reference=120;
Absmin=20.0;
% Invoke commands for SetUser
PA5x1.SetUser(PA5_USERPAR_BASE, Base);
PA5x1.SetUser(PA5_USERPAR_STEP, Step);
PA5x1.SetUser(PA5_USERPAR_REFERENCE, Reference);
PA5x1.SetUser(PA5_USERPAR_ABSMIN, Absmin);
PA5x1.SetUser(PA5_USERPAR_UPDATE,PA5_USERUPDATE_DYNAMIC);
pause(1)
% Check the values
PA5x1.GetAtten