Hands On Arduino 2: Incremental Encoders, Part 1

Поделиться
HTML-код
  • Опубликовано: 13 янв 2025

Комментарии • 35

  • @qcnck2776
    @qcnck2776 2 года назад

    Looking at this in 2022: it is still the best in depth lecture series. Thank you for this gem of a video series.

  • @beehive808
    @beehive808 10 лет назад

    DR Paz Great Video. Right now my head is trying to decode the 1x,2x,4x. I can’t wait for the next video

  • @Olavotemrazaodenovo
    @Olavotemrazaodenovo 5 лет назад

    Congratulations from Brazil.

  • @BetulKaplan
    @BetulKaplan 6 лет назад

    man! you are so good at explaining!

  • @bo88ex
    @bo88ex 9 лет назад

    I liked this video and had good fun to see those hardware shown in one third of the pixel :-I)

  • @PedroAkaki
    @PedroAkaki 8 лет назад

    Best fucking class, thank you mate. You're helping me at a final project for graduating in mechatronics. TY!

  • @DrZAP42
    @DrZAP42  9 лет назад +1

    Frank. You have a couple of things going. First, are you using the encoder on a dc motor, or on the Stepper motor you supplied the link for? If you are using a stepper, you don't need the encoder. The encoder, if properly installed should work just like the encoders used in these demonstrations. The only thing you will need to keep track of is the number of pulses per revolution that you need to convert pulse transitions into degrees.

  • @olvaar
    @olvaar 9 лет назад

    Nice video, specially that array. I tried it, but hated the if's to determine the state.
    I renumbered your table to 11 being 3, 10 being 2, 00 being 1 and 01 being 1
    I adjusted the array accordingly.
    For the state, I read portd, divide it by 8 and mask it (and) with 3 (in one line ;)
    speeds it up a little more.

  • @hosseinhayati9820
    @hosseinhayati9820 9 лет назад

    Nice about the mentioning information security. Bravo :)

  • @tomc8157
    @tomc8157 2 года назад

    So I have an incremental linear encoder spiting out serial data, 0 to 64k and rolls over back to zero again. It's stiff so it goes slow counting. My encoder has a 30ppr. I'm confused on what that means for that 0-64k. I'm trying to use it to get distance and or speed.

  • @dariorodriguez4033
    @dariorodriguez4033 8 лет назад

    Hey, very good video, could you give some advice to implement your code to control the position of the motor, I.e. the motor is moving and an specific number of pulses (counter) it stops.

  • @restonjesus
    @restonjesus 6 лет назад

    I try to control the speed of dc motor with pwm by sensing of encoder. I got some idea from your video. Thanks so much.

  • @abdallahgoda3977
    @abdallahgoda3977 9 лет назад

    Very Helpful , Thank you very much :D

  • @pamelapatrick8675
    @pamelapatrick8675 9 лет назад

    Thank you so much, this was very helpful.

  • @tdo1GU
    @tdo1GU 9 лет назад +1

    Instead of Achange and Bchange, can I combine them into one ABchange because the content of the ISR is the same?

    • @mihir777
      @mihir777 8 лет назад

      +Thanh Do Good question. Did you figure it out?

  • @beehive808
    @beehive808 10 лет назад

    Dr Paz I tried to down load the lecture slides but, the server at control.nmsu.edu can't be found, because the DNS lookup failed. I know the slides have more information. How can I get a copy of the lecture slides. Please??

    • @DrZAP42
      @DrZAP42  10 лет назад

      The link has been fixed.

  • @Warndog9
    @Warndog9 10 лет назад

    One idea is to add in a condition for state changes such as state 0 to 2. or state 3 to 1. Since theres no logical way for these transitions to happen it indicates a missed step count. at which point you could detect the miss and indicate a fault scenario. Would be very usefull for things where tracking is critical (ie cnc dimensional tracking)

    • @DrZAP42
      @DrZAP42  10 лет назад

      Agreed. The issue of error detection and correction is the topic of a separate lecture itself!

  • @amithbsc7451
    @amithbsc7451 3 года назад

    where can i learn embeded system as a diploma?

  • @CB-kt7qd
    @CB-kt7qd 7 лет назад

    Can you please provide us the link to the presentation?
    Thanks

    • @Dr.Stein99
      @Dr.Stein99 7 лет назад

      The youtube video is a presentation. Copy that.

  • @wiscokiddd
    @wiscokiddd 8 лет назад

    Oh man, bummer, I was hoping I could some how just hook the 4 wires from the encoder on the motor and the two wires to the little PM Motor up to the adruino and maybe a motor driver, shoot some code into it from the hip and presto! "Not so Grass Hopper", says Robert, "spend two hours with me and I'll give you a simple introduction to it all", I might have to watch the whole two episodes yet...

  • @RovanRCTube
    @RovanRCTube 6 лет назад

    // good 360 degree reading// rotary encoder type LPD3806-360BM-G5-24C //J733long float temp;
    int counter = 0;
    // volatile unsigned int temp, counter = 0; //This variable will increase or decrease depending on the rotation of encoder
    void setup() {
    Serial.begin (9600);
    pinMode(2, INPUT_PULLUP); // internal pullup input pin 2
    pinMode(3, INPUT_PULLUP); // internalเป็น pullup input pin 3//Setting up interrupt
    //A rising pulse from encodenren activated ai0(). AttachInterrupt 0 is DigitalPin nr 2 Arduino.
    attachInterrupt(0, ai0, RISING);
    //B rising pulse from encodenren activated ai1(). AttachInterrupt 1 is DigitalPin nr 3 Arduino.
    attachInterrupt(1, ai1, RISING);
    }
    void loop() {
    // Send the value of counter
    if( counter != temp ){
    Serial.println (temp/2,0);
    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) {
    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) {
    counter--;
    }else{
    counter++;
    }
    }

  • @eduardotobarjaque7758
    @eduardotobarjaque7758 10 лет назад

    amazing, thanks

  • @abpccpba
    @abpccpba 9 лет назад

    I would like to go on and watch but for some reason I can not handle the format you have chosen.

  • @RovanRCTube
    @RovanRCTube 6 лет назад

    Making Progress on my code. I am a newbie. Still cannot get Robert's awesome Codes to work. I set up a pendulum to test this...// change detection
    // rotary encoder type LPD3806-360BM-G5-24C
    //J733long 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 (setRight);
    }
    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--;
    }
    }

  • @undeadlich1
    @undeadlich1 9 лет назад

    thank you:)

  • @localbroadcast
    @localbroadcast 9 лет назад

    shoulda talked about revolvers instead of potentiometers.... revolvers are a much better analogue example

  • @blue_name_warrior
    @blue_name_warrior 5 лет назад

    fine explained video but bad code, just use FALLING and RISING state to determin, and waste too much time in the 'pulling' way

  • @tcurdt
    @tcurdt 8 лет назад

    That's not what volatile means. en.wikipedia.org/wiki/Volatile_(computer_programming)

  • @TechTomVideo
    @TechTomVideo 7 лет назад

    Booooring... could have be done in 20 minutes....