/* X105DO.c: The X105DO program is input for X105 8 channels DI/O board. (single channel programmable) Compiler: BC++ 3.1, Turbo C ++ 1.01(3.01) (free from http://community.borland.com/museum) Compile mode: large Project: X105DO.c ..\..\Lib\7188xcl.lib ..\..\lib\Xboard\X105.lib Hardware: 7188XC + X105 X105: 8 channels. Each channel can be program to DI/DO. Note: Please remove the external signal which connects to X105, before changing the status of channels from DI to DO mode [02/Aug/2002] [20/July/2005] by Liam */ #include #include "..\..\lib\7188xc.h" #include "..\..\lib\Xboard\X105.h" void main(void) { int iAction, iStatus, iOutChannel, iDOValue=0, iRet, quit; InitLib(); X105_Init(_DO_); //Initialize the X105, and set all channels to DO Print("\r\n"); Print("*****************************************\r\n"); Print("| Demo program for 7188XC + X105 |\r\n"); Print("| |\r\n"); Print("| [20/July/2005] |\r\n"); Print("*****************************************\r\n"); 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 DO (all channels) */ case 1: Print("Please input Output value(0 ~ 0xff): "); Scanf("%x", &iDOValue); X105_Write_All_DO(iDOValue); Print("Output value=> 0x%02x\r\n\r\n", iDOValue); break; /* Write DO (one channels) */ case 2: Print("Please select outport channel(0~7) and status(0:OFF, 1:ON)\r\n"); Print("Channel number and status:"); Scanf("%d %d", &iOutChannel, &iStatus); iRet=X105_Write_One_DO(iOutChannel, iStatus); if(iRet>0) Print("Channel %d ==> %s\r\n\r\n", iOutChannel, (iStatus>=1)?"ON":"OFF"); else Puts("Unknow command!!\r\n\r\n"); break; //Read all DO ReadBack case 3: iDOValue=X105_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~7): "); Scanf("%d", &iOutChannel); iRet=X105_Read_One_DO(iOutChannel); if(iRet>=0) { if(iRet) Print("Channel %d ==> ON\r\n\r\n", iOutChannel); else Print("Channel %d ==> OFF\r\n\r\n", iOutChannel); } else Puts("Unknow Channel Number!!\r\n\r\n"); break; case 5: default: quit=1; break; } if(!quit) { Puts("Press any key to continue...\r\n"); Getch(); } } }