Heydemann added

This commit is contained in:
2025-03-28 10:27:22 +01:00
parent cae42086e5
commit e5cc0f0a83
13 changed files with 1691 additions and 928 deletions
Binary file not shown.
+35
View File
@@ -61,6 +61,15 @@ record(longin, "EIB:CH_$(CH)_REFACTIVE")
field(INP, "@CH_$(CH)_REFACTIVE")
field(PINI, "1")
}
record(longin, "EIB:CH_$(CH)_heycomp")
{
field(DESC, "channel 0 homed")
field(SCAN, "Event")
field(EVNT, "81")
field(DTYP, "EIB li")
field(INP, "@CH_$(CH)_HEYCOMP")
field(PINI, "1")
}
#............... mbbi ..................
@@ -71,6 +80,16 @@ record(mbbi,"EIB:CH_$(CH)_REFACTIVES")
field(ZRST, "")
field(ONST, "WaitforRef")
}
#............... mbbo ..................
record(mbbo,"EIB:CH_$(CH)_HEYCOMPS")
{
field(DTYP, "Soft Channel")
field(OUT, "EIB:CH_$(CH)_HEYCOMP CPP")
field(ZRST, "Off")
field(ONST, "On")
# field(FLNK, "EIB:CH_$(CH)_HEYCOMP")
}
#............... longout ..................
@@ -95,6 +114,13 @@ record(longout, "EIB:CH_$(CH)_ADDPOINTS")
field(OUT, "@CH_$(CH)_ADDPOINTS")
field(PINI, "1")
}
record(longout, "EIB:CH_$(CH)_HEYCOMP")
{
field(DESC, "channel 0 homed")
field(DTYP, "EIB lo")
field(OUT, "@CH_$(CH)_HEYCOMP")
field(PINI, "1")
}
#............... string ..................
record(stringin, "EIB:CH_$(CH)_NAME")
@@ -133,4 +159,13 @@ record(seq, "EIB:CH_$(CH)_SETSCAN")
field(DOL1, "EIB:CH_$(CH)_ADC00.SCAN CP")
field(LNK1, "EIB:CH_$(CH)_ADC90.SCAN")
}
record(waveform, "EIB:CH_$(CH)_CORRECTION")
{
field(SCAN, "Passive")
field(DTYP, "EIB wf")
field(INP, "@CH_$(CH)_CORRECTION")
field(FTVL, "LONG")
field(NELM, "1024")
field(PREC, "0")
}
+35
View File
@@ -61,6 +61,15 @@ record(longin, "EIB:CH_$(CH)_REFACTIVE")
field(INP, "@CH_$(CH)_REFACTIVE")
field(PINI, "1")
}
record(longin, "EIB:CH_$(CH)_heycomp")
{
field(DESC, "channel 0 homed")
field(SCAN, "Event")
field(EVNT, "81")
field(DTYP, "EIB li")
field(INP, "@CH_$(CH)_HEYCOMP")
field(PINI, "1")
}
#............... mbbi ..................
@@ -71,6 +80,16 @@ record(mbbi,"EIB:CH_$(CH)_REFACTIVES")
field(ZRST, "")
field(ONST, "WaitforRef")
}
#............... mbbo ..................
record(mbbo,"EIB:CH_$(CH)_HEYCOMPS")
{
field(DTYP, "Soft Channel")
field(OUT, "EIB:CH_$(CH)_HEYCOMP CPP")
field(ZRST, "Off")
field(ONST, "On")
# field(FLNK, "EIB:CH_$(CH)_HEYCOMP")
}
#............... longout ..................
@@ -95,6 +114,13 @@ record(longout, "EIB:CH_$(CH)_ADDPOINTS")
field(OUT, "@CH_$(CH)_ADDPOINTS")
field(PINI, "1")
}
record(longout, "EIB:CH_$(CH)_HEYCOMP")
{
field(DESC, "channel 0 homed")
field(DTYP, "EIB lo")
field(OUT, "@CH_$(CH)_HEYCOMP")
field(PINI, "1")
}
#............... string ..................
record(stringin, "EIB:CH_$(CH)_NAME")
@@ -133,4 +159,13 @@ record(seq, "EIB:CH_$(CH)_SETSCAN")
field(DOL1, "EIB:CH_$(CH)_ADC00.SCAN CP")
field(LNK1, "EIB:CH_$(CH)_ADC90.SCAN")
}
record(waveform, "EIB:CH_$(CH)_CORRECTION")
{
field(SCAN, "Passive")
field(DTYP, "EIB wf")
field(INP, "@CH_$(CH)_CORRECTION")
field(FTVL, "LONG")
field(NELM, "1024")
field(PREC, "0")
}
+710 -454
View File
File diff suppressed because it is too large Load Diff
+710 -454
View File
File diff suppressed because it is too large Load Diff
Binary file not shown.
+12
View File
@@ -754,6 +754,18 @@ static long EIBwf_parse(struct waveformRecord *pwf)
pwf->nelm = NUMPOINTS;
return(MON_NO_ERROR);
}
if (!contain(name,"CH_","_CORRECTION",&num))
{
if ( EIB_ValidEncoder(num) )
{
printf("EIB_wf_parse : <%s>, num = %li not available\n",name,num);
return(MON_ERROR);
}
pwf->bptr =(void *) (eib.enc[num].Correction);
pwf->nord = NUMHEY; /* number of data points to be store, e.g. for Heydemann-correction */
pwf->nelm = NUMHEY;
return(MON_NO_ERROR);
}
return(MON_NO_ERROR);
Binary file not shown.
Binary file not shown.
Binary file not shown.
+171 -14
View File
@@ -98,6 +98,7 @@ Feb. 2025 envc_nr = 0,1,2,3
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <errno.h>
#include "epicsExit.h"
#include "epicsThread.h"
@@ -161,6 +162,76 @@ int EIB_Init_Enc(int enc_nr); /* initialize selected encoder */
void EIB_StopRef( int enc_nr);
void EIB_Clear_RingBuffer(int enc_nr);
/****************************************************************************/
void ReadHeyFile(char *filename, HEYARRAY *h)
{
FILE *ein = NULL;
char buffer[BUFLEN];
char *Inhalt;
char *done;
int Wertanzahl = 0;
int index, corr;
for (index=0;index<NUMHEY;index++) (*h)[index]=0;
ein = fopen(filename,"r");
if (ein==NULL)
{
printf("error opening file %s\n",filename);
return;
}
Wertanzahl = 0; /*Einlesen in Feldindex 0 bis Wertanzahl-1 */
while (fgets(buffer, BUFLEN, ein) && (Wertanzahl < NUMHEY))
{
printf("ReadHeyFile: %i ",Wertanzahl);
if (buffer == NULL) goto WEITER; /* Leerzeile */
Inhalt = strtok(buffer, delimList);
if (Inhalt == NULL) goto WEITER;
if (Inhalt[0] == '#' ) goto WEITER;
errno=0;
index = strtol(Inhalt,&done,0);
if (errno)
{
printf("cannot convert <%s>\n",Inhalt);
goto WEITER;
}
Inhalt = strtok(NULL, delimList);
if (Inhalt == NULL) goto WEITER;
if (Inhalt[0] == '#' ) goto WEITER;
errno=0;
corr = strtol(Inhalt,&done,0);
if (errno)
{
printf("cannot convert <%s>\n",Inhalt);
goto WEITER;
}
if ((index <NUMHEY) &&(index >=0))
(*h)[index]= corr;
printf("%5i %i\n",index, corr);
Wertanzahl++;
WEITER:
(void)0; /* dummy statement damit der compiler nicht meckert */
}
printf("ReadHeyFile: read %i entries from File %s\n",Wertanzahl, filename);
}
/*****************************************************************************/
double arctan(double x, double y)
@@ -231,6 +302,15 @@ int EIB_SpaL(char *s, int val)
if (val==2) EIB_Clear_RingBuffer(num);
else eib.enc[num].AddPoints = val;
}
else if (!contain(s,"CH_","_HEYCOMP",&num))
{
if ( EIB_ValidEncoder(num) )
{
printf("SPAL: <%s>, num = %li not available\n",s,num);
return(MON_ERROR);
}
else eib.enc[num].HeyComp = val;
}
else
{
printf("EIB_SpaL: Unkown parameter <%s>\n",s);
@@ -308,6 +388,15 @@ else if (!contain(s,"CH_","_lines",&num))
}
*val= eib.enc[num].RefActive;
}
else if (!contain(s,"CH_","_HEYCOMP",&num))
{
if ( EIB_ValidEncoder(num) )
{
printf("GPAL: <%s>, num = %li not available\n",s,num);
return(MON_ERROR);
}
*val= eib.enc[num].HeyComp;
}
else
{
printf("EIB_GpaL: Unkown parameter <%s>\n",s);
@@ -377,7 +466,7 @@ void CheckError(EIB7_ERR error)
EIB7GetErrorInfo(error, mnemonic, 32, message, 256);
printf("\nError %08X (%s): %s\n", error, mnemonic, message);
// printf("\nError %08X (%s): %s\n", error, mnemonic, message);
switch(error)
{
@@ -483,7 +572,7 @@ void EIB_Clear_RingBuffer(int enc_nr)
/* Initialize variables. They are updated in the EIB_Start() */
void EIB_Init()
{
int i;
int i,j;
InitError();
@@ -509,6 +598,9 @@ int i;
eib.enc [i].RefActive = 0;
eib.enc [i].Interpolation = 4096;
EIB_Clear_RingBuffer(i);
for (j=0;j<NUMHEY;j++) eib.enc [i].Correction[j]=0;
}
}
@@ -1256,7 +1348,6 @@ int EIB_Init_Enc(int enc_nr) /* initialize selected encoder */
Lines = eib.enc[enc_nr].Lines ;
RefSep = eib.enc[enc_nr].RefSep;
Comp = eib.enc[enc_nr].Comp;
err=EIB7InitAxis(eib.axishandles[enc_nr],
iface, /* incremental, Endat ... */
EncType, /* Linear, Rotary */
@@ -1448,7 +1539,35 @@ int EIB_Connect(char *hostname)
return(MON_NO_ERROR);
}
/***********************************************************************************************/
void EIB7_ReadCorrectionFile(int enc_nr)
{
char *Filename;
Filename = ( eib.enc[enc_nr].HeyFileName);
printf("EIB7_ReadCorrectionFile[%i]: Search Correction file %s\n",enc_nr, Filename);
if (checkIfFileExists(Filename))
{
printf("EIB7_ReadCorrectionFile[%i]: File %s Found\n",enc_nr, Filename);
ReadHeyFile( eib.enc[enc_nr].HeyFileName, &(eib.enc[enc_nr].Correction));
}
else
{
printf("EIB7_ReadCorrectionFile[%i]: File %s not Found\n",enc_nr, Filename);
return;
}
printf("EIB7_ReadCorrectionFile[%i]: Open %s\n",enc_nr, Filename);
}
/***********************************************************************************************/
/* Read config data, initialize EIB, start tasks */
int EIB_Start()
@@ -1499,6 +1618,8 @@ int EIB_Start()
if ( cfgGet(Mcfg,"E0_RefSep" , &eib.enc[0].RefSep , intType ,1)) eib.enc[0].RefSep =0;
if ( cfgGet(Mcfg,"E0_SigV" , &eib.enc[0].SigV , intType ,1)) eib.enc[0].SigV =+1;
if ( cfgGet(Mcfg,"E0_Comp" , &eib.enc[0].Comp , intType ,1)) eib.enc[0].Comp =0;
if ( cfgGet(Mcfg,"E0_HeyComp" , &eib.enc[0].HeyComp , intType ,1)) eib.enc[0].HeyComp =0;
if ( cfgGet(Mcfg,"E0_HeyFile" , &eib.enc[0].HeyFileName , strType ,1));
if ( cfgGet(Mcfg,"E1_Name" , &eib.enc[1].Name , strType ,0)) ;
if ( cfgGet(Mcfg,"E1_iface" , &eib.enc[1].iface , intType ,0)) eib.enc[1].iface =0; /* 0 invalid, 1 incremental */
@@ -1508,6 +1629,8 @@ int EIB_Start()
if ( cfgGet(Mcfg,"E1_RefSep" , &eib.enc[1].RefSep , intType ,0)) eib.enc[1].RefSep =0;
if ( cfgGet(Mcfg,"E1_SigV" , &eib.enc[1].SigV , intType ,0)) eib.enc[1].SigV =+1;
if ( cfgGet(Mcfg,"E1_Comp" , &eib.enc[1].Comp , intType ,1)) eib.enc[1].Comp =+1;
if ( cfgGet(Mcfg,"E1_HeyComp" , &eib.enc[1].HeyComp , intType ,1)) eib.enc[0].HeyComp =0;
if ( cfgGet(Mcfg,"E1_HeyFile" , &eib.enc[1].HeyFileName , strType ,1));
if ( cfgGet(Mcfg,"E2_Name" , &eib.enc[2].Name , strType ,0));
if ( cfgGet(Mcfg,"E2_iface" , &eib.enc[2].iface , intType ,0)) eib.enc[2].iface =0; /* 0 invalid, 1 incremental */
@@ -1517,6 +1640,8 @@ int EIB_Start()
if ( cfgGet(Mcfg,"E2_RefSep" , &eib.enc[2].RefSep , intType ,0)) eib.enc[2].RefSep =0;
if ( cfgGet(Mcfg,"E2_SigV" , &eib.enc[2].SigV , intType ,0)) eib.enc[2].SigV =+1;
if ( cfgGet(Mcfg,"E2_Comp" , &eib.enc[2].Comp , intType ,1)) eib.enc[2].Comp =+1;
if ( cfgGet(Mcfg,"E2_HeyComp" , &eib.enc[2].HeyComp , intType ,1)) eib.enc[0].HeyComp =0;
if ( cfgGet(Mcfg,"E2_HeyFile" , &eib.enc[2].HeyFileName , strType ,1));
if ( cfgGet(Mcfg,"E3_Name" , &eib.enc[3].Name , strType ,0)) ;
if ( cfgGet(Mcfg,"E3_iface" , &eib.enc[3].iface , intType ,0)) eib.enc[3].iface =0; /* 0 invalid, 1 incremental */
@@ -1526,6 +1651,8 @@ int EIB_Start()
if ( cfgGet(Mcfg,"E3_RefSep" , &eib.enc[3].RefSep , intType ,0)) eib.enc[3].RefSep =0;
if ( cfgGet(Mcfg,"E3_SigV" , &eib.enc[3].SigV , intType ,0)) eib.enc[3].SigV =+1;
if ( cfgGet(Mcfg,"E3_Comp" , &eib.enc[3].Comp , intType ,1)) eib.enc[3].Comp =+1;
if ( cfgGet(Mcfg,"E3_HeyComp" , &eib.enc[3].HeyComp , intType ,1)) eib.enc[0].HeyComp =0;
if ( cfgGet(Mcfg,"E3_HeyFile" , &eib.enc[3].HeyFileName , strType ,1));
for (i=0;i<4;i++)
{
@@ -1534,9 +1661,20 @@ int EIB_Start()
{
if (eib.enc[i].EncType == 0) eib.enc[i].Teilung = 1.0 / eib.enc[i].Lines; /* mm / line */
else if (eib.enc[i].EncType == 1) eib.enc[i].Teilung = 360.0 / eib.enc[i].Lines; /* deg / line */
}
}
if (strlen(eib.enc[i].HeyFileName))
{
//EIB7_ReadCorrectionFile(i);
ReadHeyFile( eib.enc[i].HeyFileName, &(eib.enc[i].Correction));
}
else
printf("EIB_Start[%i] : No correction filename given %s\n",i,eib.enc[i].HeyFileName);
}
}
if (EIB_Start_ConnectTask())
{
@@ -1693,6 +1831,8 @@ int EIB_Read(int enc_nr, double *value)
ENCODER_POSITION position;
long lref;
char Msg[200];
int index;
int corr;
if (!eib.connected)
{
@@ -1714,7 +1854,7 @@ int EIB_Read(int enc_nr, double *value)
printf("EIB_Read : Error receiving data error = %i",err);
return(MON_ERROR);
}
if((iface==1) || (iface==2049))
{
switch (eib.enc [enc_nr].RefMarks)
@@ -1725,6 +1865,16 @@ int EIB_Read(int enc_nr, double *value)
default : lref = 0; printf("EIB_READ: Invalid RefMarks (%i)\n",eib.enc[enc_nr].RefMarks);
}
if (eib.enc[enc_nr].HeyComp ==1) /* Heydemann correction */
{
index = (int) (data.interpolate * 1024);
if ((index>0)&& (index<1024)) corr = eib.enc[enc_nr].Correction[index]; else corr = 0;
if (verbose==1) printf(" Pos(%i) = %lli fraction %i index = %i correction = %i \n",enc_nr, data.pos, data.interpolate,index, corr );
}
// position = data.pos - data.refc;
position = data.pos - lref;
@@ -1781,7 +1931,9 @@ void EIB_ShowEncoder(ENC enc)
printf(" RefActive = %i\n", enc.RefActive);
printf(" LastRef = %li\n", enc.LastRef);
printf(" RefcPos = %5.3f\n", enc.RefPos);
printf(" Comp = %i\n", enc.Comp);
printf(" Comp = %i\n", enc.Comp);
printf(" HeyComp = %i\n", enc.HeyComp);
printf(" HeyFile = <%s>\n", enc.HeyFileName);
printf(" NextHist = %i\n", enc.NextHist);
printf(" AddPoints = %i\n", enc.AddPoints);
printf(" Interpolation= %i\n", enc.Interpolation);
@@ -1827,13 +1979,13 @@ void EIB_ShowEib()
printf(" Handle : %i\n", eib.handle);
printf(" Connected : %i\n", eib.connected);
printf(" Firmware ver. : %s\n", eib.fw_version);
printf(" Encoders : %li\n", eib.num);
printf(" Encoders : %li\n", eib.num);
printf(" Connect : %i\n", Connect);
printf(" CONNECTING : %i\n", CONNECTING);
printf(" configFile : %s\n",CfgFileName );
printf(" cdbg : %i\n",cdbg );
printf(" rdbg : %i\n",rdbg );
printf(" verbose : %i\n",verbose );
printf(" configFile : %s\n", CfgFileName );
printf(" cdbg : %i\n", cdbg );
printf(" rdbg : %i\n", rdbg );
printf(" verbose : %i\n", verbose );
for (i=0;i<NUM_OF_AXIS;i++)
{
@@ -2029,8 +2181,9 @@ enc_nr = 0;
printf(" (F) Calc Reference ........ (F)\n");
printf(" (G) Check Ref_status ...... (G)\n");
printf(" (H) Reference axis ........ (I)\n");
printf(" (J) Check Connection ...... (J)\n");
printf(" (I) Initialize axis ....... (I)\n");
printf(" (J) Check Connection ...... (J)\n");
printf(" (K) REad HeyFile .......... (K)\n");
printf(" (N) Set long parameter .... (N)\n");
printf(" (O) Generate Event ....... (O)\n");
printf(" (P) Show Ringbuffer ...... (P)\n");
@@ -2089,7 +2242,11 @@ enc_nr = 0;
case 'J' : EIB_CheckConnection(&status);
printf("Status = %i 0x%x\n",status,(unsigned int) status);
break;
case 'N' : printf("Parametername (long)) : ");
case 'K' : ReadHeyFile(eib.enc[enc_nr].HeyFileName, &(eib.enc[enc_nr].Correction));
break;
case 'N' : printf("Parametername (long)) : ");
scanf("%s",(char *)ParamName);CR();
if (!strcmp(ParamName," ")) break;
printf("Value to set : ");
+9 -3
View File
@@ -6,11 +6,12 @@
#define NUM_OF_AXIS 4 /* number of axes of the EIB */
#define NCHANNELS 4
#define NUMPOINTS 200 /* number of data points to be store, e.g. for Heydemann-correction */
#define NUMHEY 1024
typedef struct T_Data DATA; /* Structure to hold the values provided by a read-command */
struct T_Data
{
unsigned short status; /* status word */
unsigned short status; /* status word */
ENCODER_POSITION pos; /* position value (integer) */
ENCODER_POSITION ref1;
ENCODER_POSITION ref2;
@@ -25,6 +26,8 @@ struct T_Data
};
typedef struct T_Data DataArr[NUMPOINTS];
typedef int HEYARRAY[NUMHEY];
typedef HEYARRAY *P_HEYARRAY;
typedef struct T_enc ENC;
struct T_enc
@@ -49,9 +52,12 @@ struct T_enc
unsigned long Status; /* Data.status from EIB_read */
double adc00[NUMPOINTS]; /* for waveform-record */
double adc90[NUMPOINTS]; /* for waveform-record */
// DATA History[NUMPOINTS]; /* not used */
DataArr History; /* not used */
// DATA History[NUMPOINTS]; /* not used */
DataArr History; /* not used */
unsigned int Interpolation; /* 4096 default */
int HeyComp; /* Heydemanncompensation off=0, on=1 */
char HeyFileName[120];
HEYARRAY Correction;
};
typedef struct T_eib EIB;
+9 -3
View File
@@ -12,7 +12,9 @@
E0_RefMarks 1 # How meany reference marks (1 standard,2 = distance coded)
E0_EncType 1 # 0 linear, 1 rotary
E0_Lines 36000 # per mm for AxeType = 0, per revolution for AxeType = 1:
E0_Comp 0 # Compenation off (0) On(1)
E0_Comp 0 # Onboard Compensation off (0) On(1)
E0_HeyComp 0 # Heydemanncompensation off (0) On(1)
E0_HeyFile "ik0.hey"
# X05DA
@@ -23,7 +25,9 @@
E1_Lines 36000 # per mm for AxeType = 0, per revolution for AxeType = 1:
E1_RefSep 1000 # number of periods between two reference marks
E1_SigV +1 # for distance coded refmarks, +1 standard, -1 else
E1_Comp 0 # Compenation off (0) On(1)
E1_Comp 0 # Onboard Compensation off (0) On(1)
E1_HeyComp 0 # Heydemanncompensation off (0) On(1)
E1_HeyFile "x05da.hey"
# ROD
E2_Name "ROD"
@@ -31,5 +35,7 @@
E2_RefMarks 1 # How meany reference marks (1 standard,2 = distance coded)
E2_EncType 1 # 0 linear, 1 rotary
E2_Lines 3600 # per mm for AxeType = 0, per revolution for AxeType = 1:
E2_Comp 0 # Compenation off (0) On(1)
E2_Comp 0 # Onboard Compensation off (0) On(1)
E2_HeyComp 0 # Heydemanncompensation off (0) On(1)
E2_HeyFile "nocomp.hey"