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:
Returns:
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:
Returns:
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:
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:
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:
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:
Returns:
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:
Returns:
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