Microsoft C - Stanford Research Systems SR570 User Manual

Low-noise current preamplifier
Table of Contents

Advertisement

Program Example 2
IBM PC, Microsoft C, via RS232
In this example, the IBM PC's COM2 serial port is used to communicate with the SR570. The program asks
the user to enter an SR570 command to send to the instrument. Before running the program, use the DOS
'MODE' command to set up the serial port parameters, e.g. MODE COM2: 9600,n,8,2
/* Program written in Microsoft C to send commands to the SR570 current amplifier */
#include <stdio.h>
#include <conio.h>
#include <string.h>
#define BUFFER 0x2fd
#define OUT 0x2f8
#define MASK 0x20
void main(void)
{
int i,j;
char string[20];
while(1)
{
printf("input command string: ");
gets(string);
printf("\n");
j=strlen(string);
string[j]=13;
string[j+1]=10;
for ( i=0 ; i <= (j+1) ; i++ )
{ /*
while (( inp(BUFFER) & MASK ) == 0 ); /* Wait until transmit buffer is empty
outp( OUT , string[i] );
}
}
}
one character at a time */
/* COM2 output status : use 0x3fd for COM1 */
/* COM2 output port : use 0x3f8 for COM1 */
/* mask to pick out "buffer empty" bit */
/* Loop forever (use 'control C' to exit) */
/* Get command from user */
/* Append <CR><LF> to the command */
/* Send the command via RS-232 port */
/* Output the next character to COM2 */
13
Programming Examples
*/

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents