Jump to content

for high speed %360°


kadda

Recommended Posts

here s a basic sketch ispired by

 

 

modified to make %360° instruments turn at higher speeds ( like Roll indication in my case ),

 

AccelStepper kren(AccelStepper::DRIVER, step, dir);
/************************************************************************************************************************************/
char flagroll;
long currentrollStepperPosition = 0, diffposition; 
long lastAccelStepperPosition;
long targetrollPosition,movementSinceLastUpdate ;
long   lastroll,krenvoulu;
#define MAXROLLSPEED   500
#define MAXROLLACCEL   500
#define  MAXROLLTOUR   (931) // for my gear ratio correction
#define  MAXROLLTOURM10   (9300) // for my gear ration correction (in fact i m correcting because of the ratio i have 930.1 steps per revolution ) 

long delta;
long poskren,lastkren;
int corriger,cumul;
short statekren,signcurr;
long currentStepperPosition = 0; 
void onKpp1273kRollChange(unsigned int krenValue) {      
    long targetPosition =  map(krenValue, 0l, 65535l, 0l,MAXROLLTOURM10);
    targetPosition= targetPosition/10 + (targetPosition%10 >=6 ? 1 :0);
    poskren = kren.currentPosition();
    movementSinceLastUpdate =  poskren- lastAccelStepperPosition;
    currentStepperPosition += movementSinceLastUpdate;
    lastAccelStepperPosition = kren.currentPosition();
    
   if (currentStepperPosition < 0) {
         
         currentStepperPosition =    (-currentStepperPosition)%MAXROLLTOUR;
         currentStepperPosition =    -(currentStepperPosition)+MAXROLLTOUR;
         signcurr=1;
   }
   currentStepperPosition %= MAXROLLTOUR;
   if(abs(poskren-lastkren)>=(10*MAXROLLTOUR)){
            targetPosition= targetPosition + (poskren-lastkren >0 ? -1 : +1);
            lastkren = poskren;
   }
   delta = targetPosition - currentStepperPosition;

  if (delta < -(MAXROLLTOUR/2)) delta += MAXROLLTOUR;

  if (delta > (MAXROLLTOUR/2)) delta -= MAXROLLTOUR;
  if(delta!=0) {
           kren.move(delta);
  }
}
DcsBios::IntegerBuffer kpp1273kRollBuffer(0x320a, 0xffff, 0, onKpp1273kRollChange);


Edited by kadda
  • Like 1

With respect

_________________

Kadda

_________________

My works

TL-39 (NewGen) project (Ру)/(EN)

Link to comment
Share on other sites

@WhoMadeWho ,

i m using different type of steppers, essentially because with some instruments i need tork but not speed, with others speed and no tork, unfortunatlly or fortunatlly ( i dont know because i learned many thing from that) with others i need both plus precision stepping, but one is commun for all the steppers, i get them all from old broken machinary ( printers, conditioners, ...), for the roll indicator in particular i m using "EM-462" from an old epson printer (i mean very old one :lol: )

 

@Hansolo , @WhoMadeWho

 

you re welecome

 

 

ps to all : i m very sorry for my " multilaguage sketch writing "


Edited by kadda

With respect

_________________

Kadda

_________________

My works

TL-39 (NewGen) project (Ру)/(EN)

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...