
Using the I/O Address Map
DAI12-4(FIT)GY
35
Sample Program
/*======================================================
Sample program 2
DEVICE ID:
0
Mode:
Clock Mode, Simultaneous Conversion
Channel:
0 to 3ch
Range:
-10 to 10V
Internal Clock:
250msec (250ns x 1,000,000)
Interrupt:
N/A
====================================================== */
#include <stdio.h>
#include <conio.h>
/* ----- Constant -------------------------------------- */
#define ADR
0x0800
/* I/O address */
#define CH
4
/* Channels */
#define NUM
11
/* Conversion Times */
/* ----- Prototype ------------------------------------- */
void main( void );
/* ----- Main ------------------------------------------ */
void main( void )
{
unsigned char
UpperData[NUM], LowerData[NUM], sts;
unsigned char
i, j;
unsigned int
VDAT;
float
Volt[NUM];
outp( ADR+0x18, 0x00 ); /* Initialize */
outp( ADR+0x18, 0x02 ); /* D/A Conversion Mode */
outp( ADR+0x1c, 0x05 ); /* Software */
outp( ADR+0x18, 0x03 ); /* Range */
outp( ADR+0x1c, 0x00 ); /* -10 to 10V */
outp( ADR+0x18, 0x04 ); /* Timer Setting */
outp( ADR+0x1c, 0x3f ); /* 250ns x 1,000,000 */
outp( ADR+0x1d, 0x42 );
outp( ADR+0x1e, 0x0f );
outp( ADR+0x1f, 0x00 );
for(i = 0; i < NUM; i++) {
/* D/A Conversion Data */
VDAT = (unsigned int)(4096.0f/(NUM-1)*i);
if( VDAT > 0xfff )
VDAT = 0xfff;
UpperData[i] = (unsigned char)( ( VDAT & 0xff00 ) >> 8 );
LowerData[i] = (unsigned char)( VDAT & 0xff );
Volt[i] = (float)VDAT*20.0f/4096.0f-10.0f;
}
Содержание DAI12-4FITGY
Страница 1: ...F eIT Series Isolated Analog Output Module DAI12 4 FIT GY User s Manual CONTEC CO LTD...
Страница 47: ...Using the I O Address Map 42 DAI12 4 FIT GY...
Страница 64: ......