/* X104Demo.c: The demo program is output for X104 8 channels DI/O board. Compiler: BC++ 3.1, Turbo C ++ 1.01(3.01) (free from http://community.borland.com/museum) Compile mode: large Project: X104Demo.c ..\..\Lib\7188xcl.lib ..\..\Lib\Xboard\X104.lib Hardware: 7188XC + X104 X104: 8 channels. Each channel can be program to DI/DO. Note: Please remove the external signal which connects to X104, before changing the status of channels from DI to DO mode [18/Dec/2002] [20/July/2005] by Liam */ #include #include "..\..\lib\7188xc.h" #include "..\..\lib\Xboard\X104.h" void main(void) { int iAction, iStatus, iOutChannel, iDOValue=0, iRet, quit; InitLib(); X104_Init(_DO_); //Initialize the X104, and set all channels to DO Print("\r\n"); Print("****************************************\n\r"); Print("| Demo program for 7188XC + X104 |\n\r"); Print("| |\n\r"); Print("| [20/July/2005] |\n\r"); Print("****************************************\n\r"); while(iAction!=5) { iAction=0; quit=0; Puts("\r\n"); Puts("1) Write DO (all channels)\r\n"); Puts("2) Write DO (one channel)\r\n"); Puts("3) DO Readback (all channels)\r\n"); Puts("4) DO Readback (one channel)\r\n"); Puts("\r\n"); Puts("5) Quits demo program\r\n\r\n"); Puts("Choose an option and press [Enter]:"); Scanf("%d", &iAction); Puts("\r\n"); switch(iAction) { //Write all DO channels case 1: Print("Please input Output value(0 ~ 0xff): "); Scanf("%x", &iDOValue); iDOValue=X104_Write_All_DO(iDOValue); Print("Output value=> 0x%02x\r\n\r\n", iDOValue); break; //Write single DO channel case 2: Print("Please select outport channel(0~5 or 7) and status(0:OFF, 1:ON)\r\n"); Print("Channel number and status:"); Scanf("%d %d", &iOutChannel, &iStatus); if(iOutChannel>7 || iOutChannel==6) { Puts("Unknow Channel Number!!\r\n\r\n"); break; } X104_Write_One_DO(iOutChannel, iStatus); Print("Channel %d ==> %s\r\n\r\n", iOutChannel, (iStatus>=1)?"ON":"OFF"); break; //Read all DO ReadBack case 3: iDOValue=X104_Read_All_DO(); Print("Digital Output ReadBack=> 0x%02x\r\n\r\n", iDOValue); break; //Read single DO ReadBack case 4: Print("Please select outport channel(0~5 or 7): "); Scanf("%d", &iOutChannel); if(iOutChannel>7 || iOutChannel==6) { Puts("Unknow Channel Number!!\r\n\r\n"); break; } iRet=X104_Read_One_DO(iOutChannel); if(iRet) Print("Channel %d ==> ON\r\n\r\n", iOutChannel); else Print("Channel %d ==> OFF\r\n\r\n", iOutChannel); break; case 5: default: quit=1; break; } if(!quit) { Puts("Press any key to continue...\r\n"); Getch(); } } }