#include #include #include #include #include #include #include "8000a.h" #include "8028U.h" void main() { 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; float fAO=0; 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 mode Print("Set Power on mode : \n"); Print("1 : Power on Value \n"); Print("2 : Power on as last output value(Retentive \n"); Scanf("%d", &status); if(status >2 || status <1) { Print("invalid input\n"); return; } i8028UW_SetPowerOnEnStatus(slot,status); if(status==1) { // Set Power on output value Print("Set a different AO value for Power On value , between %s \n", GainStr[gain]); Scanf("%f", &POAO); i8028UW_WriteAO(slot,ch,gain,fAO); i8028UW_WritePowerOn_AO(slot,ch,gain,POAO); if(gain>3) Print("Now the I-8028UW should output %2.4f ma at CH %d \n",fAO,ch); else Print("Now the I-8028UW should output %2.4f V at CH %d \n",fAO,ch); Print("To test Power on Value, please Reset the Power of PAC \n"); if(gain>3) Print("And the Output will become %2.4f ma at CH %d \n",POAO,ch); else Print("And the Output will become %2.4f V at CH %d \n",POAO,ch); } else { i8028UW_WriteAO(slot,ch,gain,fAO); Print("To test Power on as last output value(Retentive, please Reset the Power of PAC \n"); if(gain>3) Print("And the Output will hold at %2.4f ma at CH %d \n",fAO,ch); else Print("And the Output will hold at %2.4f V at CH %d \n",fAO,ch); } Getch(); return; }