|
Beispielprogramm für PREL16
|
QLIB Sample for PREL16
| |
/* ** Sample Source Visual-C++ 6.0 for QUANCOM PREL16 Relay board ** ** QUANCOM: 16 Channel Relay Card ** ** Install QLIB32 before running this program ** */
/* ** Standard-Includes */
#include <windows.h> #include <stdio.h>
#include "qlib.h"
void main () {
ULONG relay = 0L;
/* receives handle for prel16 board */
ULONG handle = NULL; /* 0 = first card in system ... 7 = eight card in system */
ULONG nCardNo = 0; /* we use only one PREL16 card here, so we take the first one */
/* get the handle to the relay board */
if ((handle = QAPIExtOpenCard(PREL16,nCardNo)) == 0L) { /* if the program stops here, no card was found */ printf("Couldn't open PREL16 relay board.\n"); return; }
/* PREL16 board found */ relay = 1L;
/* loop forever */
while ( 1 ) {
/* this command sets the relays */
QAPIExtWriteDO16(handle, 0, 1L << ( relay - 1), NULL);
if ( relay == 1 ) printf("Relay 1 is switched on. Red LED on the board should be switched on !\n", relay ); else printf("Relay %i is switched on. Red LED should be switched off!\n", relay );
/* pause for 2 seconds */
Sleep(2000); if ( relay > 16L ) { /* only 16 relays */ relay = 1L;
printf("\nPress Ctrl+C to terminate the program.\n\n");
} else { /* switch on next relay on */
relay++;
} } }
|
|
|