/**************************************************/ /*head file for 8172 */ /* */ /*Library: */ /* 8000E.lib */ /*Ver 1.1.3 [25 May,2010] by Martin */ /**************************************************/ #define Reset_FRnet i8172_ResetFRnet #define Read_DI_Group_status i8172_ReadInputGroupStatus #define i8172_Write_DO_Group i8172_WriteDOGroup #define i8172_Write_DO_Bit i8172_WriteDOBit #define i8172_Read_DI_Group i8172_ReadDIGroup #define i8172_Read_DI_Bit i8172_ReadDIBit int i8172_GetLibVersion(); /********************************************************* User use this function to read the version of lib. *********************************************************/ void i8172_GetLibDate(unsigned char *LibDate); /******************************************************** Reading the date of lib lately. *********************************************************/ int i8172_Init(int slot); /*************************************************************** Read hardware ID slot: 0 ~ 7 return: 0 OK -1 error ****************************************************************/ //void i8172_ResetFRnet(int slot, int port); /************************************************************** Clear all group status. slot: 0 ~ 7 port: 0 or 1 ***************************************************************/ //FR-2057 function void i8172_WriteDOGroup(int slot,int port, int group, unsigned int doData); /*************************************************************** User use this function to input Hex value to DO module, slot: 0 ~ 7 port: 0 or 1 group: 0 ~ 7 iData: 0 ~ 0xffff ****************************************************************/ //FR-2057 function void i8172_WriteDOBit(int slot,int port,int group,int bitIndex, int bitStatus); /**************************************************************** User use this function to input single channel to DO module, slot: 0 ~ 7 port: 0 or 1 group: 0 ~ 7 bitIndex: 0~15 bitStatus: 0 off 1 on ****************************************************************/ //FR-2053 function unsigned int i8172_ReadDIGroup(int slot,int port,int group); /*************************************************************** User use this function to read value from DI module, Slot: 0 ~ 7 Port: 0 or 1 Group: 8 ~ 15 return: DI Value 0 ~ 0xffff ****************************************************************/ //FR-2053 function unsigned int i8172_ReadDIBit(int slot,int port,int group,int bitIndex); /*************************************************************** User use this function to read single channel from DI module, slot: 0 ~ 7 port: 0 or 1 group: 8 ~ 15 bitIndex: 0 ~ 15 return: 0 or 1 ************************************************************/ // modified by martin 2010/04/22 return value void --> //int Get_DIs_Communication_Status(int slot,int port); /************************************************************** Read status of all DIs. slot: 0 ~ 7 port: 0 or 1 return 0 ~ 0xff ***************************************************************/ //FR-2053, FR-2054, FR-2017 function int i8172_ReadInputGroupStatus(int slot,int port, int group); /************************************************************** Read status of single DI port: 0 or 1 group: Group: 8 ~ 15 return 0 off line, 1 on line ***************************************************************/ //FR-2054 function void i8172_DIO_WriteDOGroup(int slot,int port, int group,unsigned int doData); /*************************************************************** User use this function to input Hex value to DO module, slot: 0 ~ 7 port: 0 or 1 group: 0 ~ 7 iData: 0 ~ 0xff ****************************************************************/ //FR-2054 function void i8172_DIO_WriteDOBit(int slot,int port,int group,int bitIndex,int bitStatus); /**************************************************************** User use this function to input single channel to DO module, slot: 0 ~ 7 port: 0 or 1 group: 0 ~ 7 bitIndex: 0~7 bitStatus: 0 off 1 on ****************************************************************/ //FR-2054 function unsigned int i8172_DIO_ReadDIGroup(int slot,int port,int group); /*************************************************************** User use this function to read value from DI module, slot: 0 ~ 7 port: 0 or 1 group: 8 ~ 15 return: DI Value 0 ~ 0xff ****************************************************************/ //FR-2054 function unsigned int i8172_DIO_ReadDIBit(int slot,int port,int group,int bitIndex); /*************************************************************** User use this function to read single channel from DI module, slot: 0 ~ 7 port: 0 or 1 group: 8 ~ 15 bitIndex: 0 ~ 7 return: 0 or 1 ************************************************************/ //FR-2017 function short i8172_ReadAIHex(int slot,int port,int group,short bitMode,short *chIndex, short* aiHex); /*************************************************************** User use this function to read channel index and analog input data get from FR-2017, slot: 0 ~ 7 port: 0 or 1 group: 8 ~ 15 bitMode: 12 means 12-bit mode, 16 means 16-bit mode. *chIndex: requested channel index get from FR-2017 *aiHex: requested hex format analog input data from FR-2017 return: if return < 0 means Read AI Hex failed else means Read AI Hex successfully. Note: For FRnet, FR-2017 update 16-bit data coutinuous every 2.8 ms, if 16-bit mode, *iChannel always be 0, and aiHex will be the only analog input data. if 12-bit mode, the data format defined as MSB LSB bit15 bit14 bit13 bit12 bit11 bit10 Bit9 Bit8 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 |<------------------------------12-bits AD data------------------------------------------->| |<----- Channel Index ---->| if 12-bit mode, we have to use i8172_ReadAIHex function to get which channel and data get from FR-2017, if use i8172_ReadAIHex to get hex data from FR-2017, we have to use i8172_AIHexToFloat with typeCode and bitMode to convert the hex data to float. ****************************************************************/ float i8172_AIHexToFloat(short hexData, short typeCode, short bitMode); /*************************************************************** User use this function to convert hex format analog input data to float format, hexData: hex format analog input data get from FR-2017 with function i8172_ReadAIHex typeCode: the input range of FR-2017 bitMode: 12 means 12-bit mode, 16 means 16-bit mode. return converted float format data. FR_2017 type code 0x1a 0 ~ 20 mA 0x7 4 ~ 20 mA 0x8 +/-10 V 0x9 +/-5 V 0xa +/-1 V 0xb +/-500 mV 0xc +/-150 mV 0xd +/-20 mA ****************************************************************/ short i8172_ReadAI_Ch(int slot,int port, int group, short bitMode,short typeCode, short chIndex, float* aiFloat); /*************************************************************** User use this function to read channel index and analog input data get from FR-2017, slot: 0 ~ 7 port: 0 or 1 group: 8 ~ 15 bitMode: 12 means 12-bit mode, 16 means 16-bit mode. typeCode: the input range of FR-2017 chIndex: requested channel index of FR-2017 *aiFloat: requested float format analog input data from FR-2017 return: the sampling time needs for i8172_ReadAI_Ch to get the iChannel index data from FR-2017. Note: for most users, it is not convenient to use i8172_ReadAIHex to get the analog input data from FR-2017 By using i8172_ReadAI_Ch, program will blocked for about 0 to 45 ms to get certain channel index data. FR_2017 type code 0x1a 0 ~ 20 mA 0x7 4 ~ 20 mA 0x8 +/-10 V 0x9 +/-5 V 0xa +/-1 V 0xb +/-500 mV 0xc +/-150 mV 0xd +/-20 mA ****************************************************************/ short i8172_ReadAI_All(int slot,int port, int group, short bitMode,short totalCh,short typeCode[], float aiFloat[]); /*************************************************************** User use this function to read all analog input data get from FR-2017, slot: 0 ~ 7 port: 0 or 1 group: 8 ~ 15 bitMode: 12 means 12-bit mode, 16 means 16-bit mode. totalCh: if 16-bit mode, totalCh =1, if 12-bit and differential mode totalCh = 8, if 12-bit and single-ended mode totalCh = 16, typeCode[]: the input range array of FR-2017 aiFloat[]: requested float format analog input data array. return: the sampling time needs for i8172_ReadAI_ALL to get the all analog input data from FR-2017. Note: for most users, it is not convenient to use i8172_ReadAIHex to get the analog input data from FR-2017 By using i8172_ReadAI_ALL, program will blocked for about 0 to 45 ms to get all channels' data. FR_2017 type code 0x1a 0 ~ 20 mA 0x7 4 ~ 20 mA 0x8 +/-10 V 0x9 +/-5 V 0xa +/-1 V 0xb +/-500 mV 0xc +/-150 mV 0xd +/-20 mA ****************************************************************/ short i8172_WriteAOHex(int slot,int port,int group,short bitMode,short chIndex, short aoHexData, short delayTime); /*************************************************************** User use this function to write analog output data by FR-2024, slot: 0 ~ 7 port: 0 or 1 group: 0 ~ 7 bitMode: 12 means 12-bit mode, at present only support 12-bit mode, reserved this parameter for future I/O with different bit mode. chIndex: channel index of FR-2024 aoHexData: analog output data. delayTime: the delay time after FR-2024 write analog output data. return: 0. Note: for some application,program may use a for loop to write analog output by using i8172_WriteAOHex, but for FRnet protocol, each command will have 3 ms delay for 250K setting and 1 ms delay for 1M setting. if there is no need to write analog output continuously, the delayTime may set as 0 ****************************************************************/ short i8172_WriteAOFloat(int slot,int port,int group,short bitMode,short chIndex, short typeCode, float aoFloat, short delayTime); /*************************************************************** User use this function to write analog output data by FR-2024, slot: 0 ~ 7 port: 0 or 1 group: 0 ~ 7 bitMode: 12 means 12-bit mode, at present only support 12-bit mode, reserved this parameter for future I/O with different bit mode. typeCode: the input range of FR-2024 chIndex: channel index of FR-2024 aoHexData: analog output data. delayTime: the delay time after FR-2024 write analog output data. return: 0. Note: for some application,program may use a for loop to write analog output by using i8172_WriteAOFloat, but for FRnet protocol, each command will have 3 ms delay for 250K setting and 1 ms delay for 1M setting. if there is no need to write analog output continuously, the delayTime may set as 0 typeCode for FR-2024 0 ~ 20mA 0x30 4 ~ 20mA 0x31 0V ~ +10V 0x32 -10V ~ +10V 0x33 0V ~ +5V 0x34 -5V ~ +5V 0x35 ****************************************************************/