HP (Hewlett-Packard) E1459A Network Router User Manual


 
32 Using the HP E1459A Module
Digital Input The HP E1459A is capable of simple digital inputs on any of the individual
four ports or combined Ports 0 and 1 or Ports 2 and 3. The
MEASure
command subsystem (see Chapter 3 for details) provides two commands for
reading the current value of the input ports:
MEASure:DIGital:DATAn:
type
:VALue? — reads the current port value
MEASure:DIGital:DATAn:
type
:BIT
m
? — reads an individual bit value
Example 2:
Digital Input
This program reads Port 0 as an individual 16-bit port and then it reads the
combined Ports 2 and 3 as a 32-bit port. The values returned are a signed
16-bit integer for Port 0 and a signed 32-bit integer for combined Ports 2 and
3. Although this program does not decode the returned value to determine
individual bit/channel values, a "0" in any bit position indicates the input to
the corresponding channel is low; a "1" in any bit position indicates the
input to the corresponding channel is high.
/* Digital Input Example
This program reads the current value of Port 0 (16-bit word)
and combined value of Ports 2 and 3 (32-bit word)
Created in Microsoft Visual C++ */
#include <visa.h>
#include <stdio.h>
#include <stdlib.h>
#define INSTR_ADDR "GPIB0::9::3::INSTR"
/* HP E1459A logical address */
int main()
{
ViStatus errStatus;
/* status from VISA call */
ViSession viRM;
/* Resource Mgr. session */
ViSession E1459;
/* session for HP E1459A */
int val;
/* value of Port 0 */
long val1;
/*Value of Ports 2 & 3 */
/*
Open a default Resource Manager
*/
errStatus = viOpenDefaultRM (&viRM);
if (VI_SUCCESS > errStatus){
printf("ERROR: viOpen() returned 0x%x\n",errStatus);
return errStatus;}
/*
Open the Instrument Session
*/
errStatus = viOpen (viRM, INSTR_ADDR,VI_NULL,VI_NULL, &E1459);
if (VI_SUCCESS > errStatus){
printf("ERROR: viOpen() returned 0x%x\n",errStatus);
return errStatus;}
/*
Query Port 0 as a 16-bit word
*/
errStatus = viQueryf(E1459, "MEAS:DIG:DATA0:WORD:VAL?\n","%t", val);
if (VI_SUCCESS > errStatus){
printf("ERROR: viQueryf() returned 0x%x\n",errStatus);
return errStatus;}
printf("Value returned %i\n",val);