#include #include #include #include #include #include #include "8000a.h" #include "8028U.h" void main() { int enStatus=1,ifWDT_Overwrite=1,wdtTimeout=0; int ch, ret=-1, i,slot=-1,status=1; char act; char GainStr[6][32]={"0~ 5V", "0~ 10V", "+/- 5V", "+/- 10V", "4~ 20mA", "0~ 20mA"}; short gain =0,gg; float fAO=0,ff; float POAO=0; InitLib(); for(i=0;i< 8;i++) { ret = i8028UW_Init(i); if(ret== 0) { slot = i; Print("I-8028UW on slot %d \n",slot); break; } } if(slot ==-1) { Print("There is no I-8028UW on the backplane\n"); Getch(); return; } again: Print("Select Output Range : \n"); Print("0 : 0~ 5V \n"); Print("1 : 0~ 10V \n"); Print("2 : +/- 5V \n"); Print("3 : +/- 10V \n"); Print("4 : 4~ 20mA \n"); Print("5 : 0~ 20mA \n"); // Set gain Scanf("%d", &gain); if(gain >5 || gain <0) { Print("invalid input\n"); return; } if(gain>3) Print("Please make sure the Jumper is in current operation\n"); //else Print("Please make sure the Jumper is in voltage operation\n"); // Set output value Print("Set AO value, between %s \n", GainStr[gain]); Scanf("%f", &fAO); // Set output channel Print("Set output channel : \n"); Print("\t For I-8028UW Channel index 0~7 \n"); Print("\t For I-8024UW Channel index 0~3 \n"); Scanf("%d", &ch); // Set Power on output value Print("Set a different AO value for Safe Value , between %s \n", GainStr[gain]); Scanf("%f", &POAO); i8028UW_WriteSafe_AO(slot,ch,gain,POAO); i8028UW_ReadSafe_AO(slot,ch,&gg,&ff); // set WDT enable = true enStatus = 1; // enable Output when WDT timeout ifWDT_Overwrite = 0; // Set Watch Dog Time Print("Please Input WDT timeout value, 1 ~ 16 second \n"); Scanf("%lu", &wdtTimeout); i8028UW_WriteAO(slot,ch,gain,fAO); if(gain>3) { Print("Now the I-8028UW should output %2.4f ma at CH %d \n",fAO,ch); Print("The Output will become %2.4f ma at CH %d when watch time out\n",POAO,ch); } else { Print("Now the I-8028UW should output %2.4f V at CH %d \n",fAO,ch); Print("The Output will become %2.4f V at CH %d when watch dog time out\n",POAO,ch); } Print("Press any key to start test \n"); Getch(); i8028UW_SetModuleWDTConfig(slot,enStatus, wdtTimeout,ifWDT_Overwrite); for(i=wdtTimeout;i>=0;i--) { status=i8028UW_GetModuleWDTStatus(slot); //Print("Countdown...%d , status %d \r",i,status); Delay(2000); } Print("Countdown...%d , status %d \r",i,status); Getch(); return; }