ADInstruments AD2817C Operation Manual page 109

Lcr meter
Table of Contents

Advertisement

Available languages

Available languages

AD2817C Operation Manual
16) For some commands that will take a long time to execute, for example Correction
command, the controller should keep waiting to avoid the next command being
lost when AD2817C is executing the former command.
Sample Program for Serial Interface
z
The following is a C language sample program under DOS environment. The main function
may be expanded by users, and the other sub functions teach you how to input or output
a character string via the RS232 interface.
#define PORT 0
#include "dos.h"
#include "stdio.h"
#include "stdlib.h"
#include "ctype.h"
#include "conio.h"
void port_init( int port,unsigned char code );
int check_stat( int port );
void send_port( int port,char c );
char read_port( int port );
void string_wr( char *ps );
void string_rd( char *ps );
char input[256];
main()
{
port_init( PORT,0xe3 );/* initilize serial port:baud = 9600,no verify,1 bit stop,8 bit data
*/
string_wr( "trig:sour bus;*trg" );
string_rd( input );
printf( "\n%s",input );
string_wr( "freq 10khz" );
string_wr( "func:imp:apar cs;bpar d" );
string_wr( "voltage:level 0.3v" );
}
/* write string to serial port */
void string_wr( char *ps )
{
unsigned char c;
int m,n;
while( check_stat(PORT) & 256 ) read_port( PORT );/* read data until null */
for( m = 1000;m;m-- ) /*communication handshake:wait until ready*/
/* read serial port state(16bit) */
/* send a character to serial port */
/* recive a character form serial port */
/* write a string to serial port */
/* read a string from serial port */
/* quary recieve bufer */
44

Advertisement

Chapters

Table of Contents
loading

Table of Contents