Rotary Encoder Incremental rotary Encoder How to use it with Arduino

Поділитися
Вставка
  • Опубліковано 2 січ 2025

КОМЕНТАРІ •

  • @tomc8157
    @tomc8157 3 роки тому +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
    @visionwarecomputervisionre9943 4 роки тому +2

    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.

  • @firekizzz
    @firekizzz Рік тому +1

    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?

  • @andrescarlini2071
    @andrescarlini2071 4 роки тому +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.

  • @jorge-garcia-mateos
    @jorge-garcia-mateos 6 років тому +16

    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 4 роки тому +5

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

    • @jarisipilainen3875
      @jarisipilainen3875 4 роки тому

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

  • @racingaddict3719
    @racingaddict3719 Рік тому

    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

  • @RightlyFree
    @RightlyFree 6 років тому +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 5 років тому

      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 3 роки тому

      how to solve limit counter ? how

    • @bears7777777
      @bears7777777 2 роки тому

      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

  • @chbonnici
    @chbonnici 3 роки тому

    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.

  • @davideronchin6400
    @davideronchin6400 4 роки тому +1

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

  • @edgarbernal801
    @edgarbernal801 4 місяці тому

    Is the reading you are showing in RPM?

  • @tardraker4631
    @tardraker4631 4 роки тому +3

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

    • @angelabreu2676
      @angelabreu2676 5 місяців тому +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 5 місяців тому

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

  • @fernando.liozzi.41878
    @fernando.liozzi.41878 4 роки тому +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 4 роки тому +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.

  • @prateekmusicoffcial
    @prateekmusicoffcial 4 роки тому

    can we calculate accurate angle using this??

  • @ElectroCoderEC
    @ElectroCoderEC 3 роки тому

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

  • @TechIsGods
    @TechIsGods 6 років тому

    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?

  • @shobairbashiri9227
    @shobairbashiri9227 3 роки тому

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

  • @ShahryarNaseem
    @ShahryarNaseem 6 років тому +1

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

    • @RovanRCTube
      @RovanRCTube 6 років тому +2

      //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------------------------

  • @chinzzz345
    @chinzzz345 9 місяців тому

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

  • @erkamarslan3227
    @erkamarslan3227 4 роки тому +1

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

  • @ctlmachine3781
    @ctlmachine3781 6 років тому +1

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

  • @jupryhamzah7661
    @jupryhamzah7661 3 роки тому

    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.

  • @muratcanbarut64
    @muratcanbarut64 5 років тому

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

  • @armaky4962
    @armaky4962 5 місяців тому

    This is spectacular sketch for Arduino Thanks

  • @yusriismail6291
    @yusriismail6291 6 років тому

    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?

  • @highfacility9200
    @highfacility9200 3 роки тому

    Thanks. The only one worked codes on youtube.

  • @tiarakusumadewi2337
    @tiarakusumadewi2337 2 роки тому

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

  • @josephpatterson2722
    @josephpatterson2722 6 років тому

    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.

    • @RovanRCTube
      @RovanRCTube 6 років тому

      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*/

  • @Arun_bly
    @Arun_bly 5 років тому +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 5 років тому +1

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

    • @muratcanbarut64
      @muratcanbarut64 5 років тому

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

    • @ivanpapkin7973
      @ivanpapkin7973 5 років тому

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

  • @luishnk3983
    @luishnk3983 3 роки тому

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

  • @pranashmaharaj
    @pranashmaharaj 3 роки тому +1

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

  • @AnilKumar-jn3ho
    @AnilKumar-jn3ho 3 роки тому

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

  • @bouaslamourad3737
    @bouaslamourad3737 5 місяців тому

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

  • @amsieSY
    @amsieSY 6 років тому +1

    how can we measure length travelled using that encoder?

    • @martijnvenselaar4760
      @martijnvenselaar4760 5 років тому

      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.

  • @sumandriasumandria2253
    @sumandriasumandria2253 Рік тому

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

  • @michalgazdik2957
    @michalgazdik2957 3 роки тому

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

  • @georgealbo
    @georgealbo 2 роки тому

    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

  • @litos92323
    @litos92323 Рік тому

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

  • @shahzarkhan3116
    @shahzarkhan3116 6 років тому

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

  • @hrishieb_Sub
    @hrishieb_Sub Рік тому

    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.

  • @armaky4962
    @armaky4962 5 місяців тому

    Thank You Very Much ! for ilustration "

  • @Mcso103
    @Mcso103 3 роки тому

    Can you control two encoders at once?

  • @RovanRCTube
    @RovanRCTube 6 років тому

    /*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 Рік тому

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

  • @gsusfknchrist
    @gsusfknchrist 4 роки тому

    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 4 роки тому

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

    • @dlob
      @dlob 3 роки тому

      @@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);

  • @pkittoe
    @pkittoe 4 роки тому

    Nice little video, code works a treat. Thanks

  • @eduardocatoc8505
    @eduardocatoc8505 7 років тому

    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  7 років тому

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

    • @eduardocatoc8505
      @eduardocatoc8505 7 років тому +1

      Maker Tutor it's okay :) thanks!

    • @grsh2010
      @grsh2010 6 років тому

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

  • @MEan0207
    @MEan0207 5 років тому

    Where does the rotary Encoder buy?

  • @akshaydalvi538
    @akshaydalvi538 6 років тому +1

    how to calculate rpm from encoder pulses? please help me

  • @internetdinosaur64yearsago
    @internetdinosaur64yearsago 6 років тому

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

  • @AnwarAlfaqeehAlhusseini
    @AnwarAlfaqeehAlhusseini 7 років тому

    do you know how to wiring this encoder with cnc ?

  • @stesamasolides.a.r.l689
    @stesamasolides.a.r.l689 2 роки тому

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

  • @tobiasscheichl
    @tobiasscheichl 6 років тому

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

  • @ghamguibilel6649
    @ghamguibilel6649 6 років тому +1

    can i use this project in unojoy

  • @tiger4565
    @tiger4565 6 років тому

    Can this code stand foe high speed encoder?

  • @brunadelossantos7795
    @brunadelossantos7795 6 років тому +1

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

  • @arduinomaquinas
    @arduinomaquinas Рік тому +1

    Like 1.3 K ❤ 👏👏👏

  • @ie3562
    @ie3562 4 роки тому

    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

  • @raymondcowey1041
    @raymondcowey1041 3 роки тому

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

  • @josechavezz9048
    @josechavezz9048 5 років тому

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

  • @alexismayo9099
    @alexismayo9099 6 років тому

    Hello Bro! What Pin G is used for?

  • @ayutmlnsn
    @ayutmlnsn 4 роки тому

    how about this encorder with esp32?

  • @modellerdesign
    @modellerdesign 6 років тому

    How to open the data inputs information screen please)?

    • @theragavelan
      @theragavelan 6 років тому

      ctr+shift+m

    • @modellerdesign
      @modellerdesign 6 років тому

      @@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. )

  • @alejandrogarciagonzalez1748

    Practico de implementar, gracias.

  • @samiranantes4752
    @samiranantes4752 4 роки тому +1

    very good, help a lot, thank u!

    • @luishnk3983
      @luishnk3983 3 роки тому

      is this code limited 65535?

  • @yamenhazimi2947
    @yamenhazimi2947 6 років тому

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

  • @rochesterrodrigues3785
    @rochesterrodrigues3785 7 місяців тому

    ohhhhhhhhhhhhhhhhhhh 👍👍👍👍👏👏👏👏

  • @tumjaturong3599
    @tumjaturong3599 6 років тому

    how to detect speed of motor by this pls.

  • @illewmenadeh722
    @illewmenadeh722 6 років тому +1

    Works perfectly! Thanks!!!

    • @luishnk3983
      @luishnk3983 3 роки тому

      its limited 65535 ? and dont show negative numbers?

  • @LearnerBoy
    @LearnerBoy 6 років тому

    what details of Arduino please ?

  • @luishnk3983
    @luishnk3983 3 роки тому

    counter limit is 65535 ?! why?

  • @raymondcowey1041
    @raymondcowey1041 4 роки тому +2

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

  • @edrissiahmed6530
    @edrissiahmed6530 4 роки тому

    Thanks for the video and the code

  • @hiteshbhagat3689
    @hiteshbhagat3689 6 років тому

    How to use two encoder in arduino

  • @deark095
    @deark095 6 років тому +1

    Muchas gracias por el aporte (Y)

  • @luishnk3983
    @luishnk3983 3 роки тому

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

  • @유민재-i4v
    @유민재-i4v 6 років тому

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

    • @NikMartin-I-am
      @NikMartin-I-am 6 років тому

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

    • @kmalnasef1512
      @kmalnasef1512 6 років тому +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

    • @RovanRCTube
      @RovanRCTube 6 років тому

      // 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 6 років тому +5

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

  • @michelbitoli1388
    @michelbitoli1388 2 роки тому

    How can i contact with mail adress?

  • @tasso6196
    @tasso6196 3 роки тому

    Tks, it worked!

  • @RovanRCTube
    @RovanRCTube 6 років тому

    my encoder reads 65535 per revolution at 115200 Baud

    • @rolandkuka9987
      @rolandkuka9987 5 років тому

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

  • @aakashdewangan7313
    @aakashdewangan7313 2 роки тому

    Very good

  • @humbertoarias8112
    @humbertoarias8112 5 місяців тому

    thanks a lot!!!!!!

  • @farrukhsiddiqui9265
    @farrukhsiddiqui9265 9 місяців тому

    Hi dear Can you send me Encoder program pictures

  • @cicciofranco405
    @cicciofranco405 6 років тому

    Bellissimo progetto , mi aiuti a realizzarlo ? francesco da Palermo

  • @SandwichMitGurke
    @SandwichMitGurke 6 років тому

    helped a lot, thanks

  • @MsOgneSlav
    @MsOgneSlav 3 роки тому

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

  • @tigreminds27
    @tigreminds27 5 років тому

    excelente..gracias

  • @hillberpassball
    @hillberpassball 5 років тому

    thank you very much

  • @edsonbautista6433
    @edsonbautista6433 6 років тому

    Muchas gracias !!

  • @irsyadsahalan1362
    @irsyadsahalan1362 5 років тому

    Thanks for the code

  • @frankjonathansaenz1911
    @frankjonathansaenz1911 4 роки тому

    Nice.

  • @hanu9213
    @hanu9213 6 років тому

    Thanks ...!!!

  • @ederferreiradossantos4118
    @ederferreiradossantos4118 3 роки тому

    oi boa tarde, eu não conseguir

  • @GuwancHaydarow
    @GuwancHaydarow 2 місяці тому

    Tutcesni vidya ceksene

  • @johnyway-mk6nw
    @johnyway-mk6nw 10 місяців тому

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

  • @georgealbo
    @georgealbo Рік тому

    LPD3806-600BM

  • @luishnk3983
    @luishnk3983 3 роки тому

    65535

  • @lordlemmy5108
    @lordlemmy5108 5 років тому

    The enconder has 600 pulses per channel?