#include #include #include"..\lib\8000.h" //#include "7188x.h" #define F3 131 #define F4 132 /* This demo program is for I-8057,I-8053 Module,16 Digital Output & 16 digital Input. Before Run this program,connect the digital output to the digital input */ void x8057(void); void start(void); unsigned int SlotNo1,SlotNo2,DOdata,DIdata; void start(void) { //clear buffer //set Print("This demo program is for I-8057,I-8053 Module,16 Digital Output & 16 digital Input. "); Print("Press F3 to start\n\r"); Print("Please Input DO Module Slot Number(0 to 7) =");//Specific the digital output slot number of I-8057. SlotNo1 = ascii_to_hex(Getch());//MiniOS7 read the slot input. Print(" %d \n\r",SlotNo1);//Show the user input. Print("Please Input DO Data(Hex) = "); Scanf("%x",&DOdata);//MiniOS7 read the user keyin the digital output value. Print("DO data = %x\n\r",DOdata);//Show the user input. DIOData[SlotNo1].data16 = DOdata;//store the data to the internal variable.for later reference Print("Please Input DI Module Slot Number(0 to 7) =");//Specific the digital input slot number of I-8053. SlotNo2 = ascii_to_hex(Getch());//MiniOS7 read the slot input. Print(" %d \n\r",SlotNo2);//Show the user input. DO_16(SlotNo1,DIOData[SlotNo1].data16);//Function call to execute, set digital output Delay_1(300);//for Isolation Type,Wait the photo coupler DIdata = DI_16(SlotNo2);//Function call to execute, read digital input Print("DI data = %X\n\r",DIdata);//Show the digital input value. // Print("DI data = %X\n\r",rand()%256);//Show the digital input value. Print("%c",131); } void main() { int key; for(;;) { if(Kbhit()) { key=Getch(); if(key==F3)//Get F3 from Iview start(); else if(key=='Q') break; } x8057(); } } void x8057(void) { Delay_1(2000);//for Isolation Type,Wait the photo coupler DIdata = DI_16(SlotNo2);//Function call to execute, read digital input Print("%04X%04X%c",DOdata,DIdata,13);//Show the digital input value. }