Agilent Technologies E4374A, E4370A, E4371A manual C Program Examples

Models: E4374A E4371A E4370A

1 141
Download 141 pages 7.46 Kb
Page 107
Image 107
C Program Examples - 7

C Program Examples - 7

Example 2

This following C program shows you how to implement the example discussed at the end of chapter 1 using the API cell forming functions. Note that this example only includes a brief cell forming sequence and does not include error checking after each function call. It primarily describes how you can incorporate the various high-level features of the Agilent MCCD such as the digital I/O and the serial ports in a cell forming sequence.

Serial port A is programmed to operate in passthrough mode, so that information from a barcode reader that is connected to port A is directly sent to the PC.

To match the example at the end of chapter 1, the digital ports are programmed as follows:

Pins 0, 1, and 2 are programmed as low-true general purpose digital inputs. To use the digital inputs connect a switch from the digital port to ground. Pin 0 is connected to the fixture switch. Pin 1 is connected to the Start button. Pin 2 is connected to a smoke detector switch. With the switches open, an internal +5Vpullup resistor sets these inputs high or FALSE. With the switches closed, the digital inputs are connected to common or low TRUE.

Pins 8 and 9 are programmed as low true general purpose outputs. To use the digital outputs connect a light from the digital port to a +24V source such as the auxiliary output. Pin 8 is connected to the Ready light. Pin 9 is connected to the Test light. When programmed to 0 (FALSE), the digital port is an open circuit and the light is off. When programmed to 1 (TRUE), the digital port is connected to common and the light turns on.

/* sample1.c */

#include <windows.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <io.h> #include "mccd.h"

/* Default server address and password */ #define DEFAULT_SERVER "15.14.250.125" #define DEFAULT_PASSWORD "mypassword"

/* Digital port bit definitions */ #define DIG_FIXTURE_READY0x0001 #define DIG_START_BUTTON 0x0002 #define DIG_SMOKE_DETECT 0x0004

#define

DIG_READY_LIGHT

0x0100

#define

DIG_TEST_LIGHT

0x0200

#define CLIENT_TIMEOUT 60.0f #define MAX_BARCODE 256 #define LOG_FILE "MCCDLOG.TXT" #define MEAS_BUF_SIZE 1024

/* Local function prototypes */

void APIError(CF_HANDLE hServer, char *szName, int nError); char *RunStateToString(CF_RUN_STATE state);

107

Page 107
Image 107
Agilent Technologies E4374A, E4370A, E4371A manual C Program Examples