/*--------------------------------------------------------------------------- L A K E S H O R E 3 4 0 U T I L A few utility functions for talking to a Lakeshore 340 temperature controller via the SINQ setup: TCP/IP--MAC--RS-232-- LAKESHORE340. Mark Koennecke, Juli 1997 Mark Lesha, January 2006 (based on ITC4 code) ----------------------------------------------------------------------------*/ #ifndef SINQLAKESHORE340 #define SINQLAKESHORE340 /*----------------------- ERRORCODES-------------------------------------- Most functions return a negative error code on failure. Error codes defined are those defined for serialsinq plus a few additional ones: */ #define LAKESHORE340__BADCOM -501 /* command not recognized */ #define LAKESHORE340__BADPAR -502 /* bad parameter to command */ #define LAKESHORE340__BADMALLOC -503 /* error allocating memory */ #define LAKESHORE340__BADREAD -504 /* error analysing command string on Read */ #define LAKESHORE340__FAULT -505 /* fault or overload condition exists in LAKESHORE340 */ #define LAKESHORE340__NOLAKESHORE340 -510 /* Controller is not LAKESHORE340 */ #define LAKESHORE340__BADSET -530 /* failed three times to set temperature */ #define LAKESHORE340__READONLY -531 /*------------------------------------------------------------------------*/ typedef struct __LAKESHORE340 { int iRead; int iControl; void *pData; char pAns[80]; /* should be enough for LAKESHORE340 errors */ /* The LAKESHORE340 does not need multipliers or dividers but leave them in anyway for back compatibility or future use but force the value to 1.0 all the time */ float fDiv; float fMult; int iReadOnly; prs232 controller; } LAKESHORE340; typedef struct __LAKESHORE340 *pLAKESHORE340; /*-----------------------------------------------------------------------*/ int LAKESHORE340_Open(pLAKESHORE340 *pData,char *pHost, int iPort, int iChannel, int iMode); /***** creates an LAKESHORE340 datastructure and opens a connection to the LAKESHORE340 controller. Input Parameters are: the hostname the port number the RS-232 channel number on the Mac. iMode: 1 for ReadOnly, 0 for normal mode Return values are 1 for success, a negative error code on failure. */ void LAKESHORE340_Close(pLAKESHORE340 *pData); /****** close a connection to an LAKESHORE340controller and frees its data structure. The only parameter is a pointer to the data structure for this controller. This pointer will be invalid after this call. */ int LAKESHORE340_Config(pLAKESHORE340 *pData, int iTmo, int iRead, int iControl, float fDiv, float fMult); /***** configure some aspects of a LAKESHORE340temperature controller. The parameter are: - a pointer to the data structure for the controller as returned by LAKESHORE340_Open - a value for the connection timeout - the temperature sensor to use for reading the temperature. - the temperature sensor used by the LAKESHORE340controller for regulating the temperature. - the divisor needed to calculate the real temperature from the sensor. The function returns 1 on success, a negative error code on failure. */ int LAKESHORE340_Send(pLAKESHORE340 *pData, char *pCommand, char *pReply, int iLen); /******* send a the command in pCommand to the LAKESHORE340controller. A possible reply is returned in the buffer pReply. Maximum iLen characters are copied to pReply. The first parameter is a pointer to a LAKESHORE340data structure as returned by LAKESHORE340_Open. Return values are 1 for success, a negative error code on failure. */ int LAKESHORE340_Read(pLAKESHORE340 *pData, float *fVal); /******* reads the current actual temperature of the sensor configured by ConfigLAKESHORE340for reading. The value is returned in fVal. The first parameter is a pointer to a LAKESHORE340 data structure as returned by LAKESHORE340_Open. Return values are 1 for success, a negative error code on failure. */ int LAKESHORE340_Set(pLAKESHORE340 *pData, float fVal); /****** sets a new preset temperature in the LAKESHORE340temperature controller. Parameters are: - a pointer to a LAKESHORE340data structure as returned by LAKESHORE340_Open. - the new preset value. Return values are 1 for success, a negative error code on failure.pEVInterface */ void LAKESHORE340_ErrorTxt(pLAKESHORE340 *pData, int iCode, char *pError, int iLen); /******* translates one of the negative error LAKESHORE340error codes into text. Maximum iLen bytes will be copied to the buffer pError; */ #endif