     if(currentTick[6]>=currentPeriod[6]){
       if(currentPosition[6]>=MAX_POSITION){
         sbi(portd,7);
+        sbi(portddirection,7);
       }else if(currentPosition[6]<=MIN_POSITION){
         cbi(portd,7);
+        cbi(portddirection,7);
       }
 
       if(ebi(portd,7)){


      if(ebi(portb,0)){
        cbi(portb,0);
        cbi(portbdirection,0);
      }else{
        sbi(portb,0);
        sbi(portbdirection,0);
      }
      currentTick[8]=0;
    }

    if(currentTick[14]>=currentPeriod[14]){
      if(currentPosition[14]>=MAX_POSITION){
        sbi(portc,1);
        sbi(portcdirection,1);
      }else if(currentPosition[14]<=MIN_POSITION){
        cbi(portc,1);
        cbi(portcdirection,1);
      }

      if(ebi(portc,1)){
