Agilent Technologies E8257D PSG Instrukcja Użytkownika Strona 76

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
Przeglądanie stron 75
64 Agilent N516xA, N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Using IO Interfaces
RS–232 Programming Interface Examples
Interface Check Using HP BASIC
This portion of the example program “Interface Check Using HP BASIC” on page 64, causes the signal
generator to perform an instrument reset. The SCPI command *RST will place the signal generator
into a pre–defined state.
The serial interface address for the signal generator in this example is 9. The serial port used is
COM1 (Serial A on some computers). Refer to “Using RS–232 (ESG, PSG, and E8663B Only)” on
page 58 for more information.
The following program example is available on the signal generator’s Documentation CD–ROM as
rs232ex1.txt. For the full text of this program, refer to “Interface Check Using HP BASIC” on
page 142 or to the signal generator’s documentation CD–ROM.
170 CONTROL 9,0;1 ! Resets the RS-232 interface
180 CONTROL 9,3;9600 ! Sets the baud rate to match the sig gen
190 STATUS 9,4;Stat ! Reads the value of register 4
200 Num=BINAND(Stat,7) ! Gets the AND value
210 CONTROL 9,4;Num ! Sets parity to NONE
220 OUTPUT 9;"*RST" ! Outputs reset to the sig gen
Interface Check Using VISA and C
This portion of the example program “Interface Check Using VISA and C” on page 64, uses VISA
library functions to communicate with the signal generator. The program verifies that the RS–232
connections and interface are functional. In this example the COM2 port is used. The serial port is
referred to in the VISA library asASRL1 orASRL2 depending on the computer serial port you are
using.
The following program example is available on the signal generator Documentation CD–ROM as
rs232ex1.cpp. For the full text of this program, refer to “Interface Check Using VISA and C” on
page 143 or to the signal generators documentation CD–ROM.
int baud=9600;// Set baud rate to 9600
ViSession defaultRM, vi;// Declares a variable of type ViSession
// for instrument communication on COM 2 port
ViStatus viStatus = 0;
// Opens session to RS-232 device at serial port 2
viStatus=viOpenDefaultRM(&defaultRM);
viStatus=viOpen(defaultRM, "ASRL2::INSTR", VI_NULL, VI_NULL, &vi);
viStatus=viEnableEvent(vi, VI_EVENT_IO_COMPLETION, VI_QUEUE,VI_NULL);
viClear(vi);// Sends device clear command
// Set attributes for the session
viSetAttribute(vi,VI_ATTR_ASRL_BAUD,baud);
viSetAttribute(vi,VI_ATTR_ASRL_DATA_BITS,8);
Przeglądanie stron 75
1 2 ... 71 72 73 74 75 76 77 78 79 80 81 ... 379 380

Komentarze do niniejszej Instrukcji

Brak uwag