Author SHA1 Message Date
fewikay efbbbb73e2 included config mmperturn, stepsperturn 2026-11-13 15:56:00 +01:00
2 changed files with 34 additions and 11 deletions

No files matched your search

@@ -26,13 +26,15 @@ int state = 0;
float posmax = 295; float posmax = 295;
float posmin = 0.0f; float posmin = 0.0f;
float posref = 0.0f; float posref = 0.0f;
int mmperturn = 1; // Spindelsteigung 4 mm, Motor 200 Vollschritte pro Umdrehung (Pflichtenheft)
float mmperturn = 4;
int stepsperturn = 200;
// eingestellter Step Mode: 1, 2, 4, 8 oder 16 // eingestellter Step Mode: 1, 2, 4, 8 oder 16
int microsteps = 16; int microsteps = 16;
// 50 Vollschritte pro mm, bei 1/16 Schritt also 800 Schritte pro mm // 200 / 4 = 50 Vollschritte pro mm, bei 1/16 Schritt also 800 Schritte pro mm
int mm_to_step(float mm){ int mm_to_step(float mm){
return (int)(50 * microsteps * mm); return (int)(stepsperturn * microsteps * mm / mmperturn);
} }
static void* StepLibraryMalloc( unsigned int size ){ static void* StepLibraryMalloc( unsigned int size ){
@@ -241,6 +243,13 @@ static int config_stepper(L6474_Handle_t s, int param, float value){
reg = (((int)(value / 2) - 1) << 4) | (reg & 0x0F); reg = (((int)(value / 2) - 1) << 4) | (reg & 0x0F);
result = L6474_SetProperty(s, L6474_PROP_TFAST, reg); result = L6474_SetProperty(s, L6474_PROP_TFAST, reg);
break; break;
case 8:
if(value <= 0){
return 1;
}
mmperturn = value;
result = errcNONE;
break;
case 9: case 9:
posmax = value; posmax = value;
result = errcNONE; result = errcNONE;
@@ -253,8 +262,14 @@ static int config_stepper(L6474_Handle_t s, int param, float value){
posref = value; posref = value;
result = errcNONE; result = errcNONE;
break; break;
case 12:
if(value < 1){
return 1;
}
stepsperturn = (int)value;
result = errcNONE;
break;
default: default:
//TODO param 8 bis 12
return 1; return 1;
} }
@@ -315,6 +330,10 @@ static int config_stepper_get(L6474_Handle_t s, int param, float* value){
result = L6474_GetProperty(s, L6474_PROP_TFAST, &reg); result = L6474_GetProperty(s, L6474_PROP_TFAST, &reg);
*value = ((reg >> 4) + 1) * 2; *value = ((reg >> 4) + 1) * 2;
break; break;
case 8:
*value = mmperturn;
result = errcNONE;
break;
case 9: case 9:
*value = posmax; *value = posmax;
result = errcNONE; result = errcNONE;
@@ -322,12 +341,16 @@ static int config_stepper_get(L6474_Handle_t s, int param, float* value){
case 10: case 10:
*value = posmin; *value = posmin;
result = errcNONE; result = errcNONE;
break;
case 11: case 11:
*value = posref; *value = posref;
result = errcNONE; result = errcNONE;
break; break;
case 12:
*value = stepsperturn;
result = errcNONE;
break;
default: default:
//TODO param 8 bis 12
return 1; return 1;
} }
@@ -482,7 +505,7 @@ int stepper_pos(L6474_Handle_t s){
if(L6474_GetAbsolutePosition(s, &position) != errcNONE){ if(L6474_GetAbsolutePosition(s, &position) != errcNONE){
return 1; return 1;
} }
printf("%d", (position/(50 * microsteps))); printf("%d", (int)(position * mmperturn / (stepsperturn * microsteps)));
return StepperHasFault(s); return StepperHasFault(s);
} }
@@ -647,7 +670,7 @@ int StepperConsoleFunction( int argc, char** argv, void* ctx )
else if(strcmp(argv[2], "-r")==0){ else if(strcmp(argv[2], "-r")==0){
int temp = 0; int temp = 0;
L6474_GetAbsolutePosition(h, &temp); L6474_GetAbsolutePosition(h, &temp);
target_mm = (float)temp / (50 * microsteps) + (float)atof(argv[1]); target_mm = (float)temp * mmperturn / (stepsperturn * microsteps) + (float)atof(argv[1]);
} }
else if(strcmp(argv[2], "-a")==0){ else if(strcmp(argv[2], "-a")==0){
@@ -175,11 +175,11 @@ static int CapabilityFunc( int argc, char** argv, void* ctx )
1, // has spindle 1, // has spindle
1, // has spindle status 1, // has spindle status
1, // has stepper 1, // has stepper
0, // has stepper move relative 1, // has stepper move relative
0, // has stepper move speed 1, // has stepper move speed
0, // has stepper move async 0, // has stepper move async
0, // has stepper status 1, // has stepper status
0, // has stepper refrun 1, // has stepper refrun
0, // has stepper refrun timeout 0, // has stepper refrun timeout
0, // has stepper refrun skip 0, // has stepper refrun skip
0, // has stepper refrun stay enabled 0, // has stepper refrun stay enabled