Programming the RF Switch 25
Chapter 2
err= viPrintf (rf_mux,"PATH:COMM? 02,01\n");
if (err < VI_SUCCESS) err_handler (rf_mux,err);
err = viScanf (rf_mux,"%d",&ch_closed);
if (err < VI_SUCCESS) err_handler (rf_mux,err);
if (ch_closed == 1) printf ("Signal path 02,010 is closed");
else printf ("Signal path 02,010 is NOT closed");
/* Close the session */
viClose (rf_mux);
viClose (defaultRM);
}
void err_handler()
/* Error handling routine */
{
ViStatus err;
char err_msg[1024]={0};
viStatusDesc(rf_mux,err,err_msg);
printf ("Error = %s\n",err_msg);
return;
}
Example: Saving
and Recalling
Module States
The
*SAV
command saves the current state of all relays on the Cascade
RF Switch module and thus all the signal path connections. You can use
*SAV
to save up to ten module states and then use the
*RCL
command to
return to a specific saved state.
The commands have the form
*SAV<n>
and
*RCL<n>
where
<n>
has a
range of 0 to 9. Error -222, “Data out of range” results if a value other than
0 through 9 is used for
<n>
.
This example program first creates several PATH configurations and saves
that module state as state number 1. Next, the program creates additional
paths (while the previous paths remain closed) and saves that state as
state 2. Then, the program resets the module and recalls module state
number 1.
#include <visa.h>
#include <stdio.h>
#include <stdlib.h>
void err_handler();
void main()
{
int ch_closed;
/* Create and open a device session. E1470 is at logical address 120 */
ViStatus err;
ViSession defaultRM,rf_mux;
viOpenDefaultRM(&defaultRM);
viOpen (defaultRM,"GPIB-VXI0::9::120",VI_NULL,VI_NULL,&rf_mux);
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com