From 32e55f21762e157926d834aa0ae6deb265dd39aa Mon Sep 17 00:00:00 2001 From: Mark Koennecke Date: Mon, 13 Oct 2014 13:38:51 +0200 Subject: [PATCH] Added a motor driver which ignores air cushion errors for TRICS (falsely triggered) --- el734hp.c | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++ psi.c | 13 +++++++ sanslirebin.c | 1 + 3 files changed, 115 insertions(+) diff --git a/el734hp.c b/el734hp.c index 89cf58e..da67c4b 100644 --- a/el734hp.c +++ b/el734hp.c @@ -744,3 +744,104 @@ MotorDriver *CreateEL734HPT(SConnection * pCon, int argc, char *argv[]) } return pDriv; } +/*====================================================================== +A version which ignores the air cushion error for TRICS. Not recommended for +general use!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +But HW cannot be fixed.... as the electronics guys are not there....... +========================================================================*/ +static int EL734FixAir(void *pData, int iCode, float fValue) +{ + pEL734Driv self = NULL; + int status, msr, i, len = 49; + char pCommand[50], pReply[80]; + + self = (pEL734Driv) pData; + assert(self); + + switch (iCode) { + /* + air cushion error is really OK..... + */ + case BADCUSHION: + return MOTOK; + case BADADR: + case BADCMD: + case BADPAR: + return MOTREDO; + case BADBSY: + EL734Halt(pData); + SicsWait(1); + return MOTREDO; + case TIMEOUT: + for (i = 0; i < 3; i++) { + len = 49; + status = readRS232TillTerm(self->controller, pReply, &len); + if (status == 1) { + return MOTREDO; + } + } + /* + If nothing can be read, the only fixable cause is a network breakdown + Try to fix this. If this does not work: give up + */ + closeRS232(self->controller); + SicsWait(60); + status = initRS232(self->controller); + if (status != 1) { + return MOTFAIL; + } else { + return MOTREDO; + } + break; + case BADUNKNOWN: + if (availableRS232(self->controller)) { + len = 79; + readRS232TillTerm(self->controller, pReply, &len); + return MOTREDO; + } + return MOTFAIL; + break; + case BADLOC: + snprintf(pCommand, 49, "RMT 1\r"); + transactEL734(self->controller, pCommand, strlen(pCommand), pReply, + 79); + snprintf(pCommand, 49, "ECHO 0\r"); + transactEL734(self->controller, pCommand, strlen(pCommand), pReply, + 79); + return MOTREDO; + case NOTCONNECTED: + initRS232(self->controller); + return MOTREDO; + case RUNFAULT: + case POSFAULT: + return MOTREDO; + case BADCOUNT: + self->runCount = 0; + self->posCount = 0; + return MOTOK; + case BADSEND: + /* + network problem: try to reopen connection + */ + closeRS232(self->controller); + SicsWait(60); + status = initRS232(self->controller); + if (status != 1) { + return MOTFAIL; + } else { + return MOTREDO; + } + } + return MOTFAIL; +} +/*-------------------------------------------------------------------------*/ +MotorDriver *CreateEL734Air(SConnection * pCon, int argc, char *argv[]) +{ + MotorDriver *pDriv = NULL; + pDriv = CreateEL734HP(pCon, argc, argv); + if (pDriv != NULL) { + pDriv->TryAndFixIt = EL734FixAir; + } + return pDriv; +} + diff --git a/psi.c b/psi.c index 880d751..cec469c 100644 --- a/psi.c +++ b/psi.c @@ -145,6 +145,7 @@ static void AddPsiCommands(SicsInterp * pInter) /*---------------------------------------------------------------------*/ MotorDriver *CreateEL734HP(SConnection * pCon, int argc, char *argv[]); MotorDriver *CreateEL734HPT(SConnection * pCon, int argc, char *argv[]); +MotorDriver *CreateEL734Air(SConnection * pCon, int argc, char *argv[]); MotorDriver *MakePiPiezo(Tcl_Interp * pTcl, char *pArray); /*-------------------------------------------------------------------*/ static pMotor CreatePsiMotor(SConnection * pCon, int argc, char *argv[]) @@ -180,6 +181,18 @@ static pMotor CreatePsiMotor(SConnection * pCon, int argc, char *argv[]) SCWrite(pCon, pBueffel, eError); return NULL; } + } else if (strcmp(argv[1], "el734air") == 0) { + pDriver = (MotorDriver *) CreateEL734Air(pCon, argc - 2, &argv[2]); + if (!pDriver) { + return NULL; + } + /* create the motor */ + pNew = MotorInit("EL734air", argv[0], pDriver); + if (!pNew) { + snprintf(pBueffel,131, "Failure to create motor %s", argv[1]); + SCWrite(pCon, pBueffel, eError); + return NULL; + } } else if (strcmp(argv[1], "el734hpt") == 0) { pDriver = (MotorDriver *) CreateEL734HPT(pCon, argc - 2, &argv[2]); if (!pDriver) { diff --git a/sanslirebin.c b/sanslirebin.c index c881612..6e81368 100644 --- a/sanslirebin.c +++ b/sanslirebin.c @@ -196,6 +196,7 @@ int SansliRebin(SConnection * pCon, SicsInterp * pSics, void *pData, sortData[ix].frac = frac; } else { val = .0; + frac = .0; } setSICSDataInt(target, pos, (int) val); }