- last version?
This commit is contained in:
94
tecs/tecs.c
94
tecs/tecs.c
@ -141,6 +141,8 @@ static float
|
||||
linearPower=0, /* normally 0. Maximum power when loop=2 and the power linear to the output */
|
||||
shiftUp, shiftLow, /* upper and lower limit of tShift correction */
|
||||
maxpower2=1.0,
|
||||
stickhtron=5.0, /* switch stick heater on when sample is more than this value below main */
|
||||
stickhtroff=0.0, /* switch stick heater off when sample is less than this value below main */
|
||||
state,
|
||||
mout;
|
||||
|
||||
@ -184,7 +186,9 @@ static int
|
||||
unit=1, /* 1: Kelvin, 2: Celsius */
|
||||
autoconfig=0, /* automatic configuration 1: inside tecs, 0: done by SEA */
|
||||
lockAlarm,
|
||||
stickhtr=-1,
|
||||
stickhtr=-1, /* -1, no stick heater, 1: use stick heater in parallel */
|
||||
parallelhtr=0, /* is parallel heater active ? */
|
||||
ramping=0, /* setpoint is ramping */
|
||||
cntError;
|
||||
|
||||
static int tim, rdTim; /* actual time, read Time */
|
||||
@ -530,6 +534,7 @@ int InstalCurve(SensorT *sensor, char *devArg) {
|
||||
ERR_SI(fputs(e, fil));
|
||||
}
|
||||
ERR_SI(fputc('\0', fil));
|
||||
ERR_SI(fputc('\n', fil));
|
||||
ERR_SI(fclose(fil));
|
||||
str_copy(buf, logDir);
|
||||
sprintf(lbuf, "lsc.%d", serialNo);
|
||||
@ -995,7 +1000,9 @@ int ReadTemp(void) {
|
||||
}
|
||||
if (doit) {
|
||||
if (ramp!=0) {
|
||||
str_append(buf, ";SETP?[loop]>fbuf");
|
||||
str_append(buf, ";SETP?[loop]>fbuf;RAMPST?[loop]>ramping");
|
||||
} else {
|
||||
ramping = 0;
|
||||
}
|
||||
str_append(buf, ";MNMXRST");
|
||||
ERR_P(LscCmd(ser, buf));
|
||||
@ -1257,7 +1264,7 @@ int SetTemp(int switchOn) {
|
||||
ERR_P(LscCmd(ser, "CSET 1:[chan],[unit],0,0"));
|
||||
}
|
||||
if (ramp > 0 && set != 0) {
|
||||
/* take ramp from actual temperature if more than 10 % deviation */
|
||||
/* start ramp from actual temperature */
|
||||
ERR_P(LscCmd(ser, "CSET?[loop]>,,cod1;SETP?[loop]>fbuf"));
|
||||
if (loop == 1 && cod1 != 0) {
|
||||
ERR_P(LscCmd(ser, "RANGE?>cod1"));
|
||||
@ -2164,8 +2171,15 @@ int PeriodicTask(void) {
|
||||
if (stickhtr < 0) {
|
||||
ERR_P(LscCmd(ser, "DIOST?>cod1,out1;DOUT 3,29;BUSY?>busy"));
|
||||
} else {
|
||||
cod1=0;
|
||||
ERR_P(LscCmd(ser, "DOUT 3,0;BUSY?>busy"));
|
||||
if (parallelhtr) {
|
||||
out1 = 2;
|
||||
} else {
|
||||
out1 = 0;
|
||||
}
|
||||
if (stickhtr > 1) {
|
||||
out1 |= stickhtr;
|
||||
}
|
||||
ERR_P(LscCmd(ser, "DOUT 3,[out1];BUSY?>busy"));
|
||||
}
|
||||
if ((plug0.codDefined && plug1.codDefined)) {
|
||||
per=period; /* no timeout on above command and codes are defined: normal period */
|
||||
@ -2227,19 +2241,29 @@ int PeriodicTask(void) {
|
||||
str_copy(plug0.device, buf1+1);
|
||||
plug0.codChanged=0;
|
||||
ConfigByName(0);
|
||||
if (autoconfig == 0) ConfigByCode(0);
|
||||
if (autoconfig == 0) {
|
||||
str_copy(devname0, plug0.device);
|
||||
}
|
||||
} else {
|
||||
if (plug0.code!=0) str_copy(plug0.device, buf1);
|
||||
plug0.devcmd=0;
|
||||
if (autoconfig == 0) {
|
||||
ConfigByName(0);
|
||||
str_copy(devname0, plug0.device);
|
||||
}
|
||||
}
|
||||
if (buf2[0]=='*') {
|
||||
str_copy(plug1.device, buf2+1);
|
||||
plug1.codChanged=0;
|
||||
ConfigByName(1);
|
||||
if (autoconfig == 0) ConfigByCode(1);
|
||||
/* if (autoconfig == 0) ConfigByCode(1); */
|
||||
} else {
|
||||
if (plug1.code!=0) str_copy(plug1.device, buf2);
|
||||
plug1.devcmd=0;
|
||||
if (autoconfig == 0) {
|
||||
ConfigByName(1);
|
||||
str_copy(devname1, plug1.device);
|
||||
}
|
||||
}
|
||||
ConcatDevice();
|
||||
|
||||
@ -2417,34 +2441,36 @@ int PeriodicTask(void) {
|
||||
float f = fabsf((oldSet - set)/ (oldSet + set));
|
||||
oldShift *= exp(-f*f*25);
|
||||
tShift = oldShift;
|
||||
statCrop(&mStat, sStat.lower+tShift, sStat.upper+tShift);
|
||||
statCrop(&mStat, sStat.lower+tShift, sStat.upper+tShift);
|
||||
state = 1;
|
||||
} else {
|
||||
state = 0;
|
||||
}
|
||||
} else {
|
||||
state = 0;
|
||||
}
|
||||
finTime = rdTim + int2 + 30;
|
||||
slopeS.mx = -1;
|
||||
slopeU.mx = -1;
|
||||
slopeL.mx = -1;
|
||||
slopeS.mx = -1;
|
||||
slopeU.mx = -1;
|
||||
slopeL.mx = -1;
|
||||
}
|
||||
if (rdTim < finTime) {
|
||||
if (ramping) {
|
||||
/* do not change tShift when ramping */
|
||||
} else if (rdTim < finTime) {
|
||||
if (slopeS.wasmax) {
|
||||
finTime = rdTim + int2 + 30;
|
||||
}
|
||||
if (fabs(slopeS.slope) > slopeS.mx * 0.2
|
||||
&& finTime < rdTim + per * 0.0035) {
|
||||
finTime = rdTim + per * 0.0035;
|
||||
}
|
||||
if (d > 0) {
|
||||
tShift = oldShift + propUp * d;
|
||||
} else {
|
||||
tShift = oldShift + propDown * d;
|
||||
}
|
||||
finTime = rdTim + int2 + 30;
|
||||
}
|
||||
if (fabs(slopeS.slope) > slopeS.mx * 0.2
|
||||
&& finTime < rdTim + per * 0.0035) {
|
||||
finTime = rdTim + per * 0.0035;
|
||||
}
|
||||
if (d > 0) {
|
||||
tShift = oldShift + propUp * d;
|
||||
} else {
|
||||
tShift = oldShift + propDown * d;
|
||||
}
|
||||
} else {
|
||||
if (state != 2) {
|
||||
/* tShift = oldShift; */
|
||||
state = 2;
|
||||
statCrop(&mStat, sStat.lower+tShift, sStat.upper+tShift);
|
||||
statCrop(&mStat, sStat.lower+tShift, sStat.upper+tShift);
|
||||
} else {
|
||||
if (shiftLow > tShift) {
|
||||
tShift = shiftLow;
|
||||
@ -2474,6 +2500,16 @@ int PeriodicTask(void) {
|
||||
ERR_P(LscCmd(ser, "KEYST?>key;DIOST?>cod2,out2;DOUT 3,30"));
|
||||
} else {
|
||||
ERR_P(LscCmd(ser, "KEYST?>key"));
|
||||
if (stickhtr == 1) {
|
||||
d = set - samp.temp;
|
||||
if (parallelhtr) {
|
||||
if (d < stickhtroff) {
|
||||
parallelhtr = 0;
|
||||
}
|
||||
} else if (d > stickhtron) {
|
||||
parallelhtr=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (busy==0) {
|
||||
if (stickhtr < 0) {
|
||||
@ -3413,6 +3449,7 @@ int main(int argc, char *argv[]) {
|
||||
CocDefInt(tim0, RD);
|
||||
CocDefInt(ibuf, RD);
|
||||
CocDefInt(autoconfig, RW);
|
||||
CocDefInt(ramping, RD);
|
||||
|
||||
CocDefInt(logMask, RW);
|
||||
CocDefInt(logPeriod, RW);
|
||||
@ -3422,6 +3459,9 @@ int main(int argc, char *argv[]) {
|
||||
CocDefInt(serialNo, RD);
|
||||
CocDefInt(quit, RW);
|
||||
CocDefInt(stickhtr, RW);
|
||||
CocDefInt(parallelhtr, RW);
|
||||
CocDefFlt(stickhtron, RW);
|
||||
CocDefFlt(stickhtroff, RW);
|
||||
CocDefInt(keepT, RW);
|
||||
CocDefInt(swRangeOn, RW);
|
||||
CocDefInt(doubleControl, RW);
|
||||
|
Reference in New Issue
Block a user