User manual

112 Register-Based Programming Appendix B
Example: Scanning
Channels
This C program example is similar to the closing/opening example except
that it scans through the entire 64 channels on the multiplexer. By placing
your own multimeter programming code where indicated you can create a
scanning multimeter.
#include <stdio.h>
#include <chpib.h>
#include <cfunc.h>
#define LOG_ADDR 112L
#define BASE_ADDR (long) ((0x1FC000) + (64 * LOG_ADDR))
main ( )
{
int reg_addr = 36;
long bit_number;
float send_data[3], read;
char state[2] = {13,10};
send_data[0] = BASE_ADDR + reg_addr;
send_data[1] = 16;
send_data[2] = pow(2,5);
IOEOI (7L, 0); IOEOL (7L, " ", 0);
IOOUTPUTS (70900L, "DIAG:POKE", 10);
IOEOI (7L, 1); IOEOL (7L, state,0);
IOOUTPUTA (70900L, send_data, 3);
send_data[0] = BASE_ADDR + 4;
IOEOI (7L, 0); IOEOL (7L, " ", 0);
IOOUTPUTS (70900L, "DIAG:PEEK? ", 11);
IOEOI (7L, 1); IOEOL (7L, state, 2);
IOOUTPUTA (70900L, send_data, 2);
while (bit_number != 0)
{
IOENTER(70900L, &read);
bit_number = ((long) (read) >6 & 1); }
/* insert your multimeter programming code here*/
send_data[2] = 0;
IOEOI (7L, 0); IOEOL (7L, " ", 0);
IOOUTPUTS (70900L, "DIAG:POKE", 10);
IOEOI (7L, 1);IOEOL (7L, state,0);
IOOUTPUTA (70900L, send_data, 3);
send_data[0] = BASE_ADDR + 4;
IOEOI (7L, 0); IOEOL (7L, " ", 0);
IOOUTPUTS (70900L, "DIAG:PEEK?", 11);
IOEOI (7L, 1); IOEOL (7L, state, 2);
IOOUTPUTA (70900L, send_data, 2);
while (bit_number != 0)
{