// i8172W_ReadAI.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include #include "pac_i8172W.h" #pragma comment(lib,"pac_i8172W.lib") static int slotIndex=-1; int main(int argc, char* argv[]) { //Declaration and default value assignment int slot = 1; int port = 0; int group = 0; short bitMode = 12; short typeCode = 0x08; // -10 ~ +10 V short channel = 0; short jumper =0; short maxCh=8; float AIFloat = 0.0F; for(slot=0;slot<8;slot++) { if(pac_i8172W_Init(slot)==0) { slotIndex=slot; break; } } if(slotIndex==-1) { printf("There is no i8172W at Backplane\n"); getchar(); return -1; } else { printf("There is an i8172W at slot %d\n",slotIndex); } printf("Please input the port number of i-8172W 0 or 1:"); scanf("%d",&port); printf("\nPlease input the group index of FR-2054 0~7 :"); scanf("%d",&group); printf("Please input jumper of FR-2017 Differential = 0 Single-Ended= 1:"); scanf("%d",&jumper); if(jumper ==0) maxCh=8 ; // default else maxCh=16; printf("Please input bit mode of FR-2017 -> 12 for 12-bit; 16 for 16-bit "); scanf("%d",&bitMode); printf("FR_2017 type code\n"); printf("0x1a 0 ~ 20 mA\n"); printf("0x7 4 ~ 20 mA\n"); printf("0x8 +/-10 V\n"); printf("0x9 +/-5 V\n"); printf("0xa +/-1 V\n"); printf("0xb +/-500 mV\n"); printf("0xc +/-150 mV \n"); printf("0xd +/-20 mA \n"); printf("\nPlease slect type code for FR-2017"); scanf("%d",&typeCode); if((0x1a != typeCode) && (typeCode < 7 || typeCode > 0xd)) typeCode = 0x08; // -10 ~ +10 V if(channel > 7 || channel < 0) //differential mode channel = 0; for(channel=0;channel