- Driver for the Risoe Temperature controller
- HM is now working - display code added
This commit is contained in:
70
ecbdriv.c
70
ecbdriv.c
@@ -448,6 +448,72 @@ static int loadOffset(pECBMotDriv self, float offset){
|
||||
}
|
||||
return status;
|
||||
}
|
||||
/*---------------------------------------------------------------------
|
||||
This loads the gearing parameters for the CRT display. This should
|
||||
not have any influence on the running of the motor
|
||||
------------------------------------------------------------------------*/
|
||||
static double To_ten(int v) {
|
||||
double vv;
|
||||
|
||||
|
||||
vv = 1.0;
|
||||
if (v == 1)
|
||||
vv = 10.0;
|
||||
if (v == 2)
|
||||
vv = 100.0;
|
||||
if (v == 3)
|
||||
vv = 1000.0;
|
||||
if (v == 4)
|
||||
vv = 10000.0;
|
||||
if (v == 5)
|
||||
vv = 100000.0;
|
||||
if (v == 6)
|
||||
vv = 1000000.0;
|
||||
if (v == 7)
|
||||
vv = 10000000.0;
|
||||
return (vv);
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
static int loadGearing(pECBMotDriv self){
|
||||
int status;
|
||||
double dgear;
|
||||
int gdec, dec = 0, ratio;
|
||||
Ecb_pack data;
|
||||
Z80_reg in, out;
|
||||
|
||||
in.c = self->ecbIndex;
|
||||
dgear = (double) ObVal(self->driverPar,STEPS2DEG);;
|
||||
|
||||
/* Calculate decimals in display and gearing ratio for the ECB system*/
|
||||
gdec = (int) (1.0 + (log10(dgear - .01)));
|
||||
if (dec < gdec)
|
||||
dec = gdec; /* Display does not work with decimals < gdec */
|
||||
ratio = (long) (0.5 + dgear*To_ten(6 + 1 - dec));
|
||||
|
||||
data.result = ratio;
|
||||
in.b = data.b.byt2;
|
||||
in.d = data.b.byt1;
|
||||
in.e = data.b.byt0;
|
||||
status = ecbExecute(self->ecb,174,in,&out);
|
||||
if(status != 1){
|
||||
self->errorCode = COMMERROR;
|
||||
}
|
||||
|
||||
if(ObVal(self->driverPar,ENCODER) == 0){
|
||||
in.b = self->ecbIndex;
|
||||
} else {
|
||||
in.b = 1;
|
||||
in.e = (unsigned char)ObVal(self->driverPar,ENCODER);
|
||||
}
|
||||
in.d = 0;
|
||||
in.e = dec;
|
||||
status = ecbExecute(self->ecb,173,in,&out);
|
||||
if(status != 1){
|
||||
self->errorCode = COMMERROR;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
static int downloadECBParam(pECBMotDriv self){
|
||||
int status, parameter;
|
||||
@@ -504,6 +570,10 @@ static int downloadECBParam(pECBMotDriv self){
|
||||
self->driverPar[MULT].fVal = .0;
|
||||
}
|
||||
|
||||
if(status = loadGearing(self) <= 0){
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user