Users Manual & Installation Guide
PV-
SERIES
16 D
IGITAL INPUTS
, 48 D
IGITAL OUTPUTS
Page
6 of 12
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 (B0)
#define OUTBYTE1 (B1)
#define OUTBYTE2 (B2)
#define OUTBYTE3 (B3)
#define OUTBYTE4 (B4)
#define OUTBYTE5 (B5)
#define INBYTE0 (B6)
#define INBYTE1 (B7)
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 */
outportb (INBYTE0, 0x01);
/* Make /DO0 active, all others off */
outportb (INBYTE0, 0x02);
/* Make /DO1 active, all others off */
outportb (INBYTE0, 0x04);
/* Make /DO2 active, all others off */