Encoder driver stepper motor, not work Arduino DUE - HELP!

Hello,
i have problem with program code. This program code work to Arduino mini 5V 16Mhz.
During high speed encoder losing the signal. If the slow speed works well.
I do not know whether the problem is with the code or the Arduino Mini is too slow.
That’s why I bought an Arduino Due. But code for arduino mini not work for arduino DUE. Please help.
Problem is delay.h

#define encoder_a 2 //keep this on and interrupt pin
#define encoder_b 3 //keep this on and interrupt pin
#define motor_step 6 //can be any pin
#define motor_direction 7 //can be any pin

#include <delay.h>
volatile long motor_position, encoder;

void setup () {
  //set up the various outputs
  pinMode(motor_step, OUTPUT);
  pinMode(motor_direction, OUTPUT);
  
  // then the encoder inputs
  pinMode(encoder_a, INPUT);
  pinMode(encoder_b, INPUT);
  // enable pullup as we are using an open collector encoder
  digitalWrite(encoder_a, HIGH); 
  digitalWrite(encoder_b, HIGH); 
  
  // encoder pin on interrupt 0 (pin 2)
  attachInterrupt(0, encoderPinChangeA, CHANGE);
  // encoder pin on interrupt 1 (pin 3)
  attachInterrupt(1, encoderPinChangeB, CHANGE);
  encoder = 0; //reseet the encoder position to 0
}

void loop() {
  //do stuff dependent on encoder position here
  //such as move a stepper motor to match encoder position
  //if you want to make it 1:1 ensure the encoder res matches the motor res by dividing/multiplying
  if (encoder > 0) {
    digitalWrite(motor_direction, HIGH);// move stepper in reverse
    digitalWrite(motor_step, HIGH);
    digitalWrite(motor_step, LOW);
    delayMicroseconds(600); //_delay_us(200); //modify to alter speed
    motor_position++;
    encoder = 0; //encoder--;
  }
  else if (encoder < 0) {
    digitalWrite (motor_direction, LOW); //move stepper forward
    digitalWrite (motor_step, HIGH);
    digitalWrite (motor_step, LOW);
    delayMicroseconds(600); //_delay_us(200); //modify to alter speed
    motor_position--;
    encoder = 0; //encoder++;
  }
}

void encoderPinChangeA() {
  if (digitalRead(encoder_a)==digitalRead(encoder_b)) {
    encoder--;
  }
  else{
      encoder++;
  }
}

void encoderPinChangeB() {
  if (digitalRead(encoder_a) != digitalRead(encoder_b)) {
    encoder--;
  }
  else {
    encoder++;
  }
 }
  if (digitalRead(encoder_a)==digitalRead(encoder_b)) {

digitalRead() is not all that fast. Direct port manipulation (that's a search term for you) would be faster.

But, on the DUE, it should be fast enough.

On the other hand, the product page does not say anything about which pins support external interrupts on the Due, so I wonder why you assumed you knew which pins to use.

These pins are set out in the mini-16MHz 5V 328 version should work on DUO i think.

The should, but a Duo and Due are not the same thing. You need to determine if the Due even supports external interrupts. There are hints in the comments on the Due page that suggest that it does not.

Do you have any solution.

To what?

You need to determine if the Due even supports external interrupts.

You can directly specify the pin number in attachInterrupt().

So, did you?

If so, you modified your code, and you should post it again.

If not, get busy!

Now I was able to customize the output pin on the right to DUE. Now it’s work, but still we do not act quickly, the problem is not on the Arduino boards, but the program (code).
Also on the Arduino DUE signal from the encoder to move quickly lose signal and a stepper motor works slowly.
new code:

#define encoder_a 22 
#define encoder_b 23 
#define motor_step 53 
#define motor_direction 52 

volatile long motor_position, encoder;

void setup () {
   pinMode(motor_step, OUTPUT);
  pinMode(motor_direction, OUTPUT);
  
  pinMode(encoder_a, INPUT);
  pinMode(encoder_b, INPUT);
  digitalWrite(encoder_a, HIGH); 
  digitalWrite(encoder_b, HIGH); 
  
  attachInterrupt(22, encoderPinChangeA, CHANGE);
  attachInterrupt(23, encoderPinChangeB, CHANGE);
  encoder = 0; //reseet the encoder position to 0
}

void loop() {
  if (encoder > 0) {
    digitalWrite(motor_direction, HIGH);
    digitalWrite(motor_step, HIGH);
    digitalWrite(motor_step, LOW);
    delayMicroseconds(600); 
    motor_position++;
    encoder = 0; //encoder--;
  }
  else if (encoder < 0) {
    digitalWrite (motor_direction, LOW); 
    digitalWrite (motor_step, HIGH);
    digitalWrite (motor_step, LOW);
    delayMicroseconds(600); 
    motor_position--;
    encoder = 0; //encoder++;
  }
}

void encoderPinChangeA() {
  if (digitalRead(encoder_a)==digitalRead(encoder_b)) {
    encoder--;
  }
  else{
      encoder++;
  }
}

void encoderPinChangeB() {
  if (digitalRead(encoder_a) != digitalRead(encoder_b)) {
    encoder--;
  }
  else {
    encoder++;
  }
 }

Why do you have two functions that do exactly the same thing?

  // encoder pin on interrupt 0 (pin 2)
  attachInterrupt(22, encoderPinChangeA, CHANGE);
  // encoder pin on interrupt 1 (pin 3)
  attachInterrupt(23, encoderPinChangeB, CHANGE);

Nothing in the comment matches anything in the code. Fix or delete the crap.

    delayMicroseconds(600); //_delay_us(200); //modify to alter speed

Why? Responsive code NEVER uses delay(). In any fashion!

OK Paul, i delete comment. But still does not work. digitalRead() is not all that fast. Direct port manipulation - does not know how to do this.