Micro Technic PV-1648 user manual Software example, OUTBYTE0

Page 5

Users Manual & Installation Guide

PV-SERIES 16 DIGITAL INPUTS, 48 DIGITAL OUTPUTS

Software example:

/* Compiler: Borland C++ 3.1 */

#include <stdio.h>

#include <dos.h> /* For inportb() and outportb() */

#define BASEADDR 0x300 /* This must match with SW1 on the PV1648 */ #define OUTBYTE0 (BASEADDR+0)

#define OUTBYTE1 (BASEADDR+1) #define OUTBYTE2 (BASEADDR+2) #define OUTBYTE3 (BASEADDR+3) #define OUTBYTE4 (BASEADDR+4) #define OUTBYTE5 (BASEADDR+5) #define INBYTE0 (BASEADDR+6) #define INBYTE1 (BASEADDR+7)

int main (void)

{

unsigned char value;

/* Show input 0-7

*/

 

value = inportb

(OUTBYTE0);

 

printf ("Input

0

= %d\n", (value>>0) &

0x01);

printf ("Input

1

= %d\n", (value>>1) &

0x01);

printf ("Input

2

= %d\n", (value>>2) &

0x01);

printf ("Input

3

= %d\n", (value>>3) &

0x01);

printf ("Input

4

= %d\n", (value>>4) &

0x01);

printf ("Input

5

= %d\n", (value>>5) &

0x01);

printf ("Input

6

= %d\n", (value>>6) &

0x01);

printf ("Input

7

= %d\n", (value>>7) &

0x01);

/* Show input 8-15 */

 

value = inportb

(OUTBYTE1);

 

printf ("Input

8

= %d\n", (value>>0) &

0x01);

printf ("Input

9

= %d\n", (value>>1) &

0x01);

printf ("Input

10

= %d\n", (value>>2) &

0x01);

printf ("Input

11

= %d\n", (value>>3) &

0x01);

printf ("Input

12

= %d\n", (value>>4) &

0x01);

printf ("Input

13

= %d\n", (value>>5) &

0x01);

printf ("Input

14

= %d\n", (value>>6) &

0x01);

printf ("Input

15

= %d\n", (value>>7) &

0x01);

/* Examples of

output operations on DO0

– DO7 */

outportb (OUTBYTE0, 0x01);

/* Make /DO0 active, all others

off */

outportb (OUTBYTE0, 0x02);

/* Make /DO1 active, all others

off */

outportb (OUTBYTE0, 0x04);

/* Make /DO2 active, all others

off */

outportb (OUTBYTE0, 0x08);

/* Make /DO3 active, all others

off */

outportb (OUTBYTE0, 0x10);

/* Make /DO4 active, all others

off */

outportb (OUTBYTE0, 0x20);

/* Make /DO5 active, all others

off */

outportb (OUTBYTE0, 0x40);

/* Make /DO6 active, all others

off */

outportb (OUTBYTE0, 0x80);

/* Make /DO7 active, all others

off */

outportb (OUTBYTE0, 0x81);

/* Make /DO0 & /DO7 active, all

others off */

return 0;}

 

 

Page 5 of 8

Image 5
Contents Micronix PC/104 Digital IN-/OUTPUT Board Inputs Schematic Outline Precautions to ESDPV 16 48 /PX- /5 /S ExampleRegister Format and Description OUTBYTE0 Software exampleOptional CABLES, 30CM GND00 GND04 Connector layoutGND01 GND05 GND02 GND06Input Circuitry Schematic Output Circuitry Schematic