beautypg.com

Example program, Program: demo01.c – B&B Electronics ADAM-4521 - Manual User Manual

Page 6

background image

Example Program

This demo program demonstrates how you might send a string of data to your HP34401A Multimeter (RS-232
device) via the ADAM-4521.

ADAM-4521 Configuration Status:

ADDRESS:02

MODE:ADDRESSABLE

DELIMITER: {

ADD(CR):NO

RS-485 baud(9600),N,8,1

RS-232 baud(9600),N,8,2

HP34401A RS-232 baud(9600),N,8,2

P C

(RS-232)

(RS-485)

(RS-232)

(RS-485)

DATA-

8

C O M 1

AM- 4521

3 RX

7

HP-34401A

Program: DEMO01.C

#include

#include

#include

#include
#define TIME_OUT

500000

static

static
static

int base0=0x3F8;

char rec[36];
char cmd[40];

void
void

send(void);
receive(void);

void main()

{

outp(base0+3,0x80);

/* set DLAB=1 */

outp(base0 ,0x0C); outp(base0+1,0x00); /* set buad=9600 */

outp(base0+3,0x03);

outp(base0+1,0x00);

printf("\nInput string : ");

gets(cmd);

while (cmd[0] != 'q' && cmd[0] != 'Q')

{

send();

receive();

printf("\nInput string : ");

gets(cmd);

}

/* set data=8 stop=1 no parity */
/* disable COM1 interrupt */

}

ADAM-4521 User's Manual

2 TX

5 GND

2 RX

3 TX

5 GND

DATA-

A D

DATA+

.

DATA+