- changed OxiGet
- various bug fixes and improvements
This commit is contained in:
84
itcdriv.c
84
itcdriv.c
@ -34,6 +34,10 @@ Markus Zolliker, May 2005
|
||||
#define TESLATRON -1
|
||||
#define ITC_SETHTR 1
|
||||
#define ITC_SETGAS 2
|
||||
#define ITC_PIDMODE 3
|
||||
#define ITC_PROP 4
|
||||
#define ITC_INTEG 5
|
||||
#define ITC_DERIV 6
|
||||
|
||||
typedef struct {
|
||||
EaseDriv d;
|
||||
@ -43,6 +47,8 @@ typedef struct {
|
||||
float gas;
|
||||
float autoGasLimit;
|
||||
float setGas;
|
||||
float prop, integ, deriv;
|
||||
int pidMode;
|
||||
int sampleChan;
|
||||
int controlChan;
|
||||
int gasMode;
|
||||
@ -63,6 +69,7 @@ static void ItcParDef(void *object) {
|
||||
int i;
|
||||
static char *ti[4] = {"setp","t1","t2","t3"};
|
||||
static char *modeList[]={"off", "manual", "auto", NULL };
|
||||
static char *pidList[]={"default", "manual", "auto", NULL };
|
||||
|
||||
ParName("sampleChan");
|
||||
if (eab->syntax != TESLATRON) ParAccess(usUser);
|
||||
@ -166,10 +173,28 @@ static void ItcParDef(void *object) {
|
||||
if (eab->syntax != TESLATRON) {
|
||||
ParName("autoGasLimit");
|
||||
ParAccess(usUser); ParFmt("%.1f"); ParTail("K"); ParSave(1);
|
||||
if (drv->gasMode != 2) {
|
||||
ParList("");
|
||||
}
|
||||
if (drv->gasMode != 2) ParList("");
|
||||
ParFloat(&drv->autoGasLimit, 3.0);
|
||||
|
||||
ParName("pidMode");
|
||||
ParEnum(pidList);
|
||||
EaseUpdate(ITC_PIDMODE); ParSave(1);
|
||||
ParInt(&drv->pidMode, 0);
|
||||
|
||||
ParName("prop"); ParFmt("%.3f"); ParTail("K");
|
||||
if (drv->pidMode == 1) ParList("");
|
||||
EaseUpdate(ITC_PROP);
|
||||
ParFloat(&drv->prop, PAR_NAN);
|
||||
|
||||
ParName("int"); ParFmt("%.1f"); ParTail("min");
|
||||
if (drv->pidMode == 1) ParList("");
|
||||
EaseUpdate(ITC_INTEG);
|
||||
ParFloat(&drv->integ, PAR_NAN);
|
||||
|
||||
ParName("deriv"); ParFmt("%.2f"); ParTail("min");
|
||||
if (drv->pidMode == 1) ParList("");
|
||||
EaseUpdate(ITC_DERIV);
|
||||
ParFloat(&drv->deriv, PAR_NAN);
|
||||
}
|
||||
|
||||
if (drv->controlChan == 0) {
|
||||
@ -210,6 +235,9 @@ void ItcStatus(Itc *drv) {
|
||||
drv->a = ans[3] - '0';
|
||||
if (ans[9] == 'H') {
|
||||
drv->h = ans[10] - '0';
|
||||
if (ans[11] == 'L' && drv->pidMode != 0 && ! EaseGetUpdate(drv, ITC_PIDMODE)) {
|
||||
drv->pidMode == ans[12] - '0' + 1;
|
||||
}
|
||||
} else {
|
||||
drv->h = drv->controlChan;
|
||||
}
|
||||
@ -236,19 +264,19 @@ static long ItcRead(long pc, void *object) {
|
||||
if (drv->dig[1] < 0) goto skip1;
|
||||
EaseWrite(eab, "R1"); /* read sensor 1 */
|
||||
return __LINE__; case __LINE__: /**********************************/
|
||||
drv->t[1] = OxiGet(eab, drv->dig[1], &drv->dig[1]);
|
||||
drv->t[1] = OxiGet(eab, drv->dig[1], &drv->dig[1], drv->t[1]);
|
||||
|
||||
skip1:
|
||||
if (drv->dig[2] < 0) goto skip2;
|
||||
EaseWrite(eab, "R2"); /* read sensor 2 */
|
||||
return __LINE__; case __LINE__: /**********************************/
|
||||
drv->t[2] = OxiGet(eab, drv->dig[2], &drv->dig[2]);
|
||||
drv->t[2] = OxiGet(eab, drv->dig[2], &drv->dig[2], drv->t[2]);
|
||||
|
||||
skip2:
|
||||
if (drv->dig[3] < 0) goto skip3;
|
||||
EaseWrite(eab, "R3"); /* read sensor 3 */
|
||||
return __LINE__; case __LINE__: /**********************************/
|
||||
drv->t[3] = OxiGet(eab, drv->dig[3], &drv->dig[3]);
|
||||
drv->t[3] = OxiGet(eab, drv->dig[3], &drv->dig[3], drv->t[3]);
|
||||
|
||||
skip3:
|
||||
if (drv->controlChan == 0 || drv->a == 0) {
|
||||
@ -257,7 +285,7 @@ static long ItcRead(long pc, void *object) {
|
||||
}
|
||||
EaseWrite(eab, "R0"); /* read control T */
|
||||
return __LINE__; case __LINE__: /**********************************/
|
||||
drv->t[0] = OxiGet(eab, drv->dig[drv->controlChan], NULL);
|
||||
drv->t[0] = OxiGet(eab, drv->dig[drv->controlChan], NULL, drv->t[0]);
|
||||
if (drv->gasMode == 2) {
|
||||
if (drv->t[drv->controlChan] > drv->autoGasLimit + 1.0) {
|
||||
if (drv->a < 2) {
|
||||
@ -304,14 +332,35 @@ static long ItcRead(long pc, void *object) {
|
||||
EaseWrite(eab, "R5"); /* read heater */
|
||||
return __LINE__; case __LINE__: /**********************************/
|
||||
if (EaseGetUpdate(drv, ITC_SETHTR)) goto skiphtr;
|
||||
drv->htr = OxiGet(eab, 1, NULL);
|
||||
drv->htr = OxiGet(eab, 1, NULL, drv->htr);
|
||||
skiphtr:
|
||||
|
||||
EaseWrite(eab, "R7"); /* read gas flow */
|
||||
return __LINE__; case __LINE__: /**********************************/
|
||||
drv->gas = OxiGet(eab, 1, NULL);
|
||||
drv->gas = OxiGet(eab, 1, NULL, drv->gas);
|
||||
skipgas:
|
||||
|
||||
if (EaseGetUpdate(drv, ITC_PROP)) goto skipprop;
|
||||
EaseWrite(eab, "R9"); /* read prop */
|
||||
return __LINE__; case __LINE__: /**********************************/
|
||||
if (EaseGetUpdate(drv, ITC_PROP)) goto skipprop;
|
||||
drv->prop = OxiGet(eab, 1, NULL, drv->prop);
|
||||
skipprop:
|
||||
|
||||
if (EaseGetUpdate(drv, ITC_INTEG)) goto skipint;
|
||||
EaseWrite(eab, "R10"); /* read int */
|
||||
return __LINE__; case __LINE__: /**********************************/
|
||||
if (EaseGetUpdate(drv, ITC_INTEG)) goto skipint;
|
||||
drv->integ = OxiGet(eab, 1, NULL, drv->integ);
|
||||
skipint:
|
||||
|
||||
if (EaseGetUpdate(drv, ITC_DERIV)) goto skipderiv;
|
||||
EaseWrite(eab, "R11"); /* read deriv */
|
||||
return __LINE__; case __LINE__: /**********************************/
|
||||
if (EaseGetUpdate(drv, ITC_DERIV)) goto skipderiv;
|
||||
drv->deriv = OxiGet(eab, 1, NULL, drv->deriv);
|
||||
skipderiv:
|
||||
|
||||
ParLog(drv);
|
||||
fsm_quit: return 0; } /* FSM END *********************************/
|
||||
}
|
||||
@ -377,8 +426,12 @@ static long ItcSetTemp(long pc, void *object) {
|
||||
skiph:
|
||||
OxiSet(eab, "T", drv->d.targetValue, drv->dig[drv->controlChan]); /* set point */
|
||||
return __LINE__; case __LINE__: /**********************************/
|
||||
|
||||
if (drv->pidMode != 0) goto skipPidMode;
|
||||
EaseWrite(eab, "L1"); /* 'auto' pid on */
|
||||
return __LINE__; case __LINE__: /**********************************/
|
||||
skipPidMode:
|
||||
|
||||
a = 1; /* auto heater */
|
||||
if (drv->a >= 2) a = 3; /* auto gas & heater */
|
||||
if (drv->d.targetValue == 0.0) {
|
||||
@ -428,7 +481,7 @@ static long ItcSetGas(long pc, void *object) {
|
||||
return __LINE__; case __LINE__: /**********************************/
|
||||
EaseWrite(eab, "R7"); /* read gas flow */
|
||||
return __LINE__; case __LINE__: /**********************************/
|
||||
drv->gas = OxiGet(eab, 1, NULL);
|
||||
drv->gas = OxiGet(eab, 1, NULL, drv->gas);
|
||||
if (drv->a < 2) goto quit;
|
||||
snprintf(buf, sizeof buf, "A%d", drv->a);
|
||||
EaseWrite(eab, buf);
|
||||
@ -471,6 +524,17 @@ static long ItcSet(long pc, void *object) {
|
||||
case EASE_RUN: FsmCall(ItcSetTemp); goto loop;
|
||||
case ITC_SETHTR: FsmCall(ItcSetHtr); goto loop;
|
||||
case ITC_SETGAS: FsmCall(ItcSetGas); goto loop;
|
||||
case ITC_PIDMODE:
|
||||
if (drv->pidMode == 1) {
|
||||
EaseWrite(eab, "L0");
|
||||
} else {
|
||||
EaseWrite(eab, "L1");
|
||||
drv->pidMode = 2;
|
||||
}
|
||||
goto loop;
|
||||
case ITC_PROP: OxiSet(eab, "P", drv->prop, 1); goto loop;
|
||||
case ITC_INTEG: OxiSet(eab, "I", drv->prop, 1); goto loop;
|
||||
case ITC_DERIV: OxiSet(eab, "D", drv->prop, 1); goto loop;
|
||||
default: break;
|
||||
}
|
||||
EaseWrite(eab, "C0");
|
||||
|
Reference in New Issue
Block a user