HP (Hewlett-Packard) B Network Router User Manual


 
/* Function Prototypes */
void rst_clr(void);
void ad_confread(void);
void check_error(char *func_tion);
/****************************************************************************/
void main(void) /* run the program */
{
rst_clr(); /* reset the digitizer */
ad_confread(); /* function which configures the digitizer */
/* and takes the readings */
}
/****************************************************************************/
void ad_confread(void)
{
int length = 0, loop = 0, i = 0, swap = 0, bytes = 0, label = 0;
int *rdgs;
char lf_remove[1];
/* use the "set_commands" array to configure single ended input port */
/* 1 on digitizer channel 1 */
char static *set_commands[] =
{"CONF1:ARR:VOLT (20),1,(@1)", /* set 20 readings, 1V range */
"FORM PACK", /* set packed reading format */
"DIAG:CHAN:LAB 1"}; /* add label to each reading */
length = (sizeof(set_commands) / sizeof(char*));
/* Execute each command using a loop */
for (loop = 0; loop < length; loop++)
{
IOOUTPUTS(ADDR, set_commands[loop], strlen(set_commands[loop]));
}
/* function call to check for digitizer configuration errors */
check_error("ad_confread");
/* dynamically allocate memory for readings */
rdgs = malloc(20 * sizeof(int));
Continued on Next Page
60 Usin
g
the Di
g
itizer Chapter 2