- small improvements in drivers
This commit is contained in:
122
itcdriv.c
122
itcdriv.c
@ -38,6 +38,7 @@ Markus Zolliker, May 2005
|
||||
#define ITC_PROP 4
|
||||
#define ITC_INTEG 5
|
||||
#define ITC_DERIV 6
|
||||
#define ITC_MAXVOLT 7
|
||||
|
||||
typedef struct {
|
||||
EaseDriv d;
|
||||
@ -54,6 +55,13 @@ typedef struct {
|
||||
float deriv; /* deriv. time / int. for pressure [sec] */
|
||||
float prop2; /* TESLATRON only: prop. for pressure [%/mbar] */
|
||||
float lambdaTarget; /* TESLATRON only: lambda stage target temperature */
|
||||
float power;
|
||||
float resist;
|
||||
float htrVolt;
|
||||
float maxVolt;
|
||||
float maxPower;
|
||||
int cntVolt;
|
||||
int readMaxVolt;
|
||||
int pidMode;
|
||||
int sampleChan;
|
||||
int controlChan;
|
||||
@ -167,6 +175,9 @@ static void ItcParDef(void *object) {
|
||||
ParList(NULL);
|
||||
ParInt(&drv->gasMode, 1);
|
||||
|
||||
ParName("heaterMode");
|
||||
ParInt(&drv->a, 0);
|
||||
|
||||
} else {
|
||||
ParName("progress");
|
||||
ParAccess(usUser); ParEnum(progressList);
|
||||
@ -187,6 +198,8 @@ static void ItcParDef(void *object) {
|
||||
ParList("");
|
||||
}
|
||||
EaseUpdate(ITC_SETGAS); ParSave(1);
|
||||
if (drv->setGas > 99.9) drv->setGas = 99.9;
|
||||
if (drv->setGas < 0) drv->setGas = 0;
|
||||
ParFloat(&drv->setGas, 20.0);
|
||||
|
||||
ParName("travelTime"); ParFmt("%.0f"); ParTail("sec");
|
||||
@ -219,7 +232,39 @@ static void ItcParDef(void *object) {
|
||||
if (drv->pidMode == 1) ParList("");
|
||||
EaseUpdate(ITC_DERIV);
|
||||
ParFloat(&drv->deriv, PAR_NAN);
|
||||
|
||||
ParName("maxPower");
|
||||
ParFmt("%.4g"); ParTail("W");
|
||||
EaseUpdate(ITC_MAXVOLT);
|
||||
ParFloat(&drv->maxPower, PAR_NAN);
|
||||
if (ParActionIs(PAR_SET) > 0) {
|
||||
if (drv->maxPower < 0) {
|
||||
drv->readMaxVolt = 1;
|
||||
drv->maxPower = PAR_NAN;
|
||||
drv->maxVolt = PAR_NAN;
|
||||
} else {
|
||||
drv->readMaxVolt = 0;
|
||||
if (drv->resist < 0) {
|
||||
drv->resist = 0;
|
||||
}
|
||||
drv->maxVolt = sqrt(drv->maxPower * drv->resist);
|
||||
if (drv->maxVolt > 47.9) {
|
||||
drv->maxVolt = 47.9;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ParName("resist");
|
||||
ParFmt("%g"); ParAccess(usUser);
|
||||
ParTail("Ohm"); ParList("");
|
||||
ParFloat(&drv->resist, 80.0);
|
||||
|
||||
ParName("power");
|
||||
ParFmt("%g"); ParTail("W");
|
||||
ParFloat(&drv->power, PAR_NAN);
|
||||
|
||||
} else {
|
||||
|
||||
ParName("lambdaTarget"); ParFmt("%.2f"); ParTail("K");
|
||||
if (drv->gasMode == 0) ParList("");
|
||||
ParAccess(usUser); ParSave(1);
|
||||
@ -348,7 +393,7 @@ static long ItcRead(long pc, void *object) {
|
||||
int l;
|
||||
time_t now, delta;
|
||||
char buf[4];
|
||||
float gas, band;
|
||||
float gas, band, v1, v2, h;
|
||||
|
||||
switch (pc) { default: /* FSM BEGIN *******************************/
|
||||
EaseWrite(eab, "X");
|
||||
@ -384,7 +429,8 @@ static long ItcRead(long pc, void *object) {
|
||||
if (drv->t[drv->controlChan] > drv->autoGasLimit + 1.0) {
|
||||
if (drv->a < 2) {
|
||||
drv->a |= 2; /* switch gas to auto */
|
||||
ParPrintf(drv, eWarning, "switch to auto needle valve");
|
||||
ParPrintf(drv, eWarning,
|
||||
"needle valve switched to ITC control (AutoGas)");
|
||||
} else {
|
||||
goto skip0;
|
||||
}
|
||||
@ -392,8 +438,8 @@ static long ItcRead(long pc, void *object) {
|
||||
if (drv->a >= 2) {
|
||||
if (drv->t[drv->controlChan] < drv->autoGasLimit) {
|
||||
drv->a &= 1; /* switch gas to manual */
|
||||
ParPrintf(drv, eWarning, "switch to manual needle valve (%f %%)",
|
||||
drv->setGas);
|
||||
ParPrintf(drv, eWarning,
|
||||
"needle valve switched to software control");
|
||||
} else {
|
||||
goto skip0;
|
||||
}
|
||||
@ -494,13 +540,57 @@ static long ItcRead(long pc, void *object) {
|
||||
|
||||
if (eab->syntax == TESLATRON) goto skipctrl;
|
||||
|
||||
if (EaseGetUpdate(drv, ITC_SETHTR)) goto skiphtr;
|
||||
EaseWrite(eab, "R5"); /* read heater */
|
||||
if (EaseGetUpdate(drv, ITC_MAXVOLT)) goto skiphtr;
|
||||
EaseWrite(eab, "R5"); /* read heater percent */
|
||||
return __LINE__; case __LINE__: /**********************************/
|
||||
if (EaseGetUpdate(drv, ITC_SETHTR)) goto skiphtr;
|
||||
if (EaseGetUpdate(drv, ITC_MAXVOLT)) goto skiphtr;
|
||||
drv->htr = OxiGet(eab, 1, NULL, drv->htr);
|
||||
skiphtr:
|
||||
|
||||
|
||||
if (drv->readMaxVolt == 0) {
|
||||
drv->htrVolt = drv->htr * 0.01 * drv->maxVolt;
|
||||
goto skiphtr;
|
||||
}
|
||||
EaseWrite(eab, "R6"); /* read heater voltage */
|
||||
return __LINE__; case __LINE__: /**********************************/
|
||||
drv->htrVolt = OxiGet(eab, 1, NULL, drv->htrVolt);
|
||||
|
||||
if (drv->readMaxVolt) {
|
||||
h = drv->htr;
|
||||
if (h > 1.0) {
|
||||
v1 = 0.1 * (int)(drv->htrVolt * 1000 / (h + 0.099) - 0.5);
|
||||
v2 = 0.1 * (int)(drv->htrVolt * 1000 / (h - 0.05) + 0.99);
|
||||
if (drv->maxVolt > v2) {
|
||||
drv->cntVolt++;
|
||||
if (drv->cntVolt > drv->readMaxVolt) {
|
||||
drv->maxVolt = v2;
|
||||
drv->cntVolt = 0;
|
||||
drv->readMaxVolt++;
|
||||
}
|
||||
} else if (drv->maxVolt < v1) {
|
||||
drv->cntVolt--;
|
||||
if (drv->cntVolt < -drv->readMaxVolt) {
|
||||
drv->maxVolt = v1;
|
||||
drv->cntVolt = 0;
|
||||
drv->readMaxVolt++;
|
||||
}
|
||||
} else {
|
||||
drv->cntVolt = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (drv->maxVolt != PAR_NAN) {
|
||||
drv->htrVolt = h * 0.01 * drv->maxVolt;
|
||||
}
|
||||
|
||||
skiphtr:
|
||||
if (drv->resist <= 1) drv->resist = 80.0;
|
||||
if (drv->maxVolt != PAR_NAN) {
|
||||
drv->maxPower = drv->maxVolt * drv->maxVolt / drv->resist;
|
||||
}
|
||||
if (drv->htrVolt != PAR_NAN) {
|
||||
drv->power = drv->htrVolt * drv->htrVolt / drv->resist;
|
||||
}
|
||||
|
||||
if (EaseGetUpdate(drv, ITC_PROP)) goto skipprop;
|
||||
EaseWrite(eab, "R8"); /* read prop */
|
||||
return __LINE__; case __LINE__: /**********************************/
|
||||
@ -556,11 +646,12 @@ static long ItcStart(long pc, void *object) {
|
||||
}
|
||||
}
|
||||
ParPrintf(drv, eStatus, "connected to %s", eab->version);
|
||||
FsmCall(ItcRead);
|
||||
return __LINE__; case __LINE__: /**********************************/
|
||||
if (drv->controlChan == 0 && drv->h >= 1 && drv->h <= 3) {
|
||||
drv->controlChan = drv->h;
|
||||
}
|
||||
FsmCall(ItcRead);
|
||||
return __LINE__; case __LINE__: /**********************************/
|
||||
drv->d.targetValue = drv->t[0];
|
||||
|
||||
quit:
|
||||
return 0; } /* FSM END ********************************************/
|
||||
@ -642,7 +733,9 @@ static long ItcSetGas(long pc, void *object) {
|
||||
return __LINE__; case __LINE__: /**********************************/
|
||||
EaseWrite(eab, "R7"); /* read gas flow */
|
||||
return __LINE__; case __LINE__: /**********************************/
|
||||
drv->setGas = OxiGet(eab, 1, NULL, drv->setGas);
|
||||
if (! EaseGetUpdate(drv, ITC_SETGAS)) {
|
||||
drv->setGas = OxiGet(eab, 1, NULL, drv->setGas);
|
||||
}
|
||||
if (drv->a < 2) goto quit;
|
||||
snprintf(buf, sizeof buf, "A%d", drv->a);
|
||||
EaseWrite(eab, buf);
|
||||
@ -698,6 +791,7 @@ static long ItcSet(long pc, void *object) {
|
||||
case ITC_PROP: OxiSet(eab, "P", drv->prop, 1); goto loop;
|
||||
case ITC_INTEG: OxiSet(eab, "I", drv->integ, 1); goto loop;
|
||||
case ITC_DERIV: OxiSet(eab, "D", drv->deriv, 1); goto loop;
|
||||
case ITC_MAXVOLT:OxiSet(eab, "M", drv->maxVolt, 1); goto loop;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
@ -721,6 +815,10 @@ static int ItcInit(SConnection *con, int argc, char *argv[], int dynamic) {
|
||||
ItcSet);
|
||||
if (drv == NULL) return 0;
|
||||
drv->d.b.syntax = 0;
|
||||
drv->cntVolt = 0;
|
||||
drv->maxVolt = PAR_NAN;
|
||||
drv->htrVolt = PAR_NAN;
|
||||
drv->readMaxVolt = 1;
|
||||
return 1;
|
||||
}
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
Reference in New Issue
Block a user