#include #include #include #include #include #include #include "8000a.h" #include "8028U.h" void main() { int ch, ret=-1, i,slot=-1; char act; char GainStr[6][32]={"0~ 5V", "0~ 10V", "+/- 5V", "+/- 10V", "4~ 20mA", "0~ 20mA"}; short gain =0; float fAO=0; short oVal; unsigned short gVal; 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); i8028UW_ReadAO_GainOffset(slot,ch,gain,&gVal,&oVal); i8028UW_WriteAO(slot, ch , gain, fAO); Print("CH %d ,Range %s ,Gain %u ,Offset %d \nOutput Value = AO %7.3f \n",ch,GainStr[gain],gVal,oVal,fAO); Print("Press 'q' Or 'Q' to Exit.\nOr else to repeat again\n\n"); act=Getch(); if(act=='q' || act =='Q') return; else goto again; }