Home
remote control of devices with a gpib and matlab
Contents
1. 26 3 4 1 Connect Disconnect eese eene ntn nne 26 A en 27 3 4 1 2 DISCODHeCt 27 3 4 1 2 1 Default values nn 27 342 Colect all TEAC S de itn en ois 27 3 42 T COlOUTS insert nennen 28 2 SEEBS aolet needed S tatit shua g 28 3 4 3 Colleet one Track e tet tee trie intei iet tns 20 3 14 NEW Trade iis 29 3 4 4 1 Active Traces in Remote Control 30 3 4 4 2 Traces Channels and Diagram Areas 30 3 4 4 3 Remote 31 IAS Delete a 32 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan 3 4 5 1 Remote control 32 3 21 06 Trace training a Ee A SS 32 3 4 6 1 Remote contio lessies 32 2 4 70 62 POE e au n hen 32 3 4 7 1 S Parameters ssec ener 33 3 4 7 2 Multiport Parameters 33 3 4 7 3 Remote control urasna sia 34 22456 o Lem O 35 3 4 8 1 Cartesian Diagrams 35 3 4 8 1 1 dB Ma since 36 3 48 A naa ee 36 34 8 1 3 Ra 36 SAS el A ma ein 37 3 4 8 2 Polar Diagrams 37 338 21 POLAR ia
2. New Trace Load Antenna D Collect All Traces elete Trace Collet one Trace Bandwidth Hz gt Plot Window Plot Window 50 1r me El 08 60 0 6 70 oat Number of Points 02 2 80 ot Power dBm 5 901 s IE 02 Start Frec Mhz 100 0 44 0 6 f Stop Frec Mhz 110 08 120 i i i 1 1 1 1 1 k k 1 1 4 2000 4000 6000 8000 0 02 03 04 05 07 08 09 1 FREQUENCY Mhz Figure 37 Trace Loaded It is possible to load one antenna without connecting with the Network Analyzer because the file is load from the PC 45 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan 4 HOW TO CREATE A GUI WIT MATLAB 4 1 What is Matlab MATLAB is a numerical computing environment and programming language Created by The MathWorks MATLAB allows easy matrix manipulation plotting of functions and data implementation of algorithms creation of user interfaces and interfacing with programs in other languages Although it specializes in numerical computing an optional toolbox interfaces with the Maple symbolic engine making it a full computer algebra system 4 2 How to create a GUI with Matlab 4 2 1 Handles Every object in Matlab has a handle The screen identificator is an integer while the graphical elements are float Matlab can have several windows but only one of them is the active window and every window can have several axes but only ones are the active axes Matla
3. 2 Power dBm 50 E Start Frec Mhz 100 I iin nap 100 L 1 34 Stop Frec Mhz 150 150 200 i 200 i i i i 0 l i 50 100 150 200 10 20 30 40 50 Figure 32 Number of Points Sets the total number of measurement points per sweep The minimum number of points 1s 2 Together with the sweep range defined with the Stimulus settings this parameter defines the grid of sweep points The sweep points are equidistantly distributed over the entire sweep range The step width between two consecutive sweep points is constant on a linear scale sweep types Lin Frequency Time and CW Mode or on a logarithmic scale sweep types Log Frequency and Power In Segmented Frequency sweeps the number of points can be set independently for each segment As an alternative to the Number of Points the Stimulus Step Size can be set A large number of points improves the resolution of the trace but increases the measurement time A small number of points causes wide trace segments so that the out of tolerance regions can appear wider as they are The overall measurement time is composed of a hardware settling time at the beginning of the sweep plus the sum of the measurement times at each individual sweep point This implies that the measurement time increases roughly linearly with the number of points 39 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan After changing the channel set
4. yu Qa ata s us a uA Q gs 49 42 34 Callback usada 30 E pachu 52 6 Future Development 53 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan 4 Result and DISCUSSION ionis an an ea 54 Ackno Wide 55 Referentes MM vine ha eee el 56 APPENDIX a tite npo NDA 57 Appendix 1 Source Code aciei eene set b etd ee beris 57 Appendix 2 GPIB Charactenictics u 2 2 2 na 74 Appendix 3 Labjack Functions with Matlab 76 Appendix 4 Network Analyzer Commond Commands 78 Appendix 5 SCPI Command 79 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB 1 INTRODUCTION We are going to use a Graphical User Interface GUI with Matlab to control a Network Analyzer and a Labjack U12 and a GPIB general purpose interface bus to connect the computer with the Network Analyzer There are sixteen antennas to obtain this sixteen antennas we have used the mulplexor HP 8761B with the multiplexors and the Labjack U12 we can select one of the different antennas The signals are going to be emited from one of the Network Analyzer outport this is received for other antenna which will be in a bucket that contains water or water and oil What we want is pick up the microwaves emited for the antenna which is in the outport in one of the receiving
5. fprintf g CALC d DATA FDAT x y str2num fscanf g hold grid on end if findstr f Trc15 fprintf g calc d par sel Trc15 x select the trace as the active trace fprintf g CALC d DATA FDAT x y str2num fscanf g plot y b hold on grid on end if findstr f Trc16 fprintf g calc d par sel Trc16 x select the trace as the active trace fprintf g CALC d DATA FDAT x y str2num fscanf g plot y g hold on grid on end function popupmenul CreateFen hObject eventdata handles hObject handle to popupmenul see GCBO eventdata reserved to be defined in a future version of MATLAB handles empty handles not created until after all CreateFcns called Hint popupmenu controls usually have a white background on Windows See ISPC and COMPUTER if ispc set hObject BackgroundColor white else set hObject BackgroundColor get 0 defaultUicontrolBackgroundColor end Executes on selection change in popupmenul function popupmenul_Callback hObject eventdata handles 7 FORMAT form handles varform format x handles varx channel g handles varg contents get handles popupmenu1 string returns popupmenul contents as cell array con contents get handles popupmenul value returns selected item from popupmenul 64 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan switch con case Magnitud fprintf g ca
6. stop All inputs are passed to proy_OpeningFen via varargin See GUI Options on GUIDE s Tools menu Choose GUI allows only one Instance to run singleton See also GUIDE GUIDATA GUIHANDLES Edit the above text to modify the response to help proy Last Modified by GUIDE v2 5 21 Mar 2006 11 52 53 Begin initialization code DO NOT EDIT gui_Singleton 1 gui State struct gui mfilename Singleton gui Singleton OpeningFcn proy_OpeningFen OutputFcn proy_OutputFcn LayoutFcn Callback if nargin amp isstr varargin 1 gui State gui Callback str2func varargin 1 end if nargout varargout 1 nargout gui mainfcn gui State varargin else gui mainfen gui State varargin end End initialization code DO NOT EDIT function proy OpeningFen hObject eventdata handles varargin Executes just before proy is made visible 57 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan handles output hObject disable buttons that would send controller commands if pressed disable text boxes as well set handles edit1 Enable off set handles edit2 Enable off set handles edit3 Enable off set handles edit4 Enable off set handles listbox 1 Enable off set handles listbox2 Enable off set handles listbox3 Enable off set handles popupmenul Enabl
7. Table of Contents Introduction O rs ae 6 2 Hardware A O O 10 2 J GPIB uuu A ND nun 10 2 1 1 InttOQdUCtlon si esee 10 2 1 2 The communication principle 12 2 1 3 GPIB Signals and Lines sace regentes 13 21 3 1 Data nes nenn sta 13 2 1 3 2 Handshake LInBeS n panaka asua 13 2 1 3 3 Interface Management Lines 13 2 1 4 GPIB Deyi ES is 14 DAS GPIBADB e etse aoi DU am READ ia eed 14 2 1 6 GPIB Limitations 15 2 1 7 GPIB Restrictions u s anasu Bapu a 15 O A Sr 16 2 GPIBSUSB ues o 17 2 3 Labjack AAA NT 18 2 3 1 Hardware Description 18 24 Acdent HP BI OL uu et id 20 2 5 Network Analyzer iaa alien 21 3 The Graphical User Interface a an 23 Sd Introduction ii dalla SE E 23 3 2 How a Graphical User Interface Wolks 29 3 2 TC OmpoHetils eek 23 3 22 A 23 3 2 3 CallbacK 45 5 oe iei ire 23 3 3 Graphical User Interface Components 24 3 32L uite i 24 3 3 2 Edit BOXES Sia eT ee ten 24 3 3 3 Pushb ttonS serate Rv n 24 5 3 4 Toggle BUON un ond b Be 24 9 29 Popup Mens ars 24 3 3 6 Last BOXES cites rtu 25 3 4 Graphical User Interface with Matlab
8. above and al 0 to a2 measured at PORT 2 3 4 7 2 Multiport Parameters The multiport S parameters extend the standard 2 port S parameters to a larger number of incoming and outgoing waves For a 4 port DUT b S S S a b _ S b 5 5 Se S a b ER 5 S 5 Figure 26 33 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan Where again ai i I to 4 denote the incident bi i I to 4 denote the outgoing waves and the Sparameters are expressed as S lt out gt lt in gt The indices of the S parameters described so far number the output and input ports of a DUT the parameters are referred to as single ended S parameters The S parameter description can also be used to differentiate between different propagation modes of the waves at the output and input ports This results in the so called mixed mode S parameters The analyzer measures either single ended or mixed mode S parameters 5 Paramebar 21 v Pert Configuration Physical Ports 3 1 4 2 Balenzed and Measured Ports Ok Cancel J Help Figure 27 Port Configuration e 3 4 7 3 Remote control CALCulate lt Ch gt PARameter MEASure lt Trace_Name gt S11 512 S13 S14 S21 S22 S23 S24 S31 S32 S33 S34 S41 542 43 44 34 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan 3 4 8 Format Popupmenu Dis
9. both 1 digit numbers e g 21 or both 2 digit numbers e g 2121 or 0133 3 4 7 1 S Parameters S parameters are the basic measured quantities of a network analyzer They describe how the DUT modifies a signal that is transmitted or reflected in forward or reverse direction For a 2 port measurement the signal flow is as follows 0 y A b Forward 5 49 e 2 rev Reverse measurement b E measurement er um 22 1 rev Port 1 DUT Port 2 Figure 25 S Parameters If the source and load ports are not ideally matched part of the transmittedwaves are reflected off the receiver ports so that an additional a2 contribution occurs in forward measurements an al contribution occurs in reverse measurements The four 2 port S parameters can be interpreted as follows e Sllisthe input reflection coefficient defined as the ratio of the wave quantities bl al measured at PORT 1 forward measurement with matched output and a2 0 e 521 is the forward transmission coefficient defined as the ratio of the wave quantities b2 a1 forward measurement with matched output and a2 0 e S12 is the reverse transmission coefficient defined as the ratio of the wave quantities bl reverse measurement with matched input bl rev in the figure above and al 0 to a2 e 522 is the output reflection coefficient defined as the ratio of the wave quantities b2 reverse measurement with matched input b2 rev in the figure
10. chain or star configuration attach any cables that connect to the other instruments first and then piggyback the GPIB USB as the last connector in the stack USB Port 33333 GPIB USB B GPIB Instrument with USB Cable Included Figure 13 Figure 14 GPIB USB 17 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan 2 3 Labjack U12 LabJacks are USB Ethernet based measurement and automation devices which provide analog inputs outputs digital inputs outputs and more LabJacks provide an easy to use interface between computers and the physical world 2 3 1 Hardware Description The external features of the LabJack U12 are USB connector DB25 digital I O connector D lines Status LED 30 screw terminals The USB connection provides power and communication No external power supply is needed The 5 volt connections available at various locations are outputs do not connect a power supply The DB25 connector provides connections for 16 digital I O lines called D0 D15 It also has connections for ground and 5 volts All connections besides D0 D15 are provided by the 30 screw terminals Each individual screw terminal has a label AIO through STB AIO AI7 The LabJack U12 has 8 screw terminals for analog input signals These can be configured individually and on the fly as 8 single ended channels 4 differential channels or combinations in between Each input has a 12 bit resolution and an inpu
11. 7 NEW TRACE creates a new trace and deletes the old trace x handles varx channel w handles varw trace g handles varg fprintf g calc d par del Trc d x w J deletes the old trace fprintf g calc d par sdef Trc9d s11 x w creates a new trace fprintf g disp windl trac d feed Trc d w w assigns the trace to the windowl fprintf g calc d par sel Trc d x w J oselects the trace as the active trace handles varw w guidata hObject handles function pushbutton5_Callback hObject eventdata handles DELETE TRACE odeletes a trace with a specified trace name and channel x handles varx channel 70 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan w handles varw trace g handles varg fprintf g calc d par del deletes the trace function editl_CreateFen hObject eventdata handles hObject handle to editl see GCBO eventdata reserved to be defined in a future version of MATLAB handles empty handles not created until after all CreateFcns called Hint edit controls usually have a white background on Windows See ISPC and COMPUTER if ispc set hObject BackgroundColor white else set hObject BackgroundColor get 0 defaultUicontrolBackgroundColor end function edit1_Callback hObject eventdata handles 7 NUMBER OF POINTS odefines the total number of measurements points per sweep point handles varpoint number of poi
12. GPIB AND MATLAB M lardalens H gskolan The callback steps can be done using functions or using strings of characters that contains the Matlab commands The first case is the best one because the functions have a work space different of the main work space with this is avoided to create conflicts with the variables names Other advantage is that this way is faster than the other way To reference the Matlab elements the user have to use handles A function handle is a MATLAB value that provides a means of calling a function indirectly You can pass function handles in calls to other functions often called function functions You can also store function handles in data structures for later use It is very important to start initiating all the variables with default values The best place to do this is the OpeningFunction that is run before doing visible the figure function Ivan_OpeningFcn hObject eventdata handles varargin This function has no output args see OutputFcn h bject handle to figure eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA varargin command line arguments to Ivan see VARARGIN A A A a A Choose default command line output for Ivan handles output h bject Update handles structure quidatalh bject handles UIWAIT makes Ivan wait for user response see UIRESUME uiwait handles fiqurel Figure 46 OpeningFuncti
13. OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan w 11 Sonumber of channel fprintf g calc d par sel Trc d x w select the trace as the active trace handles varw w guidata hObject handles ostores the specified data in the figure s application data case 12 w 12 Ynumber of channel fprintf g calc d par sel Trc d x w select the trace as the active trace handles varw w guidata hObject handles ostores the specified data in the figure s application data case 13 w 13 Ynumber of channel fprintf g calc d par sel Trc d x w select the trace as the active trace handles varw w guidata hObject handles ostores the specified data in the figure s application data case 14 w 14 Sonumber of channel fprintf g calc d par sel Trc d x w select the trace as the active trace handles varw w guidata hObject handles stores the specified data in the figure s application data case 15 w 15 number of channel fprintf g calc d par sel Trc d x w select the trace as the active trace handles varw w guidata hObject handles stores the specified data in the figure s application data case 16 w 16 Ynumber of channel fprintf g calc d par sel Trc d x w select the trace as the active trace handles varw w guidata hObject handles ostores the specified data in the figure s application data end function pushbutton6_Callback hObject eventdata handles
14. antennas inport Figure 1 Bucket and Antennas REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan Figure 2 Oil Bucket To receive the signals we have to select the receiving antenna using the Labjack U12 when the antenna has already been selected the signal will pass for the multiplexors and will arrive to the Network Analyzer for the inport selected once the signal is in the Network Analizer we can work with this The sixteen antenas are going to be separeted in two groups of eight antennas per group it wants to say that we need one outport and two inports Figure 3 Antennas REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan Figure 4 Antennas To Start the communication between the computer and Network Analyzer the first thing that we have to do is create a GPIB variable and open it Once the communication has been established we have to select one antenna and to create a new trace for this antenna Then we have to select the measurements ports to do this we have to look in which group is the selected antenna When we have done this and has been asigned one trace with one antenna we can see the different received signals It is possible to save the traces the results saved are stored in an array that contains three files and a number of columns as big as the number of points of the trace that we want to save The first file contains the frequency in every point of
15. controls usually have a white background on Windows See ISPC and COMPUTER if ispc set hObject BackgroundColor white else set hObject BackgroundColor get 0 defaultUicontrolBackgroundColor end Executes on selection change in listbox1 function listbox 1_Callback hObject eventdata handles 7ANTENNA gt LABJACK g handles varg contents get handles listbox1 string returns listbox1 contents as cell array con contents get handles listbox1 value returns selected item from listbox switch con case 1 EDigitalOut 1 0 7 1 1 configures the requested pin to output and leave it that way EDigitalOut 1 0 9 1 1 EDigitalOut 1 0 11 1 1 pause case 2 EDigitalOut 1 0 7 1 1 EDigitalOut 1 0 9 1 1 EDigitalOut 1 0 11 1 0 pause case 3 EDigitalOut 1 0 7 1 1 EDigitalOut 1 0 9 1 0 EDigitalOut 1 0 12 1 1 pause case 4 EDigitalOut 1 0 7 1 1 EDigitalOut 1 0 9 1 0 EDigitalOut 1 0 12 1 0 pause case 5 EDigitalOut 1 0 7 1 0 EDigitalOut 1 0 10 1 1 EDigitalOut 1 0 13 1 1 pause 60 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan case 6 EDigitalOut 1 0 7 1 0 EDigitalOut 1 0 10 1 1 EDigitalOut 1 0 13 1 0 pause case 7 EDigitalOut 1 0 7 1 0 EDigitalOut 1 0 10 1 0 EDigitalOut 1 0 14 1 1 pause case 8 EDigitalOut 1 0 7 1 0 EDigitalOut 1 0 10 1 0 EDigitalOut 1 0 14 1 0 paus
16. end of a message string and the Controller uses the EOI line to tell devices to identify their response in a parallel poll 2 1 4 GPIB Devices Each GPIB device must be some combination of a Talker a Listener or a Controller A Controller is typically a board that you install in your computer Talkers and Listeners are typically instruments such as oscilloscopes function generators multimeters and so on Most modern instruments are both Talkers and Listeners e Talkers A Talker transmits data over the interface when addressed to talk by the Controller There can be only one Talker at a given time e Listeners A Listener receives data over the interface when addressed to listen by the Controller There can be up to 14 Listeners at a given time Typically the Controller is a Talker while one or more instruments on the GPIB are Listeners e Controllers The Controller specifies which devices are Talkers or Listeners A GPIB system can contain multiple Controllers one of which is designated the System Controller However only one Controller can be active at a given time The current active controller is the Controller In Charge CIC The CIC can pass control to an idle Controller but only the System Controller can make itself the CIC When the Controller is not sending messages then a Talker can send messages Typically the CIC is a Listener while another device is enabled as a Talker Each Controller is identified by a unique board
17. index number Each Talker Listener is identified by a unique primary address ranging from O to 30 and by an optional secondary address which can be 0 or can range from 96 to 126 2 1 5 GPIB Data There are two types of data that can be transferred over the GPIB instrument data and interface messages e Instrument data Instrument data consists of vendor specific commands that configure your instrument return measurement results and so on For a complete list of commands supported by your instrument refer to 1ts documentation e Interface messages Interface messages are defined by the GPIB standard and consist of commands that clear the GPIB bus address devices return self test results and so on 14 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan Data transfer consists of one byte 8 bits sent in parallel The data transfer rate across the interface is limited to I megabyte per second However this data rate is usually not achieved in practice and is limited by the slowest device on the bus 2 1 6 GPIB Limitations Asynchronous read and write operations are not supported Therefore Agilent GPIB objects do not support the following toolbox functionality The readasync function The async flag for the fprintf and fwrite functions e BytesAvallableAction and OutputEmptyAction properties e The End Or Identify EOT line is not asserted when the End Of String EOS character is written to
18. o i 37 A E 38 34 83 SmIth bs 38 3 4 8 4 Remote control 38 3 4 9 Number of Points 39 3 4 9 1 Remote control 40 DANO ene Arne a dise 40 3 4 10 1 Ranzen ans 40 3 4 10 2 Remote control 840 DAL TV BEIN 41 SATT HM A M 41 3 4 11 2 Remote control 41 3 4 12 Start Frequency ey 41 412 1 A dp p OR e e dd 41 3 4 12 2 Remote control 41 34 13 StOB Preq efiey u a si se an a 42 E kb 42 3 4 13 2 Remote control 1 42 34 14 AMM ia da 42 3 4 15 Save ntenna Sp tee eee usa 43 3 4 16 Load Antenna 44 4 How to create a GUI with Matlab nennen 46 4 1 Whats Matlab eet eiie O 4 2 How to create a GUI with Matlab 46 4 2 NAV ANGLES 2 57 25 ee 46 42 2 Objects properties nie n uU dd 46 4 2 3 GUIDE AD Matlab i a o dd 47 4 2 3E Property GUI OE ED CN PENES 48 4 2 3 2 Alignment Editor 49 4 2 3 3 Menu
19. on and min usually 0 when the button is off A toggle button is created by creating a uicontrol whose style property is toggle button A toggle button may be added to a GUI by using the toggle button tool in the Layout Editor e 3 4 1 1 Connect the togglebutton is not depressed off all the graphical interface components are disable less Load it s possible load an antenna previously save without connecting with the Network Analyzer The GPIB object does not exist e 3 4 1 2 Disconnect the toggle button is depressed on all the graphical interface components are enable Also creates a GPIB object and opens it The default values are given here o 3 4 1 2 1 Default values Format Magnitud Start frequency 300 KHz Stop frequency 8GHz Number of points 200 Active trace 1 Inputbuffersize 50000 Measurement ports S11 Channel 1 3 4 2 Collect all Traces Pushbutton Save Antenna New Trace Delete Trace Load Antenna Collet one Trace Bandwidth Hz v Plot Window Plot Window NI i i m Number of Points ol IN I n lli 1 ML RUE Hy 22 Statt Fee Mte ALI IA N T m i i aa Figure 20 Collect all Traces Plots all traces assigned to a particular channel 27 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan 3 4 2 1 Colours b blue g green r red c cian m m
20. riolProyectolproy m 3 CA losIPCLOOMGIPCI100 m 4 CA ar DIO1 8911PC100 m Exit MATLAB Figure 38 Menu ram M lardalens H gskolan When we open the program appears the GUIDE Quick Start in the screen where is possible select between e Create a new GUI e Open existing GUI If the selected option is create a new GUI in the screen will appear the Guide Control Panel GCP that contains different parts untitled fig File Edit View Layout Tools Help Boo PB EM u 47 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan The first part is the toolbar that contains three big modules of GUIDE Aling Objects Menu Editor and Property Inspector The second part contains the user interface components pushbutton edit text i listbox togglebutton static text popup menu radiobutton slider axes checkbox frame Figure 40 Interface Components And the third part is the design area 4 2 3 1 Property editor The property editor is associated with one or several elements but only one can be opened in the same time In this window is possible to change the properties of every element Es Property Inspector AE uicontrol Ivan hran BackgroundColor BeingDeleted BusyAction queue ButtonDownFcn CData Callback automatic Clipping on CreateFcn DeleteFcn Enable Extent Font ngle normal FontName MS Sans Se FontSiz
21. s 66 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan guidata hObject handles case S33 fprintf g calc d par meas Trc d s33 x w s 33 handles vars s guidata hObject handles case S34 fprintf g calc d par meas Trc d s34 x w s 34 handles vars s guidata hObject handles case 541 fprintf g calc d par meas Trc d s41 x w s 41 handles vars s guidata hObject handles case S42 fprintf g calc d par meas Trc d s42 x w s 42 handles vars s guidata hObject handles case S43 fprintf g calc d par meas Trc d s43 x w s 43 handles vars s guidata hObject handles case S44 fprintf g calc d par meas Trc d s44 x w s 44 handles vars s guidata hObject handles end function popupmenu2_CreateFcn hObject eventdata handles hObject handle to popupmenu5 see GCBO eventdata reserved to be defined in a future version of MATLAB handles empty handles not created until after all CreateFcns called Hint popupmenu controls usually have a white background on Windows See ISPC and COMPUTER if ispc set hObject BackgroundColor white else set hObject BackgroundColor get 0 defaultUicontrolBackgroundColor end Executes on selection change in popupmenus function popupmenu2 Callback hObject eventdata handles 7 BANDWIDTH this subsystem sets the bandwidth of the IF measurement filter resolution
22. that maps the complex reflection coefficients Sii to normalized impedance values In contrast to the polar diagram the scaling of the diagram is not linear The grid lines correspond to points of constant resistance and reactance e Points with the same resistance are located on circles e Points with the same reactance produce arcs 16 428 Q j6 480 Q 515 63 pH Pur 10 dBm Figure 31 Smith Chart 3 4 8 3 1 Smith Selects a Smith chart to display a complex quantity primarily a reflection S parameter e Properties The Smith chart is a circular diagram obtained by mapping the positive complex semi plane into a unit circle Points with the same resistance are located on circles points with the same reactance produce arcs If the measured quantity is a complex reflection coefficient S11 S22 etc then the unit Smith chart represents the normalized impedance In contrast to the polar diagram the scaling of the diagram is not linear e Application Reflection measurements 3 4 8 4 Remote control CALCulate lt Ch gt FORMat lt format gt 38 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan 3 4 9 Number of Points Edit Text Disconnect Save Antenna NNI EER Wi 511 3 New Trace Load Antenna Te Collet one Trace Bandwidth Plot window 200 200 T T T T Fors 10 Eee 150 100 100 Number of Points 50 50 E 50 H N
23. the diferents GUI components I had some problems e To connect with the Network Analyzer To plot several traces in the same axes To do this finally i used the command hold on e To save the antenna in a file At first i had a edit menu where 1 had to insert the file manually but then 1 saw that 1 could use the fuction uiputfile that creates a save file dialog box where is possible to select the file with the mouse Some considerations e We have to disconnect before closing the window of the graphical interface e If the number of traces is very big is possible that we can not see the first trace because it is cover for the other traces we are using the function holl on e large number of points improves the resolution of the trace but increase the measurement time e A small number of points causes wide traces segments so that the out of tolerance regions can appear wider as they are e When we save an antenna we lost the first measurement it is because there is a frequency in the point number cero and when we save an antenna the array starts in the point number one so we lost the measurement in the start frequency It is not significant because we are losing one point between two thousand points it is a normal number of points although default is two hundred This problem would be significant if the number of points were very small but with a small number of points we can not do nothing be
24. the hardware Therefore when the EOSMode property is configured to write and the EOIMode property is configured to on the EOI line is not asserted when the EOSCharCode property value is written to the hardware e All eight bits are used for the EOS comparison Therefore the only value supported by the CompareBits property is 8 e A board index value of 0 is not supported e An error is not reported for an invalid primary address Instead the read and write operations will time out 2 1 7 GPIB Restrictions To achieve the high data transfer rate that the GPIB was designed for you must limit the number of devices on the bus and the physical distance between devices The following restrictions are typical e A maximum separation of 4 m between any two devices and an average separation of 2 m over the entire bus e A maximum total cable length of 20 m e A maximum of 15 devices connected to each bus with at least two thirds powered on For high speed operation the following restrictions apply e devices in the system must be powered on e Cable lengths must be as short as possible with up to a maximum of 15 m of cable for each system 15 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan e There must be at least one equivalent device load per meter of cable If you want to exceed these limitations you can use a bus extender to increase the cable length or a bus expander to increase the numb
25. trace x handles varx channel 65 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan g handles varg contents get handles listbox2 string returns listbox2 contents as cell array conl contents get handles listbox2 value returns selected item from listbox2 switch 1 case 811 fprintf g calc d par meas Trc d s11 x w assigns a measurement parameter to an existing trace s 11 handles vars s guidata hObject handles case S12 fprintf g calc d par meas Trc d s12 x w s 12 handles vars s guidata hObject handles case S13 fprintf g calc d par meas Trc d s13 x w s 13 handles vars s guidata hObject handles case S14 fprintf g calc d par meas Trc d s14 x w s 14 handles vars s guidata hObject handles case 521 fprintf g calc d par meas Trc d s21 x w s 21 handles vars s guidata hObject handles case S22 fprintf g calc d par meas 522 5 22 handles vars s guidata hObject handles case S23 fprintf g calc d par meas Trc d s23 x w s 23 handles vars s guidata hObject handles case S24 fprintf g calc d par meas Trc d s24 x w s 24 handles vars s guidata hObject handles case S31 fprintf g calc d par meas Trc d s31 x w s 31 handles vars s guidata hObject handles case S32 fprintf g calc d par meas Trc d s32 x w s 32 handles vars
26. 00 28 2 57 181 64 08 66 644 72 276 89 275 72 884 73 854 82 318 90 536 75 445 77 437 3 169 01 169 38 175 89 175 07 67 022 74 895 68 108 46 876 133 42 76 222 79 765 Workspace Current Directory Command History EE Figure 35 Array With this array is possible to see the measurements of every point 3 4 16 Load Antenna Pushbutton Disconnect Collect All Traces Save Antenna Load Antenna Antenr Ea Buscar en work 4 Jantennat Antenna2 Antenna3 Collet one Trace di Bandwidth Hz y ma St Number of Points Tipo a Cancelar Power dBm fr Start Frec Stop Maf 1 1 o 02 D3 04A 05 06 00 0E 09 0 01 02 03 04 05 06 07 08 09 1 Figure 36 Load Antenna Retrieves all variables from a file given a full pathname or a MATLABPATH relative partial pathname The command uigetfile displays a dialog box for the user to fill in and returns the filename and path strings and the index of the selected filter A successful return occurs only if the file exists If the user selects a file that does not exist an error message is 44 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan displayed and control returns to the dialog box The user may then enter another filename or press the Cancel button Disconnect Save Antenna Meas P Antenni
27. ETERS UNIT COMMENT SENSe lt 1 4 gt FREQuency CENTer SPAN STAR STOP MODE ECW FIXED CONVersion ARBitrary PMETer lt 1 12 gt AWReceiver STATe HARMonic ORDer RELative RPORt SPORt MIXer FFIXed FIXed FUNDamental IFFixed LOEXternal LOFixed LOINtema RFFixed TFRequency LPNoise SBANd numeric value numeric value numeric value numeric value CW FiXed SWEep SEGMent numeric value numeric value FUNDamental HARMonic MixXer ARBitrary SHARmonic THARmonic numeric value numeric value numeric value CW FiXed SWEep numeric value numeric value numeric value CW FiXed SWEep Boolean numeric value Boolean numeric value numeric value numeric value RF LO IF RF LO IF numeric value numeric value NONE SOURCE1 SOURCE2 numeric value numeric value NONE numeric value DCUPper DCLower UCONversion BAND1 BAND2 Boolean POSitive NEGative AUTO AARNA for compatibility with ZVR for compatibility with ZVR for compatibility with ZVR for compatibility with ZVR for compatibility with ZVR for compatibility with ZVR 83 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan EL a Ey A IR 84
28. EVel IMMediate AMPlitude 40 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan 3 4 11 Bandwidth Popupmenu Defines the Meas Bandwidth for each individual sweep segment The measurements bandwidth are 10Hz 100Hz 1000Hz 10000Hz 100000Hz 500000Hz The selected bandwidth and selectivity applies to all filters used in the current channel This makes sense because the measurement speed is limited by the slowest filter in the channel In Segmented Frequency sweeps the bandwidth and selectivity can be set independently for each segment A high selectivity and a small filter bandwidth both suppress the noise level around the measurement frequency and thus increase the dynamic range On the other hand the time needed to acquire a single measurement point increases for small filter bandwidths and high selectivity For small bandwidths the filter settling time which is inversely proportional to the bandwidth is responsible for the predominant part of the measurement time The characteristics of the high selectivity filter makes it particularly suitable for isolating unexpected spurious responses or known mixer products e 3 4 11 1 Range 1 Hz to 5 MHz Hz UP and DOWN increment decrement the bandwidth in 1 2 5 steps for each decade The analyzer rounds up any entered value between these steps and rounds down values exceeding the maximum bandwidth e 3 4 11 2 Remote control SENSe lt Ch gt BANDwidthIBWIDt
29. NI 488 2TM GPIB Analyzer User Manual Victor Dominguez B guena Ma Luisa Rap n Banzo Matlab en cinco lecciones de Num rico Universidad de Navarra http www unavarra es personal victor dominguez Fernando Seco Granja Conexi n de instrumentos de medida con GPIB http www iai csic es users fseco teaching gpib paf Network Analyzer ZVB http www roschi rohde schwarz com GPIB USB http sine ni com nips cds view p lang en nid 11397 Building GUIs with MATLAB December 1996 http www mathworks com MATLAB Function Calls for the LabJack U12 http gram eng uci edu dreinken MAE 106 MATLAB 20Function 20Calls pdf Agilent HP 8761B http www ntecusa com 56 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan APPENDIX Appendix 1 Source Code function varargout proy varargin PROY M file for proy fig by itself creates a new PROY or raises the existing singleton returns the handle to a new PROY or the handle to the existing singleton PROY CALLBACK hObject eventData handles calls the local function named CALLBACK in PROY M with the given input arguments PROY Property Value creates a new PROY or raises the existing singleton Starting from the left property value pairs are applied to the GUI before proy_OpeningFunction gets called An unrecognized property name or invalid value makes property application
30. REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M LARDALEN UNIVERSITY Iv n Pedraza Guti rrez M lardalens H gskolan 21 Januari 2006 C level REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan Abstract The central idea of this project is the remote control of a Network Analyzer ZVB and the remote control of a Labjack U12 To do this we are going to use a GPIB cable to cennect the computer with the Network Analyzer The Labjack will be directly connected in the USB port To control this devices we are going to program a Graphical User Interface with Matlab We will have a window with several buttons listboxes popup menus axes and togglebuttons with everyone of this components will be possible to do a different function on the Network Analyzer The signals will be emitted from the out port of the Network Analyzer and will be received for one of the sixteen antennas which are connected to the in ports Once the received signal is in the Network Analyzer we can change the number of points the power the bandwidth the start and the stop frequency etc Also it is possible to save and load one signal the signal will be stored in one array which will contain three files frequency magnitude and phase and a number of columns as big as the number of points REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan
31. TACLE ASSEMBLY Ja 0 OOo PLUG 2 16 0 013 36 22 MI IEEE488 Data Bus Transfer Timing Data Ba is Dae MDAC Devices Data Ready Accepted GPIB Bus Handshake Timing 75 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan Appendix 3 Labjack Functions with Matlab EAnalogIn Reads the voltage from one analog input EAnalogOut Sets the voltage on both analog outputs ECount Reads and resets the counter EDigitalln Reads the state of one digital input EDigitalOut Sets the state of one digital output AlSample Reads the voltages from 1 2 or 4 analog inputs Also controls reads the 4 IO ports AlBurst Reads a specified number of scans up to 4096 at a specified scan rate up to 8192 Hz from 1 2 or 4 analog inputs First data is acquired and stored in the LabJack s 4096 sample RAM buffer Then the data is transferred to the PC AlStreamStart Starts a hardware timed continuous acquisition where data is sampled and stored in the LabJack RAM buffer and can be simultaneously transferred out of the RAM buffer to the PC application A call to this function should be followed by periodic calls to AlStreamRead and eventually a call to AlStreamClear AlStreamRead Waits for a specified number of scans to be available and reads them AlStreamStart should be called before this function and AlStreamClear should be called when finished with the stream AlStreamClear This functio
32. agenta y yellow k black The PLOT command if no colour is specified makes automatic use of the colours specified by the axes ColorOrder property The default ColourOrder is listed in the table above for colour systems where the default is blue for one line and for multiple lines to cycle through the first six colours in the table 3 4 2 2 Steps e CALCulate lt Ch gt PARameter CA Talog Returns the trace names and measurement parameters of all traces assigned to a particular channel Response String parameter with comma separated list of trace names and measurement parameters e g CH4TR1 S11 CH4TR2 S12 The measurement parameters are returned according to the naming convention of CALCulate lt Ch gt PARameter SDEFine The order of traces in the list reflects their creation time The oldest trace is the first the newest trace is the last trace in the list e findstr f Tre lt n gt Find one string within another It has to be done for every trace e hold on Holds the current plot and all axis properties so that subsequent graphing commands add to the existing graph Sets the NextPlot property of the current figure and axes to add 28 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan 3 4 3 Collect one Trace Pushbutton Save Antenna New Trace Load Antenna Delete Trace Bandwidth Hz v Plot Window Plot Window 200 T T T 1 Format Number of Power dBm Start Fr
33. art of an impedance corresponds to its reactive portion Positive negative values represent inductive capacitive reactance 3 4 8 2 Polar Diagrams Polar diagrams show the measured data response values in the complex plane with a horizontal real axis and a vertical imaginary axis The grid lines correspond to points of equal magnitude and phase e The magnitude of the response values corresponds to their distance from the center Values with the same magnitude are located on circles e The phase of the response values is given by the angle from the positive horizontal axis Values with the same phase on straight lines originating at the center Tre28S218Polar 0 2 7 1 0 0 1 2 000000 GHz 0 488 U 128 51 Start 40 MHz Pur 10 dBm Figure 30 Polar Diagram 3 4 8 2 1 Polar Selects a polar diagram to display a complex quantity primarily an S parameter or ratio 37 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan e Properties The polar diagram shows the measured data response values in the complex plane with a horizontal real axis and a vertical imaginary axis The magnitude of a complex value is determined by its distance from the center its phase is given by the angle from the positive horizontal axis In contrast to the Smith chart the scaling of the axes is linear e Application Reflection or transmission measurements 3 4 8 3 Smith Chart The Smith chart is a circular diagram
34. b draws in the active axes and in the active screen 4 2 2 Objects properties All the objects in Matlab have different properties with default values that are use unless the users change them not all default values can be changed There are properties that can have any value and others that only can have a limited group of values for example on and off With the functions ger and set is possible to consult and change this values e Function set H Returns or displays all property names and their possible values for the object with handle H The return value is a structure whose field names are property names of H and whose values are cell arrys of possible property valuesor empty cell arrays The default value for an object property can be set on any of an object s ancestors by setting the PropertyName formed by concatenating the string default the object type and the property name e Function get H Returns a structure where each field name is the name of a property of H and each field contains the value of that property 46 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB 4 2 3 GUIDE in Matlab To start a GUIDE the best option is File New GUI Edit View Web Window Help Open Ctri O Close Command Window Ctri w Import Data l Save Workspace As Set Path Preferences Page Setup Print Print Selection 1 C MATLABSpS workiproy m 2 C
35. bandwidth x handles varx channel g handles varg contents get handles popupmenu string returns popupmenu2 contents as cell array con1 contents get handles popupmenu2 value returns selected item from popupmenu2 67 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan switch 1 case 10 fprintf g sens d band 10 wai x set a resolution bandwidth of 10Hz case 100 fprintf g sens d band 100 wai x set a resolution bandwidth of 100Hz case 1000 fprintf g sens d band 1000 wai x set a resolution bandwidth of 1000Hz case 10000 fprintf g sens d band 10000 wai x set a resolution bandwidth of 10000Hz case 100000 fprintf g sens d band 100000 wai x set a resolution bandwidth of 100000Hz case 500000 fprintf g sens d band 500000 wai x set a resolution bandwidth of 500000Hz end function pushbutton4_Callback hObject eventdata handles ONE TRACE plots the selected trace x handles varx channel g handles varg hold off fprintf g CALC d DATA FDAT x Reads the current response values of the active data trace FDAT formatted trace data y str2num fscanf g plot y grid on function listbox3_CreateFcn hObject eventdata handles hObject handle to listbox3 see GCBO eventdata reserved to be defined in a future version of MATLAB handles empty handles not created until after all CreateFcns called Hint listbox con
36. bytes to the LabJack s 8 192 byte nonvolatile memory at a specified address The data is read back and verified after the write Memory 0 511 is used for and calibration data Memory from 512 1023 is unused by the LabJack and available for the user this corresponds to starting addresses from 512 1020 Memory 1024 8191 is used as a data buffer in hardware timed Al modes burst and stream 77 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan Appendix 4 Network Analyzer Commond Commands Common commands are taken from the IEEE 488 2 IEC 625 2 standard These commands have the same effect on different devices The headers of these commands consist of followed by three letters Many common commands are related to the status reporting system De A Calibration Query query only SPA Clear Status no query 0 255 Event Status Enable ar Standard Event Status Query query only IDN Identification Query query only IST Individual Status Query query only op Operation Comprete OPT Option Identification Query query only PCB Pass Control Back no query NE Prsie Poi Register Enable e ur Peron Status Clear RST Reset no query J Sewee Request Enabe STB Status Byte Query query only TRG Trigger no query TST Self Test Query query only Wait to continue no query 78 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H g
37. c value numeric value numeric value numeric value numeric value Hz S dBm d5 Deg dB dB dB PCT dBm dB COMMAND PARAMETERS UNIT COMMENT SENSe lt 1 4 gt POWer ATTenuation IFGain lt 1 2 gt REFerence MEASure ARECeiver BRECeiver CRECeiver DRECeiver numeric value lt numeric_value gt LNOise LDIStortion AUTO LNOise LDIStortion AUTO D 2 81 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan COMMAND PARAMETERS UNIT COMMENT SYSTem COMMunicate GPIB SELF ADDRess RTERminator RDEVice GENerator lt 1 11 gt DEFine DELete PMETer 1 12 DEFine DELete DATA SIZE DISPlay COLor UPDate ERRor EL NEXT ALL FiRMware UPDate LANGuage PASSword CENable PRESet SCOPe SETTings UPDate SOUNd ALARm STATe STATus STATe VERSion 0 30 LFEoi EOI lt string gt lt string gt lt string gt lt string gt LON OFF ON OFF lt string gt lt string gt string lt string gt ALL AUTO DBACkground LBACkground BWLStyles BWSolid Boolean ONCE string string string ALL SINGle ONCE Boolean Boolean query only query only no query no query no query no query 82 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan COMMAND PARAM
38. cause the resolution is very bad 54 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan Acknowledgment I would like to thank to MDH and the university of Alcala de Henares for the opportunity of doing here my project I would like to thank Mikael Ekstrom Peder Norin and Denny Aberg for the support during my project I would like to thank Alfonso Parra for his help Also big thanks for Isabel Rodriguez and my family for their patient support and understanding during my study 55 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan References Brian R Hunt Ronald L Lipsman Jonathan M Rosenberg A Guide to Matlab for Beginners and experienced Users Javier Atencia Ra l Nestar Aprenda Matlab6 0 como si estuviera en primero Escuela superior de Ingenieros Industriales Universidad de Navarra Patrick Marchand O Thomas Holland Graphics and GUIs with Matlab Javier Garc a de Jal n Jos Ignacio Rodr guez Alfonso Brazales Aprenda Matlab 5 3 como si estuviera en primero Escuela T cnica Superior de Ingenieros Industriales Universidad Polit cnica de Madrid Agilent Technologies 8712ET ES and 8714ET ES RF Network Analyzers Programmer s Guide Rohde amp Schwarz Operating Manual Vector Network Analyzers R amp S ZVA 8 24 R amp S ZVB 4 8 ZVB 20 R amp S ZVT 8 Torres Ramirez Luis Alberto Introducci n a la Programaci n Visual con Matlab
39. communicate S tandard Commands for Programmable Instruments SCPI took the command structures defined in IEEE 488 2 and created a single comprehensive programming command set that is used with any SCPI instrument Figure 7 GPIB Cable The ANSVIEEE Standard 488 1975 now called IEEE 488 1 greatly simplified the interconnection of programmable instrumentation by clearly defining mechanical electrical and hardware protocol specifications For the first time instruments from different manufacturers were interconnected by a standard cable Although this standard went a long way towards improving the productivity of test engineers the standard did have a number of shortcomings Specifically IEEE 488 1 did not address data formats status reporting message exchange protocol common configuration commands or 10 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan device specific commands As a result each manufacturer implemented these items differently leaving the test system developer with a formidable task IEEE 488 2 enhanced and strengthened IEEE 488 1 by standardizing data formats status reporting error handling Controller functionality and common commands to which all instruments must respond in a defined manner By standardizing these issues IEEE 488 2 systems are much more compatible and reliable The IEEE 488 2 standard focuses mainly on the software protocol issues and thus maintains compatibility wit
40. connect Save Antenna New Trace Load Antenna Collect All Traces Delete Trace Collet one Trace Bandwidth Hz y Plot Window Plot Window NH WES s MAI AA AA Number of Points 50 iM ivi la soll I M al iM V HAN T AN S i T Stat Mro 100 F n ul m O Stop Frec Mhz 18Df i lean een I Figure 28 Format A display format defines how the set of complex measurement points is converted and displayed in a diagram The display formats in the 7race Format menu use the following basic diagram types e Cartesian rectangular diagrams are used for all display formats involving a conversion of the measurement data into a real scalar quantity i e for dB Mag Phase Delay SWR Lin Mag Real Imag and Unwrapped Phase e Polar diagrams are used for the display format Polar and show a complex quantity as a vectorin a single trace e Smith charts are used for the display format Smith and show a vector like polar diagrams but with grid lines of constant real and imaginary part of the impedance Inverted Smith charts are used for the display format Inverted Smith and show vector like polar diagrams but with grid lines of constant real and imaginary part of the admittance 3 4 8 1 Cartesian Diagra
41. ctive trace In remote control each channel contains an active trace unless the channel contains no trace at all so the notion of active channel is meaningless This principle actually simplifies the remote control command syntax because it allows the active trace in a particular channel to be referenced by means of the channel suffix No additional trace identifier is needed there is no need either to distinguish channel and trace settings using mnemonics or suffixes The active traces are handled as follows e After a preset RST the analyzer displays a single diagram area with the default trace no 1 named TRC1 The trace is active in manual and in remote control e In manual control a new added trace automatically becomes the active trace e In remote control the first trace assigned to a channel remains the active trace until another trace in the channel is explicitly selected as the active trace e As a consequence the active traces for manual and remote control may be different even within the same channel 3 4 4 2 Traces Channels and Diagram Areas Like in manual control traces can be assigned to a channel and displayed in diagram areas There are two main differences between manual and remote control e A trace can be created without being displayed on the screen e channel must not necessarily contain a trace Channel and trace configurations are independent of each other The following frequently used comman
42. d for automated testing and systems applications User specified connectors over 250 possible combinations Unterminated Break before make Excellent repeatability typically 0 03 dB after 1 000 000 cycles Insertion loss lt 0 5 dB to 12 4 GHz lt 0 8 dB to 18 GHz Isolation gt 50 dB to 124 GHz gt 45 to 18 GHz Environmentally rugged Figure 16 HP 8761B 20 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan 2 5 Network Analyzer The Vector Network Analyzer ZVB covering the frequency range from 300 kHz to 8 GHz and 10 MHz to 20 GHz has been designed for universal measurements on passive and active components Especially for multiport measurements and measurements on balanced devices the ZVB simplifies vector analysis Featuring comprehensive measurement functions outstanding specifications high measurement and data transfer speeds plus remote control capability the ZVB is the ideal instrument for both development and production WARE VICTOR 2 gt CUA 3 OLE BBB uud Figure 17 Network Analyzer ZVB Multiport e Instruments with 2 3 and 4 ports e Multiport capability e Ability of balanced measurements Outstanding specifications e 20 001 points per trace e Dynamic range better than 123 dB e Power sweep range 50 dB Speed e Measurement time 8 ms 201 points e Switching between channel
43. ds create and delete traces channels and diagram areas 30 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan Create new trace and CALCulate lt Ch gt PARameter SDEFine lt Trace Name gt new channel lt Meas Parameter gt if channel lt Ch gt does not exist yet Caro Delete trace CALCulate lt Ch gt PARameter DELete Trace Name gt Create or delete channel CONFigure CEANnel Ch STATe ON OFF Create or delete diagram area DISPlay WINDow lt Wnd gt STATe ON OFF Display trace in diagram DISPlay WINDow lt Wnd gt TRACe lt WndTr gt FEED area Figure 23 Commands Table In this graphical interface all traces are in the same digital area A diagram area is a rectangular portion of the screen used to display traces Diagram areas are arranged in windows they are independent of trace and channel settings A diagram area can contain a practically unlimited number of traces assigned to different channels overlay mode e 3 4 4 3 Remote control CALCulate lt Ch gt PARameter SDEFine Trace Name lt Meas Parameter gt DISPlay WINDow lt Wnd gt TRACe lt WndTr gt FEED 31 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan 3 4 5 Delete Trace Pushbutton Disconnect Save Antenna Load Antenna Collect All Traces Collet one Trace Bandwidth Hz Plot Window Plot Window Be LL ETINI et j Lil T Tn Nu
44. e case 9 EDigitalOut 1 0 8 1 1 EDigitalOut 1 0 1 1 1 EDigitalOut 1 0 3 1 1 pause case 10 EDigitalOut 1 O 8 1 1 EDigitalOut 1 0 1 1 1 EDigitalOut 1 0 3 1 0 pause case 11 EDigitalOut 1 0 8 1 1 EDigitalOut 1 0 1 1 0 EDigitalOut 1 0 4 1 1 pause case 12 EDigitalOut 1 0 8 1 1 EDigitalOut 1 0 1 1 0 EDigitalOut 1 0 4 1 0 pause case 13 EDigitalOut 1 O 8 1 0 EDigitalOut 1 0 2 1 1 EDigitalOut 1 0 5 1 1 pause case 14 EDigitalOut 1 0 8 1 0 EDigitalOut 1 0 2 1 1 EDigitalOut 1 0 5 1 0 pause case 15 EDigitalOut 1 0 8 1 0 EDigitalOut 1 0 2 1 0 EDigitalOut 1 0 6 1 1 pause case 16 EDigitalOut 1 0 8 1 0 EDigitalOut 1 0 2 1 0 EDigitalOut 1 0 6 1 0 pause 61 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan end function pushbutton3_Callback hObject eventdata handles COLLET ALL TRACES plots all the traces x handles varx channel number g handles varg hold off Zoreturns to the default mode whereby PLOT commands erase the previous plots and reset all axis fprintf g calc1 par cat Returns the trace names and measurement parameters of all traces assigned to a particular channel f fscanf g if findstr f Trc1 finds one string within another fprintf g calc d par sel Trc1 x select the trace as the active trace fprintf g CALC d DATA FDAT x Reads the current respons
45. e off set handles popupmenu2 Enable off set handles pushbutton1 Enable off set handles pushbutton2 Enable on load set handles pushbutton3 Enable off set handles pushbutton4 Enable off set handles pushbutton5 Enable off set handles pushbutton6 Enable off Update handles structure guidata hObject handles UIWAIT makes proy wait for user response see UIRESUME uiwait handles figure1 Outputs from this function are returned to the command line function varargout proy_OutputFcn hObject eventdata handles varargout cell array for returning output args see VARARGOUT hObject handle to figure eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA Get default command line output from handles structure varargout 1 handles output function togglebutton1_Callback hObject eventdata handles CONNECT DISCONNECT state get handles togglebutton1 Value returns toggle state of togglebutton1 if state enable buttons that would send controller commands if pressed enable text boxes as well set handles edit1 Enable on set handles edit2 Enable on set handles edit3 Enable on set handles edit4 Enable on set handles listbox 1 Enable on set handles listbox2 Enable on set handles listbox3 Enable on set handles popupmenul Enable on set
46. e 8 0 FontUnits gt points FontWeight normal Figure 41 Property Inspector 48 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan 4 2 3 2 Alignment Editor The alignment editor is an auxiliary tool which allows that the controls which are situated in the window over the design area appear aligned Before doing it it is necessary to select the objects Align Objects vertical Align Distribute Horizontal Align Distribute UJ y de _ Figure 42 Alignment Editor 4 2 3 3 Menu Editor The Menu Editor has two parts but the operation is the same with one difference a menu which is introduced with Menu Bar will appear active in the figure while with the Context Menu will appear when we clic the right button over the figure Menu Editor UlMenu Properties Label Ivan Tag Book L Separator above this item Item is checked Callback lvan Untitled 1 Callback gcbo guidata Menu Bar Context Menus Figure 43 Menu Editor 49 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan New Menu mr mp New Context Menu I New Menu Item B Delete Selectec Item Figure 44 Menu Editor Components 4 2 3 4 Callback Editor The callback editor allows to define the form in which the different controls respond to the events The Callback Editor is automaticly opened the first time that the file f
47. e values of the active data trace FDAT formatted trace data y str2num fscanf g Yoconverts string matrix to numeric array plot y b blue hold on Zoholds the current plot and all axis properties so that subsequent graphing commands add to the existing graph grid on grid lines end if findstr f Tre2 fprintf g calc d par sel Trc2 x select the trace as the active trace fprintf g CALC d DATA FDAT x y str2num fscanf g plot y g Jogreen hold on grid on end if findstr f Trc3 fprintf g calc d par sel Trc3 x select the trace as the active trace fprintf g CALC d DATA FDAT x y str2num fscanf g plot y r hold grid if findstr f Trc4 fprintf g calc d par sel Trc4 x select the trace as the active trace fprintf g CALC d DATA FDAT x y str2num fscanf g plot y c cyan hold on grid on end if findstr f Trc5 fprintf g calc d par sel Trc5 x select the trace as the active trace fprintf g CALC d DATA FDAT x y str2num fscanf g plot y m Yomagenta hold on grid on end 62 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan if findstr f Trc6 fprintf g calc d par sel Trc6 x select the trace as the active trace fprintf g CALC d DATA FDAT x y str2num fscanf g plot y y yellow hold on grid on end if findstr f Trc7 fprintf g calc d par sel Trc7 x select
48. eAndPathString PathName FileName saves the data in m variable in the user specified filename and location save FileNameAndPathString m function pushbutton2_Callback hObject eventdata handles LOAD hold off FileName PathName uigetfile mat Load display the load file dialog box if FileName return end FileNameAndPathString PathName FileName load FileNameAndPathString plot m 1 m 2 plots the second file of m magnitude grid on xlabel FREQUENCY Mhz ylabel MAGNITUDE 73 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan Appendix 2 GPIB Characterictics GPIB PIN OUT 24 Pin GPIB Bus PinOut IEEE488 Pinout M DIO4 Data Input Output Bit 4 16 DIOS Data Input Output Bit 8 5 End Or Identify 17 REN Enable 6 AV Paavaid 18 Shield Groud DAV b Interface Clear shield Ground aC IEEE STD 488 VO Characteristics Voltage Low 0 22 volts typical 0 4 volts maximum Current High Im 2 5mA maximum Current Low Vr 3 2mA maximum Output Voltage High V on 3 4 volts typical 2 5 volts minimum Output Voltage Low Vor 0 Output Current High 5 2mA maximum w 48mA maximum 74 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan GPIB Connector Mechanical Dimensions 2 16 20 013 36 20 MAX RECEP
49. ec Mhz Stop Frec 02 03 04 05 06 07 08 0 Figure 21 Collect One Trace Plots the active trace with the default colour blue 3 4 4 New Trace Pushbutton Disconnect Collect All Traces 0 8 0 6 0 4 0 2 D 0 2 0 4 0 6 0 8 15 E iil Disconnect Save Antenna Eng 3 B Load Antenna Collect All Traces Collet one Trace Bandwidth Hz X Plot Window Plot Window 200 200 Vlll VIT I x Y l j 1 iuh rien MEM ij N ul o m p PU e UN Stop Frec Mha 150 M 801 AM iH Tri Figure 22 New Trace 29 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan Creates a new trace in the current diagram area and assigns it to the current channel The new trace is created with the trace and channel settings of the former active trace but displayed with another color A trace is a set of data points displayed together in the diagram area The individual data points are connected so that each trace forms a continuous line The default names for new traces Trc n where n is the selected trace 3 4 4 1 Active Traces in Remote Control In manual control there is always exactly one active trace irrespective of the number of channels and traces defined The active channel channel 1 contains the a
50. er of device loads You can order bus extenders and expanders from National Instruments 2 1 8 SCPI On April 23 1990 a group of instrument manufacturers announced the SCPI specification which defines a common command set for programming instruments Before SCPI each instrument manufacturer developed its own command sets for its programmable instruments This lack of standardization forced test system developers to learn a number of different command sets and instrument specific parameters for the various instruments used in an application leading to programming complexities and resulting in unpredictable schedule delays and development costs By defining a standard programming command set SCPI decreases development time and increases the readability of test programs and the ability to interchange instruments SCPI is a complete yet extendable standard that unifies the software programming commands for instruments The first version of the standard was released in mid 1990 Today the SCPI Consortium continues to add commands and functionality to the SCPI standard SCPI has its own set of required common commands in addition to the mandatory IEEE 488 2 common commands and queries Although IEEE 488 2 is used as its basis SCPI defines programming commands that you can use with any type of hardware or communication link SCPI specifies standard rules for abbreviating command keywords and uses the IEEE 488 2 message exchange protocol rules to
51. eries fo the instrument Data can also be in the form of response from an instrument The GPIB bus operates block oriented multiple commands queries and data strings units can be combined into one line of text An instrument will start executing commands and queries if a complete line of text has been received To know when a complete line is transferred the EOI End Or Identify event has to be generated simultaneously when the last byte is send 12 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan 2 1 3 GPIB Signal and Lines The GPIB interface system consists of 16 signal lines and eight ground return or shield drain lines The 16 signal lines discussed below are grouped into data lines eight handshake lines three and interface management lines five see Figure 2 Figure 11 GPIB Signals and Lines e 2 1 3 1 Data Lines The eight data lines DIO1 through DIOS carry both data and command messages The state of the Attention ATN line determines whether the information is data or commands All commands and most data use the 7 bit ASCH or ISO code set in which case the eighth bit DIOS is either unused or used for parity e 2 1 3 2 Handshake Lines Three lines asynchronously control the transfer of message bytes between devices The process is called a 3 wire interlocked handshake It guarantees that message bytes on the data lines are sent and received without transmission error o NRFD
52. es we should write some lines of code but it would be easy because the code would be similar to the rest of the callback s code If the number of antennas in every group of antennas were very big we would be able to add a new channel We could have one group of antennas in one channel and the other group of antennas in a different channel It should be in this way because if the number of antennas in every channel is very big there would not be space in the screen to represent the traces To add a new chanel is neccesary to create a new listbox where we can select between the different channels It would not be neccesary to change the rest of the function because they are ready for this change 53 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan 7 Result and discussion The first step in the project was to look up manuals about Matlab because i had never worked with this program It was very easy to find the Matlab s Manuals to do this i used internet and the library Once i knew something about Matlab looked up severals manuals about the GPIB the Network Analyzer and the Labjack U12 with Matlab because is possible to use this devices with other programs Then i started programming the Graphical User Interface at first it was very difficult for me becuse i could not connect my laptop with the network analycer but when i did this the rest was very fast In the manuals i could see how were the callbacks for
53. format commands and parameters You may use command keywords in their long form MEASure or their short form shown in capital letters MEAS SCPI offers numerous advantages to the test engineer One of these is that SCPI provides a comprehensive set of programming functions covering all the major functions of an instrument This standard command set ensures a higher degree of instrument interchangeability and minimizes the effort involved in designing new test systems The SCPI command set is hierarchical so adding commands for more specific or newer functionality is easily accommodated Signal Gene ration Figure 12 The SCPI Instrument Model 16 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan 2 2 GPIB USB The compact National Instruments GPIB USB transforms any computer with a USB port into a full function IEEE 488 2 controller that can control up to 14 programmable GPIB instruments The small size and light weight of the NI GPIB USB make it ideal for portable applications using a laptop computer or other applications in which the computer has no available internal VO slots The GPIB USB works with Windows 2000 XP Me 98 or Linux computers with a USB port The GPIB USB does not require a GPIB cable for connecting to your instruments You can attach it directly to the GPIB port on your instrument and then connect the USB cable to the USB port on your computer If you have multiple instruments in a daisy
54. h RESolution 3 4 12 Start Frequency Edit Text Defines the start frequency for a frequency sweep which is equal to the left edge of a Cartesian diagram Is the lowest value of the sweep variable If the start frequency entered is greater than the current stop frequency the stop frequency is set to the start frequency plus the minimum frequency span If Points was set to 1 then the Stop frequency would be set equal to the Start frequency but it is not possible becuse the minimum number of points is 2 e 3 4 12 1 Range Depending on the instrument model Hz The increment parameters UP or DOWN is 0 1 kHz In this case the minimum start frequency 1s 300 Khz e 3 4 12 2 Remote control SENSe lt Ch gt FREQuency STARt start frequency 41 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan 3 4 13 Stop Frequency Edit Text Defines the stop frequency for a frequency sweep which is equal to the right edge of a Cartesian diagram Is the highest value of the sweep variable The Stop frequency must be greater than the Start frequency the Span must be gt 1 Hz A sweep must contain at least two different sweep points If the stop frequency entered is smaller than the current start frequency the start frequency is set to the stop frequency minus the minimum frequency span e 3 4 13 1 Range Depending on the instrument model Hz The increment parameters UP or DOWN is 0 1 kHz In this case the maximum s
55. h the hardware oriented IEEE 488 1 standard Standard Program Command Set Handshak ng Gontrol Mechanical Electrical Standards Figure 9 GPIB Cable 2 1 2 The communication principle A GPIB instrument receives its information from another device Usually this is the system controller The instrument distinguishes between events commands queries and data 11 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan parameter cata anc events Device instrument System Controller Response dala events Figure 10 Information Types e Events The GPIB bus has a number of special control lines which allow fast and simple passing of primitive information called events This primitive information is also called Interface Events or Interface Messages because they are initiated and processed by the interface hardware An example of an event is the IFC InterFace Clear event Which forces the instrument to be able to listen to the system controller e Commands Commands are strings which cause the instrument to perform an action such as taking measurements or activate a motor e Queries Queries are strings which cause the instrument to generate response Queries usually do not cause an instrument to perform an action Queries always end with a question mark e Data units Data units are used to pass information Data can be in the form of parameters which come with commands or qu
56. handles popupmenu2 Enable on set handles pushbutton1 Enable on set handles pushbutton2 Enable on set handles pushbutton3 Enable on set handles pushbutton4 Enable on 58 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan set handles pushbutton5 Enable on set handles pushbutton6 Enable on sta 0 3 default start frequency handles varsta sta form magn Zodefault format handles varform form sto 8000 default stop frequency handles varsto sto x 1 default channel handles varx x w 1 default trace handles varw w point 200 odefault number of points handles varpoint point s 11 default meas port handles vars s starts the communication with the network analyzer using the GPIB set handles togglebutton string Disconnect backgroundcolor default g gpib ni 0 1 creates a new GPIB variable handles varg g store x handles varx w handles varw sta handles varsta sto handles varsto point handles varpoint form handles varform guidata hObject handles creates a structure containing handles to all of the objects g inputBufferSize 100000 input buffer g outputBufferSize 100000 output buffer g EOIMode on input data g EOSMode none output data fopen g ostarts the communication with the network analyzer fprintf g calc d par sel Trc d x w default trace Trc1 fprintf g sens d freq star dMhz wai x
57. hat allows a user to enter a text string The edit box generates a callback when the user presses the Enter key after typing a string into the box An edit box is created by creating a uicontrol whose style property is edit An edit box may be added to a GUI by using the edit box tool in the Layout Editor 3 3 3 Pushbuttons A pushbutton is a component that a user can click on to trigger a specific action The pushbutton generates a callback when the user clicks the mouse on it A pushbutton is created by creating a uicontrol whose style property is pushbutton A pushbutton may be added to a GUI by using the pushbutton tool in the Layout Editor 3 3 4 Toggle Buttons A toggle button is a type of button that has two states on depressed and off not depressed A toggle button switches between these two states whenever the mouse clicks on it and it generates a callback each time The Value property of the toggle button is set to max usually 1 when the button is on and min usually 0 when the button is off A toggle button is created by creating a uicontrol whose style property is toggle button A toggle button may be added to a GUI by using the toggle button tool in the Layout Editor 3 3 5 Popup Menus Popup menus are graphical objects that allow a user to select one of a mutually exclusive list of options The list of options that the user can select among is specified by a cell array of strings and the Value property indicates
58. ig is saved It consist in several code lines which are saved in a file m with the same name that the figure One part of the code is automaticly generated for the GUIDE in this code appears the functions callback associated with every control C MATLAB6p5 work lvan m EIER File Edit Text Debug Breakpoints Web Window Help D a i x l y OH ABE BE function Ivan Callback h0bject eventdata handles hObject handle to Ivan see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA Hint get h bject Value returns toggle state of Ivan function Untitled 1 Callback h bject eventdata handles hObject handle to Untitled_l see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA 2 Executes on button press in pushbuttonl function pushbuttonl_Callback h bject eventdata handles hObject handle to pushbuttonl see GCBO eventdata reserved to be defined a future version of MATLAB handles structure with handles and user data see GUIDATA Ivan Ln5 012 Figure 45 Callback Editor The callback programming is one of the more important parts when a GUI is developed since it defines the way in which the programm will work when the user causes an event over one of the controls 50 REMOTE CONTROL OF DEVICES WITH A
59. ing gt lt string gt no query lt string gt COMMAND PARAMETERS UNIT COMMENT SENSe 1 4 AN A PA lt numeric_value gt Hz lt numeric_value gt Hz COMMAND PARAMETERS UNIT COMMENT BANDwidth RESolution BWIDth ERESolution SENSe lt 1 4 gt SWEep COUNt DWELI DETector TIME SPACing SRCPort STEP TIME AUTO lt numeric_value gt lt numeric_value gt lt numeric_value gt lt numeric_value gt LINear LOGarithmic lt numeric_value gt lt numeric_value gt lt numeric_value gt lt Boolean gt LiNear LOGarithmic POWer CW POINt SEGMent 80 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan COMMAND PARAMETERS UNIT COMMENT DISPlay ANNotation FREQuency STATe CMAP lt 1 28 gt MARKer STATe RGB TRACe COLor STATe EWINDow lt 1 5 gt 5 TITLe DATA STATe lt 1 6 gt DELete FEED X OFFSet N OFFSet SCALe AUTO BOTTom PDIVision RLEVel RPOSition TOP lt Boolean gt lt Boolean gt lt numeric_value gt lt numeric_value gt lt numeric_value gt SOLid DASHed DOTTed DDOTted DDDotted lt numeric_value gt lt Boolean gt lt Boolean gt lt Boolean gt lt string gt Boolean string numeric value numeric value snumeric value numeric value numeric value ONCE numeri
60. int edit controls usually have a white background on Windows See ISPC and COMPUTER if ispc set hObject BackgroundColor white else set hObject BackgroundColor get 0 defaultUicontrolBackgroundColor end function edit3_Callback hObject eventdata handles START FREQUENCY Zodefines the start frequency sweep which is equal to the left edge of acartesian diagram sta handles varsta start frequency x handles varx channel g handles varg get hObject String Zoreturns contents of edit3 as text sta str2double get hObject String returns contents of edit3 as a double fprintf g sens d freq star dMhz wai x sta sets start frecuency handles varsta sta guidata hObject handles function edit4_CreateFen hObject eventdata handles hObject handle to edit4 see GCBO 9o eventdata reserved to be defined in a future version of MATLAB handles empty handles not created until after all CreateFcns called Hint edit controls usually have a white background on Windows See ISPC and COMPUTER if ispc set hObject BackgroundColor white else set hObject BackgroundColor get 0 defaultUicontrolBackgroundColor end function edit4_Callback hObject eventdata handles STOP FREQUENCY odefines the stop frequency sweep which is equal to the left edge of a cartesian diagram sto handles varsto frequency x handles varx channel g handles varg get hObject String returns conten
61. lc d form magn wai x Defines how the measured result at any sweep point is post processed MAGNITUDE form magn handles varform form guidata hObject handles case Phase fprintf g calc d form phas wai x PHASE form phas handles varform form guidata hObject handles case Smith fprintf g calc d form smit wai x SMITH form smit handles varform form guidata hObject handles case Re fprintf g calc d form real wai x REAL form real handles varform form guidata hObject handles case Im fprintf g calc d form imag wai x IMAGINARY form imag handles varform form guidata hObject handles case Polar fprintf g calc d form pol wai x POLAR form pol handles varform form guidata hObject handles end function listbox2_CreateFcn hObject eventdata handles hObject handle to listbox2 see GCBO eventdata reserved to be defined in a future version of MATLAB handles empty handles not created until after all CreateFcns called Hint listbox controls usually have a white background on Windows See ISPC and COMPUTER if ispc set hObject BackgroundColor white else set hObject BackgroundColor get 0 defaultUicontrolBackgroundColor end Executes on selection change in listbox2 function listbox2_Callback hObject eventdata handles MEAS PORT Yoassigns a measurement parameter to an existing trace s handles vars Yomeas port w handles varw
62. mber of Points 50 IN 50 ol wi i 1 mer T li i i li iia AM Stop Frec M TSO PHP E Es 8 TT 7 S at Figure 24 Delete Trace Deletes the current trace and removes it from the diagram area Delete Trace is disabled if the setup contains only one trace In manual control each setup must contain at least one diagram area with one channel and one trace 3 4 5 1 Remote control CALCulate lt Ch gt PA Rameter DELete Trace 3 4 6 Trace Selects an existing trace as the active trace of the channel All trace commands without explicit reference to the trace name act on the active trace It is possible that the selected trace does not exist this is the case when a new trace has to be create The active traces for manual and remote control may be different even within the same channel 3 4 6 1 Remote control CAL Culate lt Ch gt PARameter SELect Trace 3 4 7 Meas Port Listbox Assigns a measurement parameter to an existing trace The measurement ports are 511 812 513 514 521 522 523 524 31 532 33 534 541 542 543 544 32 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan Normal mode S parameters S lt out gt lt in gt where lt out gt and lt in gt denote the output and input port numbers of the DUT To avoid ambiguities lt out gt and lt in gt must be either
63. ms Cartesian diagrams are rectangular diagrams used to display a scalar quantity as a function of the stimulus variable frequency power time e The stimulus variable appears on the horizontal axis x axis scaled linearly sweep types Lin Frequency Power Time CW Mode or logarithmically sweep type Log Frequency 35 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan e The measured data response values appears on the vertical axis y axis The scale of the y axis is linear with equidistant grid lines although the y axis values may be obtained from the measured data by non linear conversions Start 40 MHz Pur 10 dBm Stop 6 GHz Figure 29 Cartesian Diagram 3 4 8 1 1 dB Mag Selects a Cartesian diagram with a logarithmic scale of the vertical axis to display the magnitude of thecomplex measured quantity e Properties The stimulus variable appears on the horizontal axis scaled linearly The magnitude of the complex quantity C i e sqrt Re C 2 Im C 2 appears on the vertical axis scaled in dB The decibel conversion is calculated according to dB Mag C 20 log ICI dB e Application dB Mag is the default format for the complex dimensionless S parameters The dB scale is the natural scale for measurements related to power ratios insertion loss gain etc 3 4 8 1 2 Phase Selects a Cartesian diagram with a linear vertical axis to display the phase of a complex measured q
64. n stops the continuous acquisition It should be called once when finished with the stream AOUpdate Sets the voltages of the analog outputs Also controls reads all 20 digital 1 O and the counter AsynchConfig Configures the LabJack U12 D lines for asynchronous communication Asynch Writes then read half duplex asynchronous data on 1 of two pairs of D lines Basically RS232 communication BitsToVolts Converts a 12 bit 0 4095 binary value into a LabJack voltage Volts 2 Bits Vmax 4096 Vmax Gain where Vmax 10 for SE 20 for Diff VoltsToBits Converts a voltage to it s 12 bit 0 4095 binary representation Bits 4096 Volts Gain Vmax 2 Vmax Counter Controls and reads the counter The counter is disabled if the watchdog timer is enabled DigitalIO Reads and writes to all 20 digital I O GetDriverVersion Returns the version number of ljackuw dll GetErrorString Converts a LabJack errorcode returned by another function into a string describing the error GetFirmwareVersion Retrieves the firmware version from the LabJack GetWinVersion Uses a Windows API function to get the OS version ListAll Searches the USB for all LabJacks and returns the serial number and local ID for each LocalID Changes the local ID of a specified LabJack Changes will not take effect until the LabJack is re enumerated or reset either manually by disconnecting and reconnecting the USB cable or by calling ReEnum or Reset NoThread Disables th
65. nment contains pushbuttons toggle buttons lists menus text boxes and so forth all of which are already familiar to the user so that he or she can concentrate on using the application rather than on the mechanics involved in doing things However GUIs are harder for the programmer because a GUI based program must be prepared for mouse clicks or possibly keyboard input for any GUI element at any time Such inputs are known as events and a program that responds to events is said to be event driven The three principal elements required to create a MATLAB Graphical User Interface are e 3 2 1 Components Each item on a MATLAB GUI pushbuttons labels edit boxes etc is a graphical component The types of components include graphical controls pushbuttons edit boxes lists sliders etc static elements frames and text strings menus and axes Graphical controls and static elements are created by the function uicontrol and menus are created by the functions uimenu and uicontextmenu Axes which are used to display graphical data are created by the function axes e 3 2 2 Figures The components of a GUI must be arranged within a figure which is a window on the computer screen In the past figures have been created automatically whenever we have plotted data However empty figures can be created with the function figure and can be used to hold any combination of components e 3 2 3 Callbacks Finally there must be some way to
66. not ready for data Indicates when a device is ready or not ready to receive a message byte The line is driven by all devices when receiving commands by Listeners when receiving data messages and by the Talker when enabling the HS488 protocol o NDAC not data accepted Indicates when a device has or has not accepted a message byte The line is driven by all devices when receiving commands and by Listeners when receiving data messages o DAV data valid Tells when the signals on the data lines are stable valid and can be accepted safely by devices The Controller drives DAV when sending commands and the Talker drives DAV when sending data messages e 2 1 3 3 Interface Management Lines Five lines manage the flow of information across the interface o attention The Controller drives ATN true when it uses the data lines to send commands and drives ATN false when a Talker can send data messages 13 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan o IFC interface clear The System Controller drives the IFC line to initialize the bus and become CIC o REN remote enable The System Controller drives the REN line which is used to place devices in remote or local program mode o SRQ service request Any device can drive the SRQ line to asynchronously request service from the Controller o EOI end or identify The EOI line has two purposes The Talker uses the EOI line to mark the
67. nts x handles varx channel g handles varg get hObject String Zoreturns contents of edit as text point str2double get hObject String Zoreturns contents of edit as a double fprintf g sens d swe poin d wai x point changes the number of points handles varpoint point guidata hObject handles function edit2_CreateFen hObject eventdata handles hObject handle to edit2 see GCBO eventdata reserved to be defined in a future version of MATLAB handles empty handles not created until after all CreateFcns called Hint edit controls usually have a white background on Windows See ISPC and COMPUTER if ispc set hObject BackgroundColor white else set hObject BackgroundColor get 0 defaultUicontrolBackgroundColor end function edit2_Callback hObject eventdata handles 7 POWER odefines the power of the internal signal source x handles varx channel g handles varg get hObject String returns contents of edit2 as text p str2double get hObject String returns contents of edit2 as a double fprintf g sour d pow d wai x p sets the internal source power function edit3_CreateFcn hObject eventdata handles hObject handle to edit3 see GCBO eventdata reserved to be defined in a future version of MATLAB handles empty handles not created until after all CreateFcns called 71 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan H
68. on 51 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan 5 Summary The objective of this project is the remote control of different components as the Network Analyzer the Labjack This is an advantage because it is not necessary to have the hardware in front to work With this kind of graphical interfaces the user can control the components without the need to know nothing about it and how are the menus in the Network Analyzer This cause that everybody can use this graphical interface This is the first time in this university that Matlab GUI is used to control a Network Analyzer with a GPIB The previous projects similar to this one were made with Labview To use this kind of graphical interface is necessary the installation of Instrument Control Toolbox that is a collection of M file functions built on the Matlab technical computing environment although in this case is not necessary because Matlab 6 5 default contains it Also is necessary the installation of Measurement and Automation Explorer that provides access to all the National Instruments MATLAB 6 5 amp Automation 52 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan 6 Future Development A future development of this project could be the increase of the number of antennas To do this it would be necessary to change the listboxes Antenna Trace and the pushbutton Collect all Trac
69. ounter is made at screw terminal CNT The counter is incremented when it detects a falling edge followed by a rising edge and is capable of counting frequencies up to at least 1 MHz CAL amp STB These terminals are used during testing and calibration The CAL terminal is a 2 5 volt reference 5V The LabJack has a nominal 5 volt internal power supply Power can be drawn from this power supply by connecting to the 5V screw terminals or the 5V pins on the DB23 connector The total amount of current that can be drawn from the 5V pins analog outputs and digital outputs is 450 mA for most desktop computers and self powered USB hubs Some notebook computers and bus powered hubs will limit this available current to about 50 mA GND The GND connections available at the screw terminals and DB25 connector provide a common ground for all LabJack functions Figure 15 Labjack U12 19 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan 2 4 Agilent HP 8761B Is a single pole double throw coaxial switch with excellent electrical and mechanical characteristics for 50 ohm transmission systems operating from de to 18 GHz It features broadband operation long life low SWR excellent repeatability and magnetic latching solenoids The Agilent 8761B switch is small and lightweight making it ideal for applications where space is limited Because of its versatility and excellent electrical performance it is well suite
70. perform an action if a user clicks a mouse on a button or types information on a keyboard A mouse click or a key press is an event and the MATLAB program must respond to each event if the program is to perform its function For example if a user clicks on a button that event must cause the MATLAB code that implements the function of the button to be executed The code executed in response to an event is known as a call back There must be a callback to implement the function of each graphical component on the GUI 23 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan 3 3 Graphical User Interface Components This section summarizes the basic characteristics of common graphical user interface components It describes how to create and use each component as well as the types of events each component can generate 3 3 1 Text Fields A text field is a graphical object that displays a text string You can specify how the text is aligned in the display area by setting the horizontal alignment property By default text fields are horizontally centered A text field is created by creating a uicontrol whose style property is edit A text field may be added to a GUI by using the text tool in the Layout Editor Text fields do not create callbacks but the value displayed in the text field can be updated in a callback function by changing the text field s String property 3 3 2 Edit Boxes An edit box is a graphical object t
71. r dBm Start Frec Mh 22 59 Stop Frec Mh 5 P X pots Fia pa Kak oni Ud e E i sika da ls 5 0 50 1 00 1 50 200 0 50 1 00 1 50 200 Figure 34 Save Antenna Saves the antenna to the binary MAT file named Antenna lt number gt mat The data may be retrieved with LOAD With the command uiputfile it is possible display a dialog box for the user to fill in and returns the filename and path strings and the index of the selected filter When the antenna is saved the file contains an array with three files and a number of culumns as big as the number of points The first column contains measurements in frequency the second contains measurements in magnitude and the third contains measurements in phase 43 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan MATLAB iiis X File Edit eb Window p Dig 5 BB BH CurentDirectory C MATLABEpSwork v EDITT GE R Using Toolbox Path Cache Type help toolbox path cache for more info Name Size Bytes Class To get started select MATLAB Help from the Help menu lsxzoo 4800 double a Variables created in current workspace gt gt 2 Array Editor m File Edit View Web Window Help 22 Numeric format shotG Size B by 200 4 6 33 8 9 10 Mat 12 13 14 15 l 160 29 240 29 280 29 320 29 360 29 400 29 440 28 480 28 520 28 560 28 6
72. read creation Use with TestPoint on Windows 98 ME PulseOut Creates pulses on any all of DO D7 PulseOutStart Starts a pulse output similar to PulseOut but does not wait for it to finish PulseOutFinish Waits for the finish of a pulse output started with PulseOutStart PulseOutCalc Used to calculate cycle times for the pulse output functions 76 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan ReEnum Causes the LabJack to electrically detach from and re attach to the USB so it will re enumerate The local ID and calibration constants are updated at this time Reset or ResetLJ Causes the LabJack to reset after about 2 seconds After resetting the LabJack will re enumerate SHT1X Retrieves temperature and or humidity readings from an SHT1X sensor SHTComm Generic low level function to send and receive up to 4 bytes to from an SHTIX sensor SHTCRC Checks the CRC on an SHT1X communication Synch Performs SPI communication with a slave device Watchdog Controls the LabJack watchdog function When activated the watchdog can change the states of digital I O if the LabJack does not successfully communicate with the PC within a specified timeout period This function could be used to reboot the PC allowing for reliable unattended operation The 32 bit counter CNT is disabled when the watchdog is enabled ReadMem Reads 4 bytes from a specified address in the LabJack s nonvolatile memory WriteMem Writes 4
73. s 1 ms e Switching between setups 10 ms e Data transfer time 0 7 ms 201 points via RSIB e Simultaneous measurement of more than one DUT User Interface e Intuitive Windows based mouse operation e Operation using hardkeys and softkeys 21 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan e High number of channels and traces e Parallel setup administration e Operating wizards for e g balanced measurements and calibrations Connectivity e Compatibility with conventional design tools e Trace data exchange between R amp S ZVB in both directions e Remote control via GPIB and LAN e Digital VO port e USB connectors 22 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan 3 THE GRAPHICAL USER INTERFACE 3 1 Introduction A graphical user interface GUI is a pictorial interface to a program A good GUI can make programs easier to use by providing them with a consistent appearance and with intuitive controls like pushbuttons list boxes sliders menus and so forth The GUI should behave in an understandable and predictable manner so that a user knows what to expect when he or she performs an action For example when a mouse click occurs on a pushbutton the GUI should initiate the action described on the label of the button 3 2 How a Graphical User Interface Works A graphical user interface provides the user with a familiar environment in which to work This enviro
74. skolan Appendix 5 SCPI Command Tables COMMAND PARAMETERS UNIT COMMENT Aa T 47 FORMat MLINear MLOGarithmic PHASe UPHase POLar SMITH SMith GDELay REAL IMAGinary SWR COMPlex MAGNitude for compatibility with ZVR COMMAND PARAMETERS UNIT COMMENT FUNCtion SELect MAXimum MINimum RPEak LPEak NPEak TARGet LTARget RTARget BFiLter for compatibility with ZVR BWIDth lt numeric_value gt MODE BPASs BSTop BPRMarker BSRMarker TARGet lt numeric_value gt for compatibility with ZVR RESult query only DELTa STATe lt Boolean gt CENTer no query STAR no query STOP no query APEak EXCursion lt numeric_value gt THReshold lt numeric_value gt DOMain USER numeric value STARt lt numeric_value gt Hz S dBm STOP lt numeric_value gt Hz S dBm EXECute lt none gt MAXimum MINimum no query RPEak LPEak NPEAK TARGet LTARget RTARget BFILter for compatibility with ZVR 79 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan COMMAND PARAMETERS UNIT COMMENT CALCulate lt 1 4 gt A A J PARameter CATalog DEFine SDEFine MEASure DELete SELect query only lt string gt no query R3A R3 R4A R4B R1R2 R1R3 R1RA R2R1 R2R3 R2R4 R3R1 R3R2 R3R4 R4R1 RAR2 R4R3 lt numeric_value gt lt string gt lt string gt no query lt string gt lt str
75. sta default start frequency 300Khz fprintf g sens d freq stop dMhz wai x sto default stop frequency 8Ghz fprintf g sens d swe poin d wai x point default number of points 200 fprintf g calc d form s wai x form default format magnitude else disable buttons that would send controller commands if pressed disable text boxes as well set handles edit1 Enable off set handles edit2 Enable off set handles edit3 Enable off set handles edit4 Enable off set handles listbox 1 Enable off set handles listbox2 Enable off set handles listbox3 Enable off set handles popupmenul Enable off set handles popupmenu2 Enable off set handles pushbutton 1 Enable off set handles pushbutton2 Enable on load set handles pushbutton3 Enable off set handles pushbutton4 Enable off 59 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan set handles pushbutton5 Enable off set handles pushbutton6 Enable off closes the communication set handles togglebutton1 string Connect backgroundcolor default g handles varg fclose g delete g clear g end function listbox 1_CreateFcn hObject eventdata handles hObject handle to listbox1 see GCBO eventdata reserved to be defined in a future version of MATLAB handles empty handles not created until after all CreateFcns called Hint listbox
76. t bias current of 90 pA Single Ended The input range for a single ended measurement is 10 volts Differential channels can make use of the PGA to provide gains up to 20 giving an effective resolution greater than 16 bits In differential mode the voltage of each AI with respect to ground must be between 10 volts but the range of voltage difference between the 2 Al is a function of gain G as follows G 1 20 volts G 2 10 volts G 4 5 volts G 5 4 volt G 8 2 5 volts G 10 2 volts G 16 1 25 volts G 20 1 volt AO0 AO1 The LabJack U12 has 2 screw terminals for analog output voltages Each analog output can be set to a voltage between O and the supply voltage 5 volts nominal with 10 bits of resolution 100 103 Connections to 4 of the LabJack s 20 digital I O are made at the screw terminals and are referred to as IOO IO3 These 4 channels include a 1 5 k Q series resistor that provides overvoltage short circuit protection DO D15 Connections to 16 of the LabJack s 20 digital I O are made at the DB25 connector and are referred to as DO D15 These 16 lines have no overvoltage short 18 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan circuit protection and can sink or source up to 25 mA each total sink or source current of 200 mA max for all 16 All digital I O are CMOS output and TTL input except for D13 D15 which are Schmitt trigger input CNT The input connection to the 32 bit c
77. the trace f stop freq start freq number of points Zofrequency for every point for i 1 point j f i sta sG j array of frequency end The second file contains the measurements in magnitude and the third file contains the measurements in phase The different hardware elements are Network analyzer Sixteen antenas Labjack USB Ordenador port til GPIB B USB Fourteen multiplexores 8761 B REMOTE CONTROL OF D 77 lardalens H gskolan Interactive M file functions Instrument Control Toolbox M file functions Interface driver adaptors Property values data and events GPIB driver Property values data and events GPIB controller Hmm Figure 5 Operation Diagram NETWORK ANALYZER ANTENNAS Figure 6 Components Hardware REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan 2 HARDWARE 2 1 GPIB 2 1 1 Introduction In 1965 Hewlett Packard designed the Hewlett Packard Interface Bus HP IB to connect their line of programmable instruments to their computers Because of its high transfer rates nominally 1 Mbytes s this interface bus quickly gained popularity It was later accepted as IEEE Standard 488 1975 and has evolved to ANSI IEEE Standard 488 1 1987 Today the name G eneral Purpose Interface Bus GPIB is more widely used than HP IB ANSVIEEE 488 2 1987 strengthened the original standard by defining precisely how controllers and instruments
78. the trace as the active trace fprintf g CALC d DATA FDAT x y str2num fscanf g plot y k black hold on grid on end if findstr f Trc8 fprintf g calc d par sel select the trace as the active trace fprintf g CALC d DATA FDAT x y str2num fscanf g plot y b hold on grid on end if findstr f Trc9 fprintf g calc d par sel Trc9 x select the trace as the active trace fprintf g CALC d DATA FDAT x y str2num fscanf g plot y g hold on grid on end if findstr f Trc10 fprintf g calc d par sel Trc10 x select the trace as the active trace fprintf g CALC d DATA FDAT x y str2num fscanf g plot y r hold on grid on end if findstr f Trc11 fprintf g calc d par sel Trc11 x select the trace as the active trace fprintf g CALC d DATA FDAT x y str2num fscanf g plot y c hold on grid on end if findstr f Trc12 fprintf g calc d par sel Trc12 x fprintf g CALC d DATA FDAT x y str2num fscanf g plot y m hold on grid on 63 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan end if findstr f Tre13 fprintf g calc d par sel Trc13 x select the trace as the active trace fprintf g CALC d DATA y str2num fscanf g plot y y hold on grid on end if findstr f Trc14 fprintf g calc d par sel Trc14 x select the trace as the active trace
79. tings or selecting another measured quantity the analyzer needs some time to initialize the new sweep This preparation period increases with the number of points and the number of partial measurements involved All analyzer settings can still be changed during sweep initialization If necessary the analyzer terminates the current initialization and starts a new preparation period e 3 4 9 1 Remote control SENSe lt Ch gt SWEep POINts 3 4 10 Power Edit Text Disconnect Save Antenna New Trace Delete Trace Bandwidth Hz z Formaat Number of Ponte 40 St t Frec Mha 00 Stop Frec Hh Figure 33 Power The channel power determines the output power at the test ports if a Frequency Sweep or a Time Sweep is active The setting has no effect in Power Sweep mode where the source power is varied over a continuous range The selected channel power applies to all source ports used in the active channel Power sets the output power at the test port that supplies the stimulus for the active channel The channel power can be varied over a wide dynamic range This leaves enough flexibility to include an attenuation or gain in the test setup e 3 4 10 1 Range 40 dBm to 10 dBm The exact range depends on the analyzer model refer to the data sheet dBm UP and DOWN increment decrement the source power in 0 1 dB steps e 3 4 10 2 Remote control SOURce lt Ch gt POWer L
80. top frequency is 8Ghz 3 4 13 2 Remote control SENSe lt Ch gt FREQuency STOP stop frequency 3 4 14 Antenna Selects an antenna betwen the 16 antennas To select an antenna the Labjack U12 has to be connected with the PC It does not need a GPIB conexion because it is independent of the GPIB e The function EDIGITALOUT Easy function This is a simplified version of DigitallO that sets clears the state of one digital output Also configures the requested pin to output and leave it that way Execution time for this function is 50 ms or less Note that this is a simplified version of the lower level function DigitallO which operates on all 20 digital lines The DLL ljackuw attempts to keep track of the current direction and output state of all lines so that this easy function can operate on a single line without changing the others When the DLL is first loaded though 1t does not know the direction and state for the lines and assumes all directions are input and output stares are low Matlab Syntax errorcode idnum EDigitalOut idnum demo channel writeD state 42 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan 3 4 15 Save Antenna Pushbutton Save Antenna New Trace Load Antenna Collect All Traces Delete Trace Save antenna as Guardar en gt work Mantennat E a Jantennaz Bandwidth Hz Format bd Number of Points Powe
81. trols usually have a white background on Windows See ISPC and COMPUTER if ispc set hObject BackgroundColor white else set hObject BackgroundColor get 0 defaultUicontrolBackgroundColor end function listbox3_Callback hObject eventdata handles SELECT TRACE Select an existing trace as the active trace of the chanel x handles varx channel w handles varw trace g handles varg contents get handles listbox3 string returns listbox3 contents as cell array conl contents get handles listbox3 value returns selected item from listbox3 switch 1 case 1 w 1 Ynumber of channel fprintf g calc d par sel Trc d x w select the trace as the active trace handles varw w guidata hObject handles ostores the specified data in the figure s application data 68 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan case 2 w 2 Ynumber of channel fprintf g calc d par sel Trc d x w select the trace as the active trace handles varw w guidata hObject handles ostores the specified data in the figure s application data case 3 w 3 number of channel fprintf g calc d par sel Trc d x w select the trace as the active trace handles varw w guidata hObject handles ostores the specified data in the figure s application data case 4 w 4 number of channel fprintf g calc d par sel Trc d x w select the trace as the active trace handles var
82. ts of edit4 as text sto str2double get hObject String returns contents of edit4 as a double fprintf g sens d freq stop dMhz wai x sto sets the stop frequency handles varsto sto guidata hObject handles function pushbutton1 Callback hObject eventdata handles 5 ANTENNA form handles varform format sto handles varsto stop frequency sta handles varsta start frequency point handles varpoint number of points x handles varx channel g handles varg f sto sta point frequency for every point 72 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan for i 1 point j f i sta s 1 array of frequency end fprintf g calc d form magn wai x changes the format to magnitude to store every point fprintf g CALC d DATA FDAT x mag str2num fscanf g array of magnitud fprintf g calc d form phas wai x Zochanges the format to phase to store every point fprintf g CALC d DATA FDAT x pha str2num fscanf g array of phase fprintf g calc d form s wai x form Jochanges at the start format m 1 s the frequency in the first file of m m 2 mag ostores the magnitude in the second file of m m 3 pha stores the phase in the third file of m creates a save file dialog box to store plotted data saved in m FileName PathName uiputfile Antenna mat Save antenna as if FileName when you clic cancel return end FileNam
83. ty 23 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan 3 4 Graphical User Interface with Matlab 3 4 1 Connect Disconnect Togglebutton ee Load Antenna Bandwidth HJ A Plot Window Plot Window dr 1 0 8 0 6 0 6 04r 0 4 Number of Points 02 02 ot D Power dBm 02 0 2 Start Frec Mhz 4 0 4 06 0 6 Stop Frec Mhz 08 0 8 1 1 1 1 1 1 1 1 1 J 2 1 1 1 1 1 1 1 1 1 1 a e qub Ds quA DB DS D qo devel D 3 met 05 DB D7 A Figure 18 Connect Disconnect Save Antenna New Trace Load Antenna D Collect All Traces elete Trace Collet one Trace Bandwidth Hz Plot Window Plot Window ir Format Z 08 0 6 D 6f D 4F 0 4 Number of Points 02 02 ot Power dBm 02 0 2 Start Frec Mhz 4 0 4 0 6 0 6 Stop Frec Mhz 0 8t _ ET D 01 02 04 05 06 07 08 1 n iZ D3 06 07 08 0371 Figure 19 Disconnect Connect Disconnect is a toggle button this is a type of button that has two states on depressed and off not depressed A toggle button switches between these two states whenever the mouse clicks on it and it generates a callback each time The Value 26 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan property of the toggle button is set to max usually 1 when the button is
84. uantity in the range between 180 degrees and 180 degrees e Properties The stimulus variable appears on the horizontal axis scaled linearly The phase of the complex quantity C 1 e _ C arctan Im C Re C appears on the vertical axis _ C is measured relative to the phase at the start of the sweep reference phase 0 If _ C exceeds 180 the curve jumps by 360 if it falls below 180 the trace jumps by 360 The result is a trace with a typical sawtooth shape The alternative Phase Unwrapped format avoids this behavior e Application Phase measurements e g phase distortion deviation from linearity 3 4 8 1 3 Real Selects a Cartesian diagram to display the real part of a complex measured quantity 36 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan e Properties The stimulus variable appears on the horizontal axis scaled linearly The real part Re C of the complex quantity C Re C j Im C appears on the vertical axis also scaled linearly e Application The real part of an impedance corresponds to its resistive portion 3 4 8 1 4 Imag Selects a Cartesian diagram to display the imaginary part of a complex measured quantity e Properties The stimulus variable appears on the horizontal axis scaled linearly The imaginary part Im C of the complex quantity C Re C j Im C appears on the vertical axis also scaled linearly e Application The imaginary p
85. w w guidata hObject handles ostores the specified data in the figure s application data case 5 w 5 number of channel fprintf g calc d par sel Trc d x w select the trace as the active trace handles varw w guidata hObject handles ostores the specified data in the figure s application data case 6 w 6 Ynumber of channel fprintf g calc d par sel Trc d x w select the trace as the active trace handles varw w guidata hObject handles stores the specified data in the figure s application data case 7 w 7 Ynumber of channel fprintf g calc d par sel Trc d x w select the trace as the active trace handles varw w guidata hObject handles stores the specified data in the figure s application data case 8 w 8 number of channel fprintf g calc d par sel Trc d x w select the trace as the active trace handles varw w guidata hObject handles stores the specified data in the figure s application data case 9 w 9 number of channel fprintf g calc d par sel Trc d x w select the trace as the active trace handles varw w guidata hObject handles ostores the specified data in the figure s application data case 10 w 10 Sonumber of channel fprintf g calc d par sel Trc d x w select the trace as the active trace handles varw w guidata hObject handles stores the specified data in the figure s application data case 11 69 REMOTE CONTROL
86. which of the strings is currently selected A popup menu may be added to a GUI by using the popup menu tool in the Layout Editor 24 REMOTE CONTROL OF DEVICES WITH A GPIB AND MATLAB M lardalens H gskolan 3 3 6 List Boxes List boxes are graphical objects that display many lines of text and allow a user to select one or more of those lines If there are more lines of text than can fit in the list box a scroll bar will be created to allow the user to scroll up and down within the list box The lines of text that the user can select among are specified by a cell array of strings and the Value property indicates which of the strings are currently selected A list box is created by creating a uicontrol whose style property is listbox A list box may be added to a GUI by using the listbox tool in the Layout Editor List boxes can be used to select a single item from a selection of possible choices In normal GUI usage a single mouse click on a list item selects that item but does not cause an action to occur Instead the action waits on some external trigger such as a pushbutton However a mouse double click causes an action to happen immediately Single click and double click events can be distinguished using the SelectionType property of the figure in which the clicks occurred A single mouse click will place the string normal in the SelectionType property and a double mouse click will place the string open in the SelectionType proper
Download Pdf Manuals
Related Search
Related Contents
334228B - PR70E, Instructions, French HARD DRIVE and DUAL CD PLAYER SYSTEM USER`S MANUAL Anthofit - Zedental IC Plus Electronics Unit YMCS0004 and YMCS0005 Operating and APPENDIX C : DESIGN AND SYSTEM OF WEB CONTENTS Copyright © All rights reserved.
Failed to retrieve file