Pages: [1]   Go Down
Author Topic: fatal error: delay.h: No such file or directory  (Read 1091 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
The program that runs on the Arduino mini nice work.
On the duo writes me: Fatal Error: delay.h: No such file or directory
Does anyone know what is the replacement for
# include <delay.h>
volatile long motor_position, encoder;

Please reply.








Logged

Offline Offline
Sr. Member
****
Karma: 16
Posts: 453
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The "Arduino Due" ?
Not all libraries for the normal Arduino boards work on the Arduino Due.
Which library are you using ?
Logged

Offline Offline
Sr. Member
****
Karma: 16
Posts: 453
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The "delay.h" is needed for "_delay_us".
If you use the Arduino function "delayMicroseconds" you can remove the "delay.h".
Logged

Offline Offline
Sr. Member
****
Karma: 16
Posts: 453
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Do not include that.
Logged

Offline Offline
Sr. Member
****
Karma: 16
Posts: 453
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Remove this: #include <delay.h>
Keep this: volatile long motor_position, encoder;
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Peter,
yes i to change is the numbers in those attachInterrupt lines.I had also to change in/out pin.
However, I have the same problem as before. At a higher speed encoder stepper motor slow work.
 If encoder slowly move work ok. There is no error in the Arduino mini but in the program.
 Can you help me how can I fix the error that signals from encoder fast read and sent to the stepper motor.
This is new code
Code:
#define encoder_a 22 //keep this on and interrupt pin
#define encoder_b 23 //keep this on and interrupt pin
#define motor_step 53 //can be any pin
#define motor_direction 52 //can be any pin

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(22, encoderPinChangeA, CHANGE);
  // encoder pin on interrupt 1 (pin 3)
  attachInterrupt(23, 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++;
  }
 }
Logged

Pages: [1]   Go Up
Jump to: