/* This demo is used as a quick start for user to check basic information and AI accuracy If your I-8014W performs bad result, please take screen shot for this demo and mail to serivce@icpdas.com */ #include #include #include "8000E.h" #include "8014W.h" #include int slotIndex=-1; char gainStr[5][32]={"+/-10V","+/-5V","+/-2.5V","+/-1.25V","+/-20mA"}; short jumper; short firmware,isofirm; void main() { int slot,ch; short i,HVal; int maxCh=8; float fVal=0; char sTemp[20]; int iGain=0; char libDate[32]; unsigned short gainValue; short offsetValue; unsigned long T1,T3; start: Print("\nThis demo show how to use i8014W_ReadAI to read hex and float format analog input data.\n"); for(slot=0;slot<8;slot++) { if(i8014W_Init(slot)==0) { slotIndex=slot; break; } } if(slotIndex==-1) { Print("There is no i8014 at i8000\n"); exit(0); } else { Print("There is an i8014 at slot %d\n",slotIndex); } Print("\n****************************"); firmware = i8014W_GetFirmwareVer_L1(slotIndex); Print("\nPrimary FPGA Version =: %04X",firmware); isofirm = i8014W_GetFirmwareVer_L2(slotIndex); Print("\nSecondary FPGA Version =: %04X",isofirm); Print("\nLibrary Version =: %04X",i8014W_GetLibVersion()); i8014W_GetLibDate(libDate); Print("\nBuild Date =: %s",libDate); Print("\n****************************\n"); jumper = i8014W_GetSingleEndJumper(slotIndex); if(jumper) { maxCh=16; Print("i8014W Input Mode=Single-End\n\r"); } else { maxCh=8; Print("i8014W Input Mode=Differential\n\r"); } for(i=0;i<5;i++) { Print ("\n\t Select %d : %s",i,gainStr[i]); } Print("\n\r"); Print ("Select Gain (0~4):"); LineInput(sTemp,20); iGain=atoi(sTemp); i8014W_ReadGainOffset(slotIndex,iGain,&gainValue, &offsetValue); Print("Select Gain[%d]=%s ,the Calibrated Gain= %u, Calibrated Offset= %d\n\n",iGain, gainStr[iGain],gainValue,offsetValue); T1=GetTimeTicks(); for (;;) { T3=GetTimeTicks(); if ((T3-T1) >1000) // read frequency every 300 ms { T1=T3; for(i=0;i