Video není dostupné.
Omlouváme se.

Rotary Encoder Incremental rotary Encoder How to use it with Arduino

Sdílet
Vložit
  • čas přidán 15. 08. 2024
  • Rotary Encoder Incremental rotary Encoder How to use it with Arduino
    Link Sketch download
    goo.gl/s5fV59 ::::::::::: SUPPORT CHANNEL ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    Please Donate To Help Me Afford New Equipment And Software To Make My Videos More : goo.gl/1m8Dg2
    Don't forget to subscribe!

Komentáře • 133

  • @tomc8157
    @tomc8157 Před 2 lety +2

    I just hooked up a 10-30v fairly large encoder, fed the encoder 12v @ 70ma or so and worked like a champ. Shaft is a lot hard than yours to turn but works perfect first try. Counts 1-65k and back down no problem. Thanks for simple and clear video.

  • @visionwarecomputervisionre9943

    In some case, it wont work with board's 5v .. if you want to use the board power ONLY, then you can open it up and short the outer pins of LM7805 (78m05).. Remeber its only if you dont want to use any other external power source.

  • @andrescarlini2071
    @andrescarlini2071 Před 3 lety +2

    Hi Everyone! I´ve tried this code in arduino mega and works just fine. ( I have the same encoder only 360ppr) but when I try ir in arduino leonardo the counter stays around the same number. It starts working when I modify one of the interrupts to FALLING or if i just unplug uno of the pins. But only increments the Value. Does anyone knows what could be the issue. Thanks.

  • @armaky4962
    @armaky4962 Před 16 dny

    This is spectacular sketch for Arduino Thanks

  • @raymondcowey1041
    @raymondcowey1041 Před 3 lety +2

    Why do people think it appropriate to make a technical video with hideous music hammering away in the background and no commentary.

  • @edgarbernal801
    @edgarbernal801 Před 3 dny

    Is the reading you are showing in RPM?

  • @jorge-garcia-mateos
    @jorge-garcia-mateos Před 6 lety +15

    I think the encoder you are using (see 0:14) has 600 pulses per revolution, not 400. Yours is type ...-600BM-... Thanks for the video and the code!

    • @Bartosh.S
      @Bartosh.S Před 4 lety +5

      Also this code is incrementing counter on both phases, so it 1200 pulses per rotation

    • @jarisipilainen3875
      @jarisipilainen3875 Před 3 lety

      is it matter.all is it doing count pulses not revolutions xD

  • @armaky4962
    @armaky4962 Před 16 dny

    Thank You Very Much ! for ilustration "

  • @bouaslamourad3737
    @bouaslamourad3737 Před 15 dny

    Good job .if I went put stepper motor withe encoder how I do that

  • @chinzzz345
    @chinzzz345 Před 4 měsíci

    The encoder detects movement in both directions but loses its reference zero...does anyone knows why?

  • @RightlyFree
    @RightlyFree Před 5 lety +4

    Thank you for sharing this video with us. There is one point to enhance the code: add max and minimum counter limits then flip the counter when reaching the limit such as:
    void countClamp () { // clamp count from QMIN to QMAX:
    if (counter > QMAX) {
    counter = QMIN;
    }
    else if (counter < QMIN) {
    counter = QMAX;
    }
    This function should be verified whenever updating the counter
    I think in your case limits would be
    long temp,counter = 0; //sign should be considered
    #define QMAX 1199
    #define QMIN 0

    • @benrichards1410
      @benrichards1410 Před 5 lety

      Hi A R, looking for some help, would this make the code deal with minus numbers as it currently goes to 65000 something when it passes zero? Any elp would be appreciated, been stuck on this too long. Thanks

    • @luishnk3983
      @luishnk3983 Před 3 lety

      how to solve limit counter ? how

    • @bears7777777
      @bears7777777 Před 2 lety

      Make sure that if you're using velocity as a control input that you also account for the rollover. E.g. if the QMAX was 1000 and it goes from 980 to 20 in one dt timestep, you have to do some math. 1000-(prevCount=980) + (newCount=20) to get the 40 counts that the encoder rotated. Do this in reverse if you hit QMIN. If you don't do this, the counts/dt would be 20-980 which would give a speed of -960counts/dt which will throw off any control loop you may have

  • @davideronchin6400
    @davideronchin6400 Před 3 lety +1

    Anyone knows the max speed readable? I don't think the arduino can read all values if the encoder reaches 5000 rpm

  • @pranashmaharaj
    @pranashmaharaj Před 2 lety +1

    Can you convert the ENCODER FREQ to RPM Function ?Looking forward to another quick video

  • @tardraker4631
    @tardraker4631 Před 4 lety +3

    yo tengo exactamente ese mismo encoder pero mi problema es que solo aumenta, no disminuye, creo que vino con defectos

    • @angelabreu2676
      @angelabreu2676 Před 15 dny +1

      Hola, espero que no haya llegado tarde pero el encoder funciona, lo que pasa es que el codigo tiene deteccion de interrupciones en HIGH cuando deberia ser CHANGE modifica eso y funcionara

    • @tardraker4631
      @tardraker4631 Před 15 dny

      @@angelabreu2676 ya voy para 3 años con mi volante g29 ya que nunca pude resolverlo 😞 pero igual gracias

  • @firekizzz
    @firekizzz Před 10 měsíci

    I have a homemade steering wheel project for games, just like Logitec, but I don't have the sketch to use the encoder, and I also can't load the sketches into the Arduino. what to do?

  • @ctlmachine3781
    @ctlmachine3781 Před 6 lety +1

    can i use this as a masering wheel for Cut to lenth machine

  • @highfacility9200
    @highfacility9200 Před 3 lety

    Thanks. The only one worked codes on youtube.

  • @chbonnici
    @chbonnici Před 2 lety

    I have an AC motor which turns 10 RPM . The motor turns a shaft with a chain . I want to measure and stop the motor when to chain travels 4 meters. Is this possible with this encoder.

  • @fernando.liozzi.41878
    @fernando.liozzi.41878 Před 3 lety +1

    I have exactly the same encoder, it came to me today from Aliexpress and if I don't put pullups on it, it doesn't work for me, I put the outputs on the oscilloscope and I see the signals very very attenuated, with pullups it works very well. What can it be due to, will I have failed? Regards.

    • @fernando.liozzi.41878
      @fernando.liozzi.41878 Před 3 lety +3

      That's it, I'm not using it with Arduino, and I can't activate the internal pullups of the microcontroller, because I have opto-isolated input. The output of this encoder in NPN open collector, that's why I need to put external pull ups resistors. Regards.

  • @ElectroCoderEC
    @ElectroCoderEC Před 3 lety

    If the motor does 3.500 rpm, the encoder 1.000 pulses, does the arduino have enough capacity or are pulses lost? Thks

  • @ShahryarNaseem
    @ShahryarNaseem Před 5 lety +1

    Can you please tell me how would you use this to calculate angle, like the line of code that should be added?

    • @jameselliott9397
      @jameselliott9397 Před 5 lety +1

      //TRY THIS
      // defines pins numbers
      const int stepPin = 10;
      const int dirPin = 11;
      const int enPin = 12;
      float pulsesR = 6400;
      float pulsesL = 6400;
      const int pulsedelay = 0;
      int cycledelay= 20;
      //--------------------ENCODER Variables START-------------------------
      float counter;
      int Left;
      int Right;
      int leftPin = 2;
      int rightPin = 3;
      const int Home = 999;
      float degree;
      //--------------------ENCODER Variables FINISH-------------------------
      void setup() {
      Serial.begin(115200);
      // Sets the two pins as Outputs
      pinMode(6, INPUT_PULLUP);
      pinMode(7, OUTPUT);
      pinMode(4, INPUT_PULLUP);
      pinMode(5, OUTPUT);
      pinMode(stepPin,OUTPUT);
      pinMode(dirPin,OUTPUT);
      pinMode(enPin,OUTPUT);
      digitalWrite(enPin,LOW);
      //--------------------ENCODER Setup START-------------------------
      pinMode(leftPin, INPUT_PULLUP); // internal pullup input pin leftPin
      pinMode(rightPin, INPUT_PULLUP); // internal pullup input pin rightPin
      pinMode(Home,INPUT);
      //Setting up interrupt
      //A rising pulse from encodenren activated ai0(). AttachInterrupt 0 is DigitalPin nr leftPin on moust Arduino.
      attachInterrupt(0, SwingRight, RISING);
      //B rising pulse from encodenren activated ai1(). AttachInterrupt 1 is DigitalPin nr rightPin on moust Arduino.
      attachInterrupt(1, SwingLeft, RISING);
      //--------------------ENCODER Setup FINISH-------------------------
      }
      void loop() {
      //--------------------ENCODER Loop START-------------------------
      degree = counter /2;
      // Send the value of counter
      if( digitalRead (Home) == HIGH ){
      // temp = counter;
      counter = 0;
      Serial.println (degree,0);
      }
      digitalRead(leftPin);
      digitalRead(rightPin);
      //--------------------ENCODER Loop FINISH-------------------------
      int sensorVal6 = digitalRead(6);
      if (sensorVal6 == LOW) {
      digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
      // Makes 200 pulses for making one full cycle rotation
      for(int x = 0; x < pulsesR; x++) {
      digitalWrite(stepPin,HIGH);
      delayMicroseconds(pulsedelay);
      digitalWrite(stepPin,LOW);
      delayMicroseconds(pulsedelay);
      // degree++;
      // Serial.println(degree / 35.55555555555556 ,0);
      digitalWrite(7, HIGH);
      }
      } else {
      digitalWrite(7, LOW);
      delay (50);
      }
      delay(cycledelay);
      delay(cycledelay); // One second delay
      int sensorVal4 = digitalRead(4);
      if (sensorVal4 == LOW) {
      digitalWrite(dirPin,LOW); //Changes the rotations direction
      // Makes 400 pulses for making two full cycle rotation
      for(int x = 0; x < pulsesL; x++) {
      digitalWrite(stepPin,HIGH);
      delayMicroseconds(pulsedelay);
      digitalWrite(stepPin,LOW);
      delayMicroseconds(pulsedelay);
      // degree--;
      // Serial.println(degree/ 35.55555555555556,0);
      digitalWrite(5, HIGH);
      }
      } else {
      digitalWrite(5, LOW);
      }
      delay(cycledelay);
      }
      //--------------------ENCODER SwingRight Interrupt START------------------------
      void SwingRight() {
      // ai0 is activated if DigitalPin nr leftPin is going from LOW to HIGH
      // Check pin rightPin to determine the direction
      if(digitalRead(rightPin)==LOW + LOW + HIGH) {
      counter--;
      Serial.print(" SwingingRight at ");
      Serial.println (degree,0);
      Right = degree;
      }else{
      counter++;
      }
      }
      //--------------------ENCODER SwingRight Interrupt FINISH------------------------
      //--------------------ENCODER SwingLeft Interrupt START------------------------
      void SwingLeft() {
      // ai0 is activated if DigitalPin nr rightPin is going from LOW to HIGH
      // Check with pin leftPin to determine the direction
      if(digitalRead(leftPin)==LOW + LOW + HIGH) {
      counter++;
      Serial.print("SwingingLeft at ");
      Serial.println (degree,0);
      Left = degree;
      }else{
      counter--;
      }
      }
      //--------------------ENCODER Swingleft INterrupt FINISH------------------------

  • @arduinomaquinas
    @arduinomaquinas Před rokem +1

    Like 1.3 K ❤ 👏👏👏

  • @shobairbashiri9227
    @shobairbashiri9227 Před 2 lety

    you programmed it with rising edge on each pins A and B right?

  • @racingaddict3719
    @racingaddict3719 Před rokem

    Hi does it work? With arduino leonardo, i´ve uploaded the code and connected the wired scheme and in the monitor shows 1 2 and when i turn the encoder it doesnt go to 50

  • @techisgod
    @techisgod Před 6 lety

    My homemade Six Digit, 20MHz, CD74HC192 Up-Down counter circuit counts Quadrature Encoder pulses at 20Mhz speeds. And seems to be many times faster than using my PIC16F887 microcontrollers.
    Can you tell me why?

  • @jupryhamzah7661
    @jupryhamzah7661 Před 2 lety

    HI Maker Tutor, i brought Rotary Encoder HQK38H6-600N-G5-24 form china use your Sketch the problem is the encoder reading always increment if i turn forward or backwards the staff.

  • @georgealbo
    @georgealbo Před rokem

    thank you for this video but i want to read this value and control a DC motor with the same value so the encoder and the motor have the same speed
    thanks

  • @muratcanbarut64
    @muratcanbarut64 Před 4 lety

    Hello, what if I want see negative numbers want to see, what should I change in code ? ,thank you.

  • @luishnk3983
    @luishnk3983 Před 3 lety

    hi. i have e38s65 400b g24n rotary encoder 5v-24v it is not work with arduino routary encoder code. how can i solve ?

  • @tiarakusumadewi2337
    @tiarakusumadewi2337 Před rokem

    Hi, Sir. can we use raspberry pi pico to read the incremental rotary encoder?

  • @rochesterrodrigues3785
    @rochesterrodrigues3785 Před 2 měsíci

    ohhhhhhhhhhhhhhhhhhh 👍👍👍👍👏👏👏👏

  • @yusriismail6291
    @yusriismail6291 Před 6 lety

    I need, can you help. i want to make a long cloth.between 1 meter to 10 meter.so how to do the code and use the suitable rotary encoder?

  • @pkittoe
    @pkittoe Před 3 lety

    Nice little video, code works a treat. Thanks

  • @sumandriasumandria2253

    May I know what type arduino u used?thanks.GBU

  • @litos92323
    @litos92323 Před 10 měsíci

    Hi, great project. Do you know about the maximum frecuency reading of arduino

  • @AnilKumar-jn3ho
    @AnilKumar-jn3ho Před 2 lety

    What is the software used to view the results mam in your pc

  • @shahzarkhan3116
    @shahzarkhan3116 Před 5 lety

    I want to move it to specific number of turn and want to control position of quadrature encoder motor using coding

  • @ie3562
    @ie3562 Před 4 lety

    Excellent video
    Can the out put of the Arduino Uno be given to an display unit. IF so please make a video on it.
    Muchas gracious from India

  • @prateekmusicoffcial
    @prateekmusicoffcial Před 4 lety

    can we calculate accurate angle using this??

  • @erkamarslan3227
    @erkamarslan3227 Před 3 lety +1

    Is it possible to have a design that will allow the incremental encoder to act like an absolute encoder?

  • @brunadelossantos7795
    @brunadelossantos7795 Před 5 lety +1

    Hola,pueden compartir ese codigo para contar pulsos de encoder rotativo?

  • @michalgazdik2957
    @michalgazdik2957 Před 3 lety

    do you have the code to connect to the lcd display with this type of encoder?

  • @hrishieb_Sub
    @hrishieb_Sub Před rokem

    Hi
    Has anyone tried to do the same with a jetson nano or raspberry pi for the same model of the encoder ? If yes then please share the code.

  • @Arun_bly
    @Arun_bly Před 5 lety +1

    @maker tutor , i am having problem that when i rotate it in anti clock wise direction it shows 65535, kindly tell me how to resolve that issue.

    • @rolandkuka9987
      @rolandkuka9987 Před 5 lety +1

      I has the same problem. Change variable type from int(int stores a 16-bit) to long (32-bit).

    • @muratcanbarut64
      @muratcanbarut64 Před 4 lety

      volatile unsigned int temp, counter = 0 ,what should I write to do it ??? thanks

    • @ivanpapkin7973
      @ivanpapkin7973 Před 4 lety

      @@muratcanbarut64 You figured it out I myself can’t understand?

  • @josephpatterson2722
    @josephpatterson2722 Před 6 lety

    I have an encoder very similar to this one, having no luck writing a code to do what I need, can you help. I want to use a timing belt and sprocket to measure how far the belt moves (with extreme accuracy) and display on a LCD display.

    • @jameselliott9397
      @jameselliott9397 Před 6 lety

      float temp;
      int counter = 0;
      int statePrevious;
      boolean stateLeft;
      boolean stateRight;
      int setLeft;
      int setRight;
      int Led7=7;
      int Led8=8;
      // volatile unsigned int temp, counter = 0; //This variable will increase or decrease depending on the rotation of encoder
      void setup() {
      Serial.begin (115200);
      pinMode(2, INPUT_PULLUP); // internal pullup input pin 2
      pinMode(3, INPUT_PULLUP); // internal pullup input pin 3
      pinMode(Led7, OUTPUT);
      pinMode(Led8, OUTPUT);
      //Setting up interrupt
      //A rising pulse from encodenren activated ai0(). AttachInterrupt 0 is DigitalPin nr 2 on moust Arduino.
      attachInterrupt(0, ai0, RISING);
      //B rising pulse from encodenren activated ai1(). AttachInterrupt 1 is DigitalPin nr 3 on moust Arduino.
      attachInterrupt(1, ai1, RISING);
      }
      void loop() {
      // Send the value of counter
      if( counter != temp ){
      temp = counter;
      }
      }
      void ai0() {
      // ai0 is activated if DigitalPin nr 2 is going from LOW to HIGH
      // Check pin 3 to determine the direction
      if(digitalRead(3)==LOW) {
      stateRight = true;
      stateLeft = false;
      if (stateRight == true && stateLeft == false) {
      Serial.println ("Going Right ");
      setLeft = counter - counter - counter + 1;
      Serial.println (temp,0);
      Serial.print (" Set left to ");
      Serial.println (setLeft);
      digitalWrite (Led7, HIGH);
      digitalWrite (Led8, LOW);
      // send stepper to last (setLeft);
      }
      counter--;
      }else{
      counter++;
      }
      }
      void ai1() {
      // ai0 is activated if DigitalPin nr 3 is going from LOW to HIGH
      // Check with pin 2 to determine the direction
      if(digitalRead(2)==LOW) {
      stateRight = false;
      stateLeft = true;
      if (stateRight == false && stateLeft == true) {
      Serial.println ("Going Left ");
      setRight = counter - counter - counter - 1 ;
      Serial.println (temp,0);
      Serial.print (" Set Right to ");
      Serial.println (setRight);
      digitalWrite (Led7, LOW);
      digitalWrite (Led8, HIGH);
      // send stepper to last (setLeft);
      }
      counter++;
      }else{
      counter--;
      }
      }/*change detection
      rotary encoder type LPD3806-360BM-G5-24C
      J733 purchased on ebay*/

  • @josechavezz9048
    @josechavezz9048 Před 5 lety

    Ese motor de paso y encodet se puede conectar a un driver híbrido,para motor de paso y encoder.

  • @Mcso103
    @Mcso103 Před 3 lety

    Can you control two encoders at once?

  • @amsieSY
    @amsieSY Před 5 lety +1

    how can we measure length travelled using that encoder?

    • @martijnvenselaar4760
      @martijnvenselaar4760 Před 4 lety

      2*pi*radius gives you the length traveled in a whole revolution (radius = outer radius of pulley attached to the axis of the encoder for example).
      Devide this length by the number of pulses per revolution, in this case 400. Now you now your displacement per pulse.

  • @MEan0207
    @MEan0207 Před 5 lety

    Where does the rotary Encoder buy?

  • @ghamguibilel6649
    @ghamguibilel6649 Před 5 lety +1

    can i use this project in unojoy

  • @alejandrogarciagonzalez1748
    @alejandrogarciagonzalez1748 Před 11 měsíci

    Practico de implementar, gracias.

  • @humbertoarias8112
    @humbertoarias8112 Před měsícem

    thanks a lot!!!!!!

  • @lordlemmy5108
    @lordlemmy5108 Před 4 lety

    The enconder has 600 pulses per channel?

  • @stesamasolides.a.r.l689

    Bonjour, j'ai un code de 1200, je veux convertir en 360, puis-je avoir un code

  • @deark095
    @deark095 Před 6 lety +1

    Muchas gracias por el aporte (Y)

  • @illewmenadeh722
    @illewmenadeh722 Před 5 lety +1

    Works perfectly! Thanks!!!

    • @luishnk3983
      @luishnk3983 Před 3 lety

      its limited 65535 ? and dont show negative numbers?

  • @internetdinosaur64yearsago

    Can I use this code for arduino Leonardo r3? Help please

  • @samiranantes4752
    @samiranantes4752 Před 4 lety +1

    very good, help a lot, thank u!

  • @AnwarAlfaqeehAlhusseini

    do you know how to wiring this encoder with cnc ?

  • @edrissiahmed6530
    @edrissiahmed6530 Před 4 lety

    Thanks for the video and the code

  • @tasso6196
    @tasso6196 Před 3 lety

    Tks, it worked!

  • @tobiasscheichl
    @tobiasscheichl Před 6 lety

    does anyone know how to use two rotary encoders with this code??

  • @akshaydalvi538
    @akshaydalvi538 Před 5 lety +1

    how to calculate rpm from encoder pulses? please help me

  • @aakashdewangan7313
    @aakashdewangan7313 Před 2 lety

    Very good

  • @raymondcowey1041
    @raymondcowey1041 Před 3 lety

    Wow, until I watched this video, I had no idea how to plug four wires into an Arduino

  • @SandwichMitGurke
    @SandwichMitGurke Před 6 lety

    helped a lot, thanks

  • @tiger4565
    @tiger4565 Před 6 lety

    Can this code stand foe high speed encoder?

  • @gsusfknchrist
    @gsusfknchrist Před 4 lety

    used ur code and the same ecoder, but getting wrong result. with one step i get both signals(+ and _) and result is like 1-0-1-0-1-0-1-0-1..... if i detach one logic pin i get only one direction of counting no matter of direction of rotation. it counts impulses correctly but only pluses or only minuses. cant understand why does it do this way...((

    • @andrescarlini2071
      @andrescarlini2071 Před 3 lety

      It happened the same to me but only in Leonardo. In Mega works fine. Dont know why...

    • @dlob
      @dlob Před 3 lety

      @@andrescarlini2071 you have to change the code, see www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/
      attachInterrupt(digitalPinToInterrupt(2), ai0, RISING);
      attachInterrupt(digitalPinToInterrupt(3), ai1, RISING);

  • @jameselliott9397
    @jameselliott9397 Před 5 lety

    /*I have been trying to these encoders to read oscillations left to right of a pendulum. I have tried interrupts, switch states and every type of code I can think of. I can get reading from center of zero and - to the left , + to right, but cannot get it to return to zero. It drifts one way or the other. Does anyone have a sketch I can try? Here is an example sketch I pulled out the Stepper code. */
    // defines pins numbers
    const int stepPin = 10;
    const int dirPin = 11;
    const int enPin = 12;
    float pulsesR = 6400;
    float pulsesL = 6400;
    const int pulsedelay = 0;
    int cycledelay= 20;
    //--------------------ENCODER Variables START-------------------------
    float counter;
    int Left;
    int Right;
    int leftPin = 2;
    int rightPin = 3;
    const int Home = 999;
    float degree;
    //--------------------ENCODER Variables FINISH-------------------------
    void setup() {
    Serial.begin(115200);
    // Sets the two pins as Outputs
    pinMode(6, INPUT_PULLUP);
    pinMode(7, OUTPUT);
    pinMode(4, INPUT_PULLUP);
    pinMode(5, OUTPUT);
    pinMode(stepPin,OUTPUT);
    pinMode(dirPin,OUTPUT);
    pinMode(enPin,OUTPUT);
    digitalWrite(enPin,LOW);
    //--------------------ENCODER Setup START-------------------------
    pinMode(leftPin, INPUT_PULLUP); // internal pullup input pin leftPin
    pinMode(rightPin, INPUT_PULLUP); // internal pullup input pin rightPin
    pinMode(Home,INPUT);
    //Setting up interrupt
    //A rising pulse from encodenren activated ai0(). AttachInterrupt 0 is DigitalPin nr leftPin on moust Arduino.
    attachInterrupt(0, SwingRight, RISING);
    //B rising pulse from encodenren activated ai1(). AttachInterrupt 1 is DigitalPin nr rightPin on moust Arduino.
    attachInterrupt(1, SwingLeft, RISING);
    //--------------------ENCODER Setup FINISH-------------------------
    }
    void loop() {
    //--------------------ENCODER Loop START-------------------------
    degree = counter /2;
    // Send the value of counter
    if( digitalRead (Home) == HIGH ){
    // temp = counter;
    counter = 0;
    Serial.println (degree,0);
    }
    digitalRead(leftPin);
    digitalRead(rightPin);
    //--------------------ENCODER Loop FINISH-------------------------
    int sensorVal6 = digitalRead(6);
    if (sensorVal6 == LOW) {
    digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
    // Makes 200 pulses for making one full cycle rotation
    for(int x = 0; x < pulsesR; x++) {
    digitalWrite(stepPin,HIGH);
    delayMicroseconds(pulsedelay);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(pulsedelay);
    // degree++;
    // Serial.println(degree / 35.55555555555556 ,0);
    digitalWrite(7, HIGH);
    }
    } else {
    digitalWrite(7, LOW);
    delay (50);
    }
    delay(cycledelay);
    delay(cycledelay); // One second delay
    int sensorVal4 = digitalRead(4);
    if (sensorVal4 == LOW) {
    digitalWrite(dirPin,LOW); //Changes the rotations direction
    // Makes 400 pulses for making two full cycle rotation
    for(int x = 0; x < pulsesL; x++) {
    digitalWrite(stepPin,HIGH);
    delayMicroseconds(pulsedelay);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(pulsedelay);
    // degree--;
    // Serial.println(degree/ 35.55555555555556,0);
    digitalWrite(5, HIGH);
    }
    } else {
    digitalWrite(5, LOW);
    }
    delay(cycledelay);
    }
    //--------------------ENCODER SwingRight Interrupt START------------------------
    void SwingRight() {
    // ai0 is activated if DigitalPin nr leftPin is going from LOW to HIGH
    // Check pin rightPin to determine the direction
    if(digitalRead(rightPin)==LOW + LOW + HIGH) {
    counter--;
    Serial.print(" SwingingRight at ");
    Serial.println (degree,0);
    Right = degree;
    }else{
    counter++;
    }
    }
    //--------------------ENCODER SwingRight Interrupt FINISH------------------------
    //--------------------ENCODER SwingLeft Interrupt START------------------------
    void SwingLeft() {
    // ai0 is activated if DigitalPin nr rightPin is going from LOW to HIGH
    // Check with pin leftPin to determine the direction
    if(digitalRead(leftPin)==LOW + LOW + HIGH) {
    counter++;
    Serial.print("SwingingLeft at ");
    Serial.println (degree,0);
    Left = degree;
    }else{
    counter--;
    }
    }
    //--------------------ENCODER Swingleft INterrupt FINISH------------------------

    • @ebersontomazelli9192
      @ebersontomazelli9192 Před rokem

      Hello.. I'm having the same issue. Have you find the solucion ? If yes let me know

  • @eduardocatoc8505
    @eduardocatoc8505 Před 6 lety

    Can it keep up with a stepper motor running at 30000 mm/min? I would like to use it in high speed gcode application

    • @MakerTutor101
      @MakerTutor101  Před 6 lety

      This rotary encoder can running at 6,000 rpm , convert from rpm to mm/min I don't know sorry

    • @eduardocatoc8505
      @eduardocatoc8505 Před 6 lety +1

      Maker Tutor it's okay :) thanks!

    • @grsh2010
      @grsh2010 Před 6 lety

      Do you know what encoder this is Brand and Serial Number Please
      or a link to where i can buy it =)

  • @yamenhazimi2947
    @yamenhazimi2947 Před 6 lety

    thanks for the video.
    but how can i use encoder to meassure angular speed?
    any ideas????????

  • @hillberpassball
    @hillberpassball Před 5 lety

    thank you very much

  • @tigreminds27
    @tigreminds27 Před 4 lety

    excelente..gracias

  • @farrukhsiddiqui9265
    @farrukhsiddiqui9265 Před 5 měsíci

    Hi dear Can you send me Encoder program pictures

  • @edsonbautista6433
    @edsonbautista6433 Před 5 lety

    Muchas gracias !!

  • @irsyadsahalan1362
    @irsyadsahalan1362 Před 5 lety

    Thanks for the code

  • @ayutmlnsn
    @ayutmlnsn Před 3 lety

    how about this encorder with esp32?

  • @tumjaturong3599
    @tumjaturong3599 Před 6 lety

    how to detect speed of motor by this pls.

  • @LearnerBoy
    @LearnerBoy Před 5 lety

    what details of Arduino please ?

  • @frankjonathansaenz1911

    Nice.

  • @luishnk3983
    @luishnk3983 Před 3 lety

    counter limit is 65535 ?! why?

  • @luishnk3983
    @luishnk3983 Před 3 lety

    no no your code is working . but how can i have negative numbers?

  • @MsOgneSlav
    @MsOgneSlav Před 3 lety

    Круто, работает!

  • @hiteshbhagat3689
    @hiteshbhagat3689 Před 5 lety

    How to use two encoder in arduino

  • @hanu9213
    @hanu9213 Před 5 lety

    Thanks ...!!!

  • @alexismayo9099
    @alexismayo9099 Před 5 lety

    Hello Bro! What Pin G is used for?

  • @cicciofranco405
    @cicciofranco405 Před 6 lety

    Bellissimo progetto , mi aiuti a realizzarlo ? francesco da Palermo

  • @michelbitoli1388
    @michelbitoli1388 Před 2 lety

    How can i contact with mail adress?

  • @modellerdesign
    @modellerdesign Před 5 lety

    How to open the data inputs information screen please)?

    • @theragavelan
      @theragavelan Před 5 lety

      ctr+shift+m

    • @modellerdesign
      @modellerdesign Před 5 lety

      @@theragavelan Yeah, I've got that. That encoders should have separate 12V power suplly to work. And that's why I asked that couse that showed some wrong thingies in that screen with defolt 5v from arduino. So was wondered if that a right one. )

  • @user-gg4ng1rr8f
    @user-gg4ng1rr8f Před 6 lety

    400P/R is how many can divide angles ? can use for 0.01 degree ?

    • @NikMartin-I-am
      @NikMartin-I-am Před 6 lety

      365/400 = .9 deg/pulse, so no?

    • @kmalnasef1512
      @kmalnasef1512 Před 6 lety +1

      yes
      0.01 deg means you need 360 * 100 pulses then you need 36000 puls.
      that's mean you need 36000 / 400 = 90 encoder revelution per one turn of the motor shaft.
      so use gears to make this posible and you will get 0.01 degree per puls

    • @jameselliott9397
      @jameselliott9397 Před 5 lety

      // defines pins numbers
      const int stepPin = 10;
      const int dirPin = 11;
      const int enPin = 12;
      float pulsesR = 6400;
      float pulsesL = 6400;
      const int pulsedelay = 0;
      int cycledelay= 20;
      //--------------------ENCODER Variables START-------------------------
      float counter;
      int Left;
      int Right;
      int leftPin = 2;
      int rightPin = 3;
      const int Home = 999;
      float degree;
      //--------------------ENCODER Variables FINISH-------------------------
      void setup() {
      Serial.begin(115200);
      // Sets the two pins as Outputs
      pinMode(6, INPUT_PULLUP);
      pinMode(7, OUTPUT);
      pinMode(4, INPUT_PULLUP);
      pinMode(5, OUTPUT);
      pinMode(stepPin,OUTPUT);
      pinMode(dirPin,OUTPUT);
      pinMode(enPin,OUTPUT);
      digitalWrite(enPin,LOW);
      //--------------------ENCODER Setup START-------------------------
      pinMode(leftPin, INPUT_PULLUP); // internal pullup input pin leftPin
      pinMode(rightPin, INPUT_PULLUP); // internal pullup input pin rightPin
      pinMode(Home,INPUT);
      //Setting up interrupt
      //A rising pulse from encodenren activated ai0(). AttachInterrupt 0 is DigitalPin nr leftPin on moust Arduino.
      attachInterrupt(0, SwingRight, RISING);
      //B rising pulse from encodenren activated ai1(). AttachInterrupt 1 is DigitalPin nr rightPin on moust Arduino.
      attachInterrupt(1, SwingLeft, RISING);
      //--------------------ENCODER Setup FINISH-------------------------
      }
      void loop() {
      //--------------------ENCODER Loop START-------------------------
      degree = counter /2;
      // Send the value of counter
      if( digitalRead (Home) == HIGH ){
      // temp = counter;
      counter = 0;
      Serial.println (degree,0);
      }
      digitalRead(leftPin);
      digitalRead(rightPin);
      //--------------------ENCODER Loop FINISH-------------------------
      int sensorVal6 = digitalRead(6);
      if (sensorVal6 == LOW) {
      digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
      // Makes 200 pulses for making one full cycle rotation
      for(int x = 0; x < pulsesR; x++) {
      digitalWrite(stepPin,HIGH);
      delayMicroseconds(pulsedelay);
      digitalWrite(stepPin,LOW);
      delayMicroseconds(pulsedelay);
      // degree++;
      // Serial.println(degree / 35.55555555555556 ,0);
      digitalWrite(7, HIGH);
      }
      } else {
      digitalWrite(7, LOW);
      delay (50);
      }
      delay(cycledelay);
      delay(cycledelay); // One second delay
      int sensorVal4 = digitalRead(4);
      if (sensorVal4 == LOW) {
      digitalWrite(dirPin,LOW); //Changes the rotations direction
      // Makes 400 pulses for making two full cycle rotation
      for(int x = 0; x < pulsesL; x++) {
      digitalWrite(stepPin,HIGH);
      delayMicroseconds(pulsedelay);
      digitalWrite(stepPin,LOW);
      delayMicroseconds(pulsedelay);
      // degree--;
      // Serial.println(degree/ 35.55555555555556,0);
      digitalWrite(5, HIGH);
      }
      } else {
      digitalWrite(5, LOW);
      }
      delay(cycledelay);
      }
      //--------------------ENCODER SwingRight Interrupt START------------------------
      void SwingRight() {
      // ai0 is activated if DigitalPin nr leftPin is going from LOW to HIGH
      // Check pin rightPin to determine the direction
      if(digitalRead(rightPin)==LOW + LOW + HIGH) {
      counter--;
      Serial.print(" SwingingRight at ");
      Serial.println (degree,0);
      Right = degree;
      }else{
      counter++;
      }
      }
      //--------------------ENCODER SwingRight Interrupt FINISH------------------------
      //--------------------ENCODER SwingLeft Interrupt START------------------------
      void SwingLeft() {
      // ai0 is activated if DigitalPin nr rightPin is going from LOW to HIGH
      // Check with pin leftPin to determine the direction
      if(digitalRead(leftPin)==LOW + LOW + HIGH) {
      counter++;
      Serial.print("SwingingLeft at ");
      Serial.println (degree,0);
      Left = degree;
      }else{
      counter--;
      }
      }
      //--------------------ENCODER Swingleft INterrupt FINISH------------------------

  • @rodstartube
    @rodstartube Před 6 lety +5

    i'm confused: that ugly hand is not a girl's hand

  • @georgealbo
    @georgealbo Před rokem

    LPD3806-600BM

  • @ederferreiradossantos4118

    oi boa tarde, eu não conseguir

  • @jameselliott9397
    @jameselliott9397 Před 5 lety

    my encoder reads 65535 per revolution at 115200 Baud

    • @rolandkuka9987
      @rolandkuka9987 Před 5 lety

      I has the same problem. Change variable type from int(int stores a 16-bit) to long (32-bit).

  • @johnyway-mk6nw
    @johnyway-mk6nw Před 6 měsíci

    O conteúdo é relevante mas veja no mudo porq a música é um lixo

  • @luishnk3983
    @luishnk3983 Před 3 lety

    65535