- ECB motors without encoders, with encoders and with control bits now work
This commit is contained in:
47
ecb.c
47
ecb.c
@@ -325,6 +325,49 @@ int ECBAction(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------*/
|
||||
int ecbAssignEncoder(pECB self, int encoder, int motorNumber){
|
||||
|
||||
if(encoder <= 0 || encoder > 3){
|
||||
return 0;
|
||||
}
|
||||
|
||||
self->encoder[encoder-1] = motorNumber;
|
||||
self->encoderDirty = 1;
|
||||
return 1;
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
int ecbLoadEncoder(pECB self){
|
||||
Z80_reg in, out;
|
||||
int status;
|
||||
|
||||
if(self->encoderDirty != 1){
|
||||
/*
|
||||
no need to do it if no change
|
||||
*/
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(self->encoder[0] != 0){
|
||||
in.d = self->encoder[0];
|
||||
}else {
|
||||
in.d = 0;
|
||||
}
|
||||
if(self->encoder[1] != 0){
|
||||
in.e = self->encoder[1];
|
||||
}else {
|
||||
in.e = 0;
|
||||
}
|
||||
if(self->encoder[2] != 0){
|
||||
in.b = self->encoder[2];
|
||||
}else {
|
||||
in.b = 0;
|
||||
}
|
||||
in.c = 1;
|
||||
|
||||
status = ecbExecute(self,152,in,&out);
|
||||
return status;
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
void ECBKill(void *pData){
|
||||
pECB self = (pECB)pData;
|
||||
@@ -345,7 +388,9 @@ void ECBKill(void *pData){
|
||||
}
|
||||
free(self);
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*----------------------------------------------------------------------
|
||||
MakeECB name gpibcontroller boardNo gpib-address
|
||||
-----------------------------------------------------------------------*/
|
||||
int MakeECB(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
int argc, char *argv[]){
|
||||
pECB self = NULL;
|
||||
|
||||
Reference in New Issue
Block a user