- added LakeShore 370 driver
- improvements in ease and ips driver
This commit is contained in:
2
ease.c
2
ease.c
@ -627,7 +627,7 @@ static int EaseInit(SConnection *pCon, EaseBase *eab, int argc, char *argv[],
|
|||||||
|
|
||||||
setRS232ReplyTerminator(eab->ser,"\r");
|
setRS232ReplyTerminator(eab->ser,"\r");
|
||||||
setRS232SendTerminator(eab->ser,"\r");
|
setRS232SendTerminator(eab->ser,"\r");
|
||||||
setRS232Timeout(eab->ser,10000); /* milliseconds */
|
setRS232Timeout(eab->ser,5000); /* milliseconds */
|
||||||
setRS232Debug(eab->ser,0);
|
setRS232Debug(eab->ser,0);
|
||||||
|
|
||||||
eab->task = NULL;
|
eab->task = NULL;
|
||||||
|
@ -497,6 +497,7 @@ static int IpsInit(SConnection *con, int argc, char *argv[], int dynamic) {
|
|||||||
IpsChangeField);
|
IpsChangeField);
|
||||||
if (drv == NULL) return 0;
|
if (drv == NULL) return 0;
|
||||||
drv->d.maxwait = 999999;
|
drv->d.maxwait = 999999;
|
||||||
|
drv->d.tolerance = 0.001;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
132
lsc370driv.c
Normal file
132
lsc370driv.c
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
/*---------------------------------------------------------------------------
|
||||||
|
lsc370driv.c
|
||||||
|
|
||||||
|
Driver for the LakeShore Model 370 AC Resistance Bridge
|
||||||
|
|
||||||
|
Markus Zolliker, July 2006
|
||||||
|
----------------------------------------------------------------------------*/
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <tcl.h>
|
||||||
|
#include <fortify.h>
|
||||||
|
#include <sics.h>
|
||||||
|
#include <splitter.h>
|
||||||
|
#include <obpar.h>
|
||||||
|
#include <devexec.h>
|
||||||
|
#include <nserver.h>
|
||||||
|
#include <interrupt.h>
|
||||||
|
#include <emon.h>
|
||||||
|
#include <evcontroller.h>
|
||||||
|
#include <evcontroller.i>
|
||||||
|
#include <servlog.h>
|
||||||
|
#include <sicsvar.h>
|
||||||
|
#include <evdriver.i>
|
||||||
|
#include <rs232controller.h>
|
||||||
|
#include "lscsupport.h"
|
||||||
|
#include "fsm.h"
|
||||||
|
#include "initializer.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
EaseDriv d;
|
||||||
|
float t;
|
||||||
|
float htr;
|
||||||
|
} Lsc370;
|
||||||
|
|
||||||
|
static ParClass lsc370Class = { "LSC370", sizeof(Lsc370) };
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
static void Lsc370ParDef(void *object) {
|
||||||
|
Lsc370 *drv = ParCast(&lsc370Class, object);
|
||||||
|
EaseBase *eab = object;
|
||||||
|
|
||||||
|
ParName(""); ParTail("K");
|
||||||
|
ParFloat(&drv->t, PAR_NAN);
|
||||||
|
|
||||||
|
EaseBasePar(drv);
|
||||||
|
EaseSendPar(drv);
|
||||||
|
EaseDrivPar(drv, "%.5g", "K");
|
||||||
|
ParStdDef();
|
||||||
|
EaseMsgPar(drv);
|
||||||
|
}
|
||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
static long Lsc370Read(long pc, void *object) {
|
||||||
|
Lsc370 *drv = ParCast(&lsc370Class, object);
|
||||||
|
EaseBase *eab = object;
|
||||||
|
|
||||||
|
switch (pc) { default: /* FSM BEGIN *******************************/
|
||||||
|
EaseWrite(eab, "RDGK?1");
|
||||||
|
return __LINE__; case __LINE__: /**********************************/
|
||||||
|
drv->t = atof(eab->ans);
|
||||||
|
EaseWrite(eab, "HTR?");
|
||||||
|
return __LINE__; case __LINE__: /**********************************/
|
||||||
|
drv->htr = atof(eab->ans);
|
||||||
|
|
||||||
|
ParLog(drv);
|
||||||
|
fsm_quit: return 0; } /* FSM END *********************************/
|
||||||
|
}
|
||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
static long Lsc370Start(long pc, void *object) {
|
||||||
|
Lsc370 *drv = ParCast(&lsc370Class, object);
|
||||||
|
EaseBase *eab = object;
|
||||||
|
|
||||||
|
switch (pc) { default: /* FSM BEGIN *******************************/
|
||||||
|
EaseWrite(eab, "*IDN?");
|
||||||
|
return __LINE__; case __LINE__: /**********************************/
|
||||||
|
if (0 != strncmp(eab->version, "LSCI,MODEL370", 13)) {
|
||||||
|
snprintf(eab->msg, sizeof eab->msg, "unknown temperature controller version: %s",
|
||||||
|
eab->version);
|
||||||
|
ParPrintf(drv, eError, "ERROR: %s", eab->msg);
|
||||||
|
EaseStop(eab);
|
||||||
|
goto quit;
|
||||||
|
}
|
||||||
|
ParPrintf(drv, eStatus, "connected to %s", eab->version);
|
||||||
|
FsmCall(Lsc370Read);
|
||||||
|
return __LINE__; case __LINE__: /**********************************/
|
||||||
|
|
||||||
|
quit:
|
||||||
|
return 0; } /* FSM END ********************************************/
|
||||||
|
}
|
||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
static long Lsc370Set(long pc, void *object) {
|
||||||
|
Lsc370 *drv = ParCast(&lsc370Class, object);
|
||||||
|
EaseBase *eab = object;
|
||||||
|
char cmd[32];
|
||||||
|
int upd;
|
||||||
|
|
||||||
|
switch (pc) { default: /* FSM BEGIN *******************************/
|
||||||
|
upd = EaseNextUpdate(drv);
|
||||||
|
if (upd != EASE_RUN) goto quit;
|
||||||
|
EaseWrite(eab, "MODE 1:MODE?"); /* remote mode */
|
||||||
|
return __LINE__; case __LINE__: /**********************************/
|
||||||
|
snprintf(cmd, sizeof cmd, "SETP %.5g:SETP?", drv->d.targetValue);
|
||||||
|
EaseWrite(eab, cmd);
|
||||||
|
return __LINE__; case __LINE__: /**********************************/
|
||||||
|
EaseWrite(eab, "MODE 0:MODE?"); /* local mode */
|
||||||
|
quit:
|
||||||
|
return 0; } /* FSM END ********************************************/
|
||||||
|
}
|
||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
static int Lsc370Init(SConnection *con, int argc, char *argv[], int dynamic) {
|
||||||
|
/* args:
|
||||||
|
MakeObject objectname lsc370 <rs232>
|
||||||
|
MakeObject objectname lsc370 <host> <port>
|
||||||
|
*/
|
||||||
|
Lsc370 *drv;
|
||||||
|
|
||||||
|
drv = EaseMakeDriv(con, &lsc370Class, argc, argv, dynamic, 7,
|
||||||
|
Lsc370ParDef, LscHandler, Lsc370Start, NULL, Lsc370Read,
|
||||||
|
Lsc370Set);
|
||||||
|
if (drv == NULL) return 0;
|
||||||
|
setRS232ReplyTerminator(drv->d.b.ser,"\n");
|
||||||
|
setRS232SendTerminator(drv->d.b.ser,"\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
void Lsc370Startup(void) {
|
||||||
|
ParMakeClass(&lsc370Class, EaseDrivClass());
|
||||||
|
MakeDriver("LSC370", Lsc370Init, 0, "LakeShore 370 AC Resistance Bridge");
|
||||||
|
}
|
82
lscsupport.c
Normal file
82
lscsupport.c
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
/*---------------------------------------------------------------------------
|
||||||
|
lscsupport.c
|
||||||
|
|
||||||
|
Communication routines for LakeShore equipment
|
||||||
|
|
||||||
|
Markus Zolliker, July 2006
|
||||||
|
----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
there is no error return value, eab->errCode is used. On success, eab->errCode
|
||||||
|
is not changed, i.e. an existing errCode is not overwritten.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <fortify.h>
|
||||||
|
#include "sics.h"
|
||||||
|
#include "oxinst.h"
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
int LscHandler(void *object) {
|
||||||
|
int iret, l;
|
||||||
|
EaseBase *eab = EaseBaseCast(object);
|
||||||
|
char *corr;
|
||||||
|
|
||||||
|
if (eab->state < EASE_idle) goto quit;
|
||||||
|
if (availableNetRS232(eab->ser) || availableRS232(eab->ser)) {
|
||||||
|
eab->msg[0] = '\0';
|
||||||
|
l = sizeof(eab->ans);
|
||||||
|
iret = readRS232TillTerm(eab->ser, eab->ans, &l);
|
||||||
|
if (eab->state != EASE_expect && eab->state != EASE_lost) {
|
||||||
|
if (iret == 1) {
|
||||||
|
ParPrintf(eab, eError, "unexpected answer: %s", eab->ans);
|
||||||
|
}
|
||||||
|
goto quit;
|
||||||
|
}
|
||||||
|
if (iret == 1) {
|
||||||
|
ParPrintf(eab, -2, "ans: %s", eab->ans);
|
||||||
|
if (strncmp(eab->ans, "0,123",5) == 0 && eab->state == EASE_lost) { /* response to LOCK? */
|
||||||
|
EaseWrite(eab, "*IDN?");
|
||||||
|
goto quit;
|
||||||
|
} else if (eab->state == EASE_lost) {
|
||||||
|
goto quit;
|
||||||
|
} else if (strncmp(eab->cmd,"*IDN?",5) == 0) {
|
||||||
|
if (strcmp(eab->ans, eab->version) == 0) {
|
||||||
|
/* we are still connected with the same device */
|
||||||
|
} else if (*eab->version == '\0') {
|
||||||
|
strncat(eab->version, eab->ans, sizeof(eab->version)-1);
|
||||||
|
} else { /* version (and therefore device) changed */
|
||||||
|
eab->errCode = EASE_DEV_CHANGED;
|
||||||
|
eab->state = EASE_idle;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
eab->state = EASE_idle;
|
||||||
|
goto quit;
|
||||||
|
} else {
|
||||||
|
eab->tmo = 120;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (iret != 1) {
|
||||||
|
eab->errCode = iret;
|
||||||
|
eab->state = EASE_idle;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
eab->state = EASE_read;
|
||||||
|
} else if (eab->state == EASE_expect) {
|
||||||
|
if (time(NULL) > eab->cmdtime + eab->tmo) {
|
||||||
|
eab->state = EASE_lost;
|
||||||
|
}
|
||||||
|
} else if (eab->state == EASE_lost) {
|
||||||
|
if (time(NULL) > eab->cmdtime) {
|
||||||
|
EaseWrite(eab, "LOCK?");
|
||||||
|
eab->state = EASE_lost;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
goto quit;
|
||||||
|
error:
|
||||||
|
/* EaseWriteError(eab); */
|
||||||
|
quit:
|
||||||
|
return EaseHandler(eab);
|
||||||
|
}
|
16
lscsupport.h
Normal file
16
lscsupport.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/*---------------------------------------------------------------------------
|
||||||
|
lscsupport.h
|
||||||
|
|
||||||
|
Communication routines for LakeShore equipment
|
||||||
|
|
||||||
|
Markus Zolliker, July 2006
|
||||||
|
----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef LSCSUPPORT_H
|
||||||
|
#define LSCSUPPORT_H
|
||||||
|
|
||||||
|
#include "ease.h"
|
||||||
|
|
||||||
|
int LscHandler(void *eab);
|
||||||
|
|
||||||
|
#endif
|
Reference in New Issue
Block a user