How to stepper motor control with driver TB6560 and Arduino Rotary Encoder

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 ก.พ. 2025

ความคิดเห็น • 99

  • @DuyVu-dn8ss
    @DuyVu-dn8ss 2 ปีที่แล้ว +1

    I only have the microstep driver DM542-05. Does it still work?

    • @DIYInkJet
      @DIYInkJet  2 ปีที่แล้ว

      yes no problem

    • @DuyVu-dn8ss
      @DuyVu-dn8ss 2 ปีที่แล้ว +1

      @@DIYInkJet It means I tried your project. As the result, everything is the same except the driver that I mentioned above. However, it did not work.

    • @DIYInkJet
      @DIYInkJet  2 ปีที่แล้ว

      @@DuyVu-dn8ss maybe you connected the wrong driver.

  • @msr2363
    @msr2363 5 ปีที่แล้ว +6

    #define pha_a 2 // pin 2 on UNO is connected to phase a encoder
    #define pha_b 3 // pin 3 on UNO is connected to phase b encoder
    #define step_CLK 9 // pin 9 on UNO is connected to the CLK pin of TB6560
    #define dir_CW 10 // pin 10 on UNO is connected to the CLK pin of TB6560
    #define pin_EN 11 // pin 11 on UNO is connected to the CLK pin of TB6560
    static boolean rotating=false;
    volatile long motor_position,encoder;
    boolean A_set = false;
    boolean B_set = false;
    void setup() {
    pinMode(step_CLK,OUTPUT);
    pinMode(dir_CW, OUTPUT);
    pinMode(pin_EN, OUTPUT);
    digitalWrite(pin_EN, LOW);
    delay(1);
    pinMode(pha_a,INPUT);
    pinMode(pha_b,INPUT);
    digitalWrite(pha_a, HIGH);
    digitalWrite(pha_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;
    }
    void encoderPinChangeA()
    {
    if (digitalRead(pha_a)== digitalRead (pha_b))
    {
    encoder--;
    }
    else
    {
    encoder--;
    }
    }
    void encoderPinChangeB()
    {
    if (digitalRead(pha_a)!= digitalRead (pha_b))
    {
    encoder--;
    }
    else
    {
    encoder++;
    }
    }
    void loop () {
    // run when detecting notion
    if ( rotating ) delay (1);
    if (encoder >0)
    {
    digitalWrite(dir_CW, HIGH);
    digitalWrite(step_CLK,HIGH);
    digitalWrite(step_CLK,LOW);
    _delay_us(200);
    motor_position++;
    encoder =0;
    }
    else if (encoder

    • @msr2363
      @msr2363 5 ปีที่แล้ว +1

      Any one help me pls how to add two limit switch, in push botton, out push botton, then stop botton, pls tell me

    • @muhammeddogan8157
      @muhammeddogan8157 4 ปีที่แล้ว

      thank you

    • @ideasforlife454
      @ideasforlife454 3 ปีที่แล้ว

      if (digitalRead(pha_a)== digitalRead (pha_b))
      {
      encoder--;
      }
      else
      {
      encoder--;
      }
      this part is wrong, it should be
      if (digitalRead(pha_a)== digitalRead (pha_b))
      {
      encoder--;
      }
      else
      {
      encoder++;
      }

    • @okankurt5278
      @okankurt5278 ปีที่แล้ว

      @@muhammeddogan8157 KARDEŞİM NE YAPTIN BİTİRDİNMİ PROJENİ *

  • @frankdoyal6450
    @frankdoyal6450 4 ปีที่แล้ว +1

    I don't see it hooked up with a diy dtg printer,, will it communicate with the printer to print?

    • @DIYInkJet
      @DIYInkJet  4 ปีที่แล้ว

      it is not used in dtg printer, please watch other video th-cam.com/video/jPHzJetT3Ns/w-d-xo.html

  • @fotosdeoro
    @fotosdeoro 4 ปีที่แล้ว +1

    ITs the same with other driver. for example 6600?

  • @victorjames6242
    @victorjames6242 3 ปีที่แล้ว +1

    What is the major function of rotary optical encoders on HP M631 ADF ? is it responsible for motor stall ?

    • @DIYInkJet
      @DIYInkJet  3 ปีที่แล้ว

      works correctly

  • @prepackembalagensembalagen98
    @prepackembalagensembalagen98 3 ปีที่แล้ว +1

    Is it okay to make that call even when it's plugged into the printer?

    • @DIYInkJet
      @DIYInkJet  3 ปีที่แล้ว +1

      need more advanced programming to work well with the printer. please contact whatsapp +84 918219268

    • @prepackembalagensembalagen98
      @prepackembalagensembalagen98 3 ปีที่แล้ว

      @@DIYInkJet unfortunately I don't know how to get in touch with you through whatsapp, I'm in Brazil and mine is +55 81 991474272 and the email: prepackembalagens@gmail.com.br I'm trying to develop something like that for me, any help will be very valuable . Thank you and stay with God!

  • @prepackembalagensembalagen98
    @prepackembalagensembalagen98 3 ปีที่แล้ว

    Do the cables that were soldered to the encoder go directly to the two ports of the arduino together with the ground, or is there any protection?

  • @msr2363
    @msr2363 5 ปีที่แล้ว +1

    Good video Pls tell limit switch npn sensor push botton how to working pls new video

    • @DIYInkJet
      @DIYInkJet  5 ปีที่แล้ว

      ok

    • @msr2363
      @msr2363 5 ปีที่แล้ว

      @@DIYInkJet u r code is super working my epson l1800 dtg how to limit switch 2 with in push botton, out push botton, stop push botton how to add this code pls help

    • @pt.passindokreasitama516
      @pt.passindokreasitama516 4 ปีที่แล้ว

      @@DIYInkJetneed u r code too. Please send mrfai2000@gmail.com thanks

  • @h.d.801
    @h.d.801 4 ปีที่แล้ว +1

    Hi . Can you tell me how i can add buttons to control the platen?

    • @DIYInkJet
      @DIYInkJet  4 ปีที่แล้ว

      vui lòng kết nối whatsapp: +84918219268

  • @frankdoyal6450
    @frankdoyal6450 4 ปีที่แล้ว +1

    Great video,, question ,,, which part goes to the printer to get power from?

    • @DIYInkJet
      @DIYInkJet  4 ปีที่แล้ว

      are also powered from outside

  • @elizabethalmontecabrera3802
    @elizabethalmontecabrera3802 5 ปีที่แล้ว +2

    Hi. When you're going to leave the Arduino code, I'm running a little fast, thanks.

  • @muhammeddogan8157
    @muhammeddogan8157 4 ปีที่แล้ว +1

    If I ask, would you share the codes you wrote?

    • @DIYInkJet
      @DIYInkJet  4 ปีที่แล้ว

      If I ask, would you share the codes you wrote?

    • @muhammeddogan8157
      @muhammeddogan8157 4 ปีที่แล้ว

      @@DIYInkJet
      DO YOU SHARE THE CODES YOU WRITE?

    • @muhammeddogan8157
      @muhammeddogan8157 4 ปีที่แล้ว +1

      @@DIYInkJet I USE GOOGLE TRANSLATION. NO ENGLISH.

  • @andrerivaldi89
    @andrerivaldi89 4 ปีที่แล้ว +1

    Hi, you have the sketch code for downloading? Thank you

    • @DIYInkJet
      @DIYInkJet  4 ปีที่แล้ว

      pls whatsapp (+84918219268)

    • @artprint22
      @artprint22 4 ปีที่แล้ว

      @@DIYInkJet faile Arduino sensor disk???
      Sent to e-mail
      Syahrulanwar1992@gmail.com

  • @shibarmy9621
    @shibarmy9621 5 ปีที่แล้ว +3

    hey bro awesome tutorial can you please share the Arduino code as well to study and implement

    • @DIYInkJet
      @DIYInkJet  5 ปีที่แล้ว +1

      You can rewrite the code. We will share the code in the future.

    • @shibarmy9621
      @shibarmy9621 5 ปีที่แล้ว +1

      @@DIYInkJet ok please do share

    • @havefun8962
      @havefun8962 4 ปีที่แล้ว

      @@DIYInkJet please share bro. Where waiting. Tnx. Great video. Thats the video im looking for. Hope u could help us🙏🙂

    • @DIYInkJet
      @DIYInkJet  4 ปีที่แล้ว

      @@havefun8962 please contact whatsapp: +84918219268

    • @SK2Chanel
      @SK2Chanel ปีที่แล้ว

      ​@@DIYInkJet hallo

  • @msr2363
    @msr2363 5 ปีที่แล้ว

    #define encoder_a 2 //keep this on and interrupt pin
    #define encoder_b 3 //keep this on and interrupt pin #define motor_step 9 #define motor_direction 8 #define senzor_front 6 #define senzor_rear 7 #define load_button 4 #define eject_button 5 int home_position = 0; int load_position = 0; int pe_load = 0; void setup() { pinMode(encoder_a, INPUT); pinMode(encoder_b, INPUT); // disable pullup as we aren't using an open collector encoder digitalWrite(encoder_a, LOW); digitalWrite(encoder_b, LOW); //set up the various outputs pinMode(motor_step, OUTPUT); pinMode(motor_direction, OUTPUT); // then the senzors inputs pinMode(senzor_front, INPUT_PULLUP); pinMode(senzor_rear, INPUT_PULLUP); pinMode(load_button, INPUT_PULLUP); pinMode(eject_button, INPUT_PULLUP); } void loop() { // Control platen position of boot up and move to front if (home_position == 0) { digitalWrite(motor_direction, HIGH); TurnStepper(); if (digitalRead(senzor_front) == LOW) { home_position = 1; } } // eject platen if (digitalRead(eject_button) == LOW) { home_position = 0; } // load platen if (digitalRead(load_button) == LOW) { load_position = 1; } if (load_position == 1) { digitalWrite(motor_direction, LOW); TurnStepper(); if (digitalRead(senzor_rear) == LOW) { load_position = 0; pe_load = 1; } } } void TurnStepper() { digitalWrite(motor_step, HIGH); delayMicroseconds(40); //speed delay, the lower it is t digitalWrite(motor_step, LOW); delayMicroseconds(40); //speed delay, the lower it is the faster }
    Second... Encoder A B +3.3v GND to belt drive
    Quote:
    #define encoder_a 2 //keep this on and interrupt pin
    #define encoder_b 3 //keep this on and interrupt pin #define motor_step 4 //can be any pin #define motor_direction 5 //can be any pin volatile long motor_position, encoder; unsigned long WaitReverse = 200; //

    • @e.sukisnopixmaprint4649
      @e.sukisnopixmaprint4649 5 ปีที่แล้ว

      mani raj i want to ask you..this code just works when the printer print or works begin from the printer is on..? I mean that I want this code works when the printer is printing only, when the printer is cleaning this code does not work..

    • @pt.passindokreasitama516
      @pt.passindokreasitama516 4 ปีที่แล้ว

      hi. how have your projects been done?

    • @robinlaiko5532
      @robinlaiko5532 6 หลายเดือนก่อน

      @@e.sukisnopixmaprint4649 motor stepper bekerja saat perintah print di deteksi dari sensor penarik kertas krn hanya perintah print sj penarik kertas ada pergerakan

  • @havefun8962
    @havefun8962 4 ปีที่แล้ว

    Great video dear. Can u please put a link of Code in the discription? Thanks dear it helps a lot

  • @ЯнкоКолев-ц4ж
    @ЯнкоКолев-ц4ж 5 ปีที่แล้ว +2

    great!!!

  • @otercesotercesfernandez784
    @otercesotercesfernandez784 5 ปีที่แล้ว +1

    Hi, can you tell me exactly what engine step by step it is? Thank you.

    • @DIYInkJet
      @DIYInkJet  5 ปีที่แล้ว

      Step motor 1.8

    • @otercesotercesfernandez784
      @otercesotercesfernandez784 5 ปีที่แล้ว +1

      @@DIYInkJet Yes, I imagined that, but is it Nema 17 or Nema 23?

    • @DIYInkJet
      @DIYInkJet  5 ปีที่แล้ว +1

      @@otercesotercesfernandez784 Nema 17

  • @qamarhussain5323
    @qamarhussain5323 4 ปีที่แล้ว

    Make video using all these tb6560 driver arduino uno encoder encoder disk
    and potentiometer also for speed controlling

  • @orlandoleon78
    @orlandoleon78 4 ปีที่แล้ว +1

    GOOD BROTHER GREETINGS BEFORE ALL THAT CODE I CAN USE IT WITH AN ARDUINO MEGA 2560 AND WITH A POLOLU 8825 DRIVER

    • @DIYInkJet
      @DIYInkJet  4 ปีที่แล้ว

      use for tb6560

  • @qamarhussain5323
    @qamarhussain5323 4 ปีที่แล้ว

    Please send encoder diagram or tell which encoder you used

  • @tanshobbies6404
    @tanshobbies6404 5 ปีที่แล้ว +1

    how to stepper motor with sensor controller eye mark register ?

    • @DIYInkJet
      @DIYInkJet  5 ปีที่แล้ว

      Please contact whatsapp +84 918219268

  • @bouaslamourad3737
    @bouaslamourad3737 2 ปีที่แล้ว +2

    Good job .if you can send me code Arduino pls

  • @mahfoudcherabi2590
    @mahfoudcherabi2590 4 ปีที่แล้ว +1

    Hello
    The number of turns is not the same ( motor of the printer and my stepper ) is that normal ?
    i don't get problems in the futur ?
    Thanks i appreciate your help
    + 1 Sebscriber

    • @DIYInkJet
      @DIYInkJet  4 ปีที่แล้ว

      please contact whatsapp: +84918219268

  • @Microfiom35
    @Microfiom35 ปีที่แล้ว +1

    Hi brother how can i get the code for Arduino? sketch

    • @DIYInkJet
      @DIYInkJet  ปีที่แล้ว

      pls contact whatsapp +84 918219268

    • @Microfiom35
      @Microfiom35 ปีที่แล้ว +1

      HI I have a question, can I use optical rotary encoder E38S6-600-24G instead of the one you used in your project?

  • @seenivasan0387
    @seenivasan0387 5 ปีที่แล้ว +1

    Hi sir thk u for your awesome video. This code have some error. Can u please update new code

  • @orlandoleon78
    @orlandoleon78 4 ปีที่แล้ว

    good brother greetings that code only works for this driver tb6560 brother does not work with the pololu 8825 driver I have tried to simulate it with the 8825 driver and it does not respond the motor does not do anything it is a nema 17 of 1.8 degree

  • @xtdiy
    @xtdiy 2 ปีที่แล้ว

    Can you give me the code?

  •  4 ปีที่แล้ว

    donde puedo obtener el código para la targete arduino

  • @woodengifts2472
    @woodengifts2472 4 ปีที่แล้ว +1

    Hi Interesting tutorial.. do you have the code for downloading Thanks

    • @DIYInkJet
      @DIYInkJet  4 ปีที่แล้ว

      Please contact whatsapp: +84 918219268 or email willkaydesign@gmail.com

    • @woodengifts2472
      @woodengifts2472 4 ปีที่แล้ว

      DIY Channel Will the stepper motor work forward and reverse?

    • @DIYInkJet
      @DIYInkJet  4 ปีที่แล้ว +1

      @@woodengifts2472 yes

    • @woodengifts2472
      @woodengifts2472 4 ปีที่แล้ว

      DIY Channel Hi I sent you an email could you send me the code please? Thanks Gary

  • @angleprinting3731
    @angleprinting3731 5 ปีที่แล้ว

    Any one help how to add limit switch in out stop arduino codeing

  • @DK_0710
    @DK_0710 4 ปีที่แล้ว +1

    very cool friend! how can i get the code for Arduino? sketch

    • @DIYInkJet
      @DIYInkJet  4 ปีที่แล้ว

      Please contact whatsapp: +84 918219268

  • @alexanderevich6503
    @alexanderevich6503 4 ปีที่แล้ว

    Hey. I am a subscriber to your channel. A very interesting video about creating a tablet printer. Can you drop me a sketch to control the table?

  • @blackcomedy5509
    @blackcomedy5509 4 ปีที่แล้ว +1

    Cool please sketch 🙏🙏🙏

  • @debbant
    @debbant 5 ปีที่แล้ว

    Thumbs down!! You call this a "How To" but don't post the code?? 12 minutes of my life that I can never get back!!

  • @msr2363
    @msr2363 5 ปีที่แล้ว

    This code online download not work

  • @ipworks4567
    @ipworks4567 หลายเดือนก่อน

    code please

  • @AlokYadav-gk7lk
    @AlokYadav-gk7lk 5 ปีที่แล้ว +1

    Please send the code

    • @wikastana
      @wikastana 5 ปีที่แล้ว +1

      #define encoder_a 2 //keep this on and interrupt pin
      #define encoder_b 3 //keep this on and interrupt pin
      #define motor_step 9
      #define motor_direction 8
      #define senzor_front 6
      #define senzor_rear 7
      #define load_button 4
      #define eject_button 5
      volatile long motor_position, encoder;
      int home_position = 0;
      int load_position = 0;
      int pe_load = 0;
      void setup() {
      pinMode(encoder_a, INPUT);
      pinMode(encoder_b, INPUT);
      // disable pullup as we aren't using an open collector encoder
      digitalWrite(encoder_a, LOW);
      digitalWrite(encoder_b, LOW);
      //set up the various outputs
      pinMode(motor_step, OUTPUT);
      pinMode(motor_direction, OUTPUT);
      // then the senzors inputs
      pinMode(senzor_front, INPUT_PULLUP);
      pinMode(senzor_rear, INPUT_PULLUP);
      pinMode(load_button, INPUT_PULLUP);
      pinMode(eject_button, INPUT_PULLUP);
      //--------------------------------------------------
      // encoder pin on interrupt 0 (pin 2)
      attachInterrupt(0, encoderPinChangeA, CHANGE);
      // encoder pin on interrupt 1 (pin 3)
      attachInterrupt(1, encoderPinChangeB, CHANGE);
      encoder = 0;
      // -------------------------------------------------
      }
      // -------------------------------------------------
      void encoderPinChangeA(){
      if (digitalRead(encoder_a) == digitalRead(encoder_b)){
      encoder--;
      }
      else{
      encoder++;
      }
      }
      void encoderPinChangeB(){
      if (digitalRead(encoder_a) != digitalRead(encoder_b)){
      encoder--;
      }
      else{
      encoder++;
      }
      }
      // -------------------------------------------------
      void loop() {
      // Control platen position of boot up and move to front
      if (home_position == 0) {
      digitalWrite(motor_direction, HIGH);
      TurnStepper();
      if (digitalRead(senzor_front) == LOW) {
      home_position = 1;
      }
      }
      // eject platen
      if (digitalRead(eject_button) == LOW) {
      home_position = 0;
      }
      // load platen
      if (digitalRead(load_button) == LOW) {
      load_position = 1;
      }
      if (load_position == 1) {
      digitalWrite(motor_direction, LOW);
      TurnStepper();
      if (digitalRead(senzor_rear) == LOW) {
      load_position = 0;
      pe_load = 1;
      }
      }
      // -------------------------------------------------
      if (encoder > 0){
      digitalWrite(motor_direction, HIGH); // output direction HIGH
      digitalWrite(motor_step, HIGH); // output step HIGH
      digitalWrite(motor_step, LOW); // output step LOW
      _delay_us(2000); // tunggu 200 microsecond
      motor_position++; // posisi motor bergeser tambah satu point
      encoder = 0; // reset ke 0
      }
      else if (encoder < 0){
      digitalWrite(motor_direction, LOW); // output direction LOW
      digitalWrite(motor_step, HIGH); // output step HIGH
      digitalWrite(motor_step, LOW); // output step LOW
      _delay_us(2000); // tunggu 200 microsecond
      motor_position--; // posisi motor bergeser kurang satu point
      encoder = 0; // reset ke 0
      }
      // -------------------------------------------------
      }
      void TurnStepper() {
      digitalWrite(motor_step, HIGH);
      delayMicroseconds(100); // speed delay, the lower it is the faster
      digitalWrite(motor_step, LOW);
      delayMicroseconds(100); // speed delay, the lower it is the faster
      }

    • @uwtyhulonthalo3152
      @uwtyhulonthalo3152 5 ปีที่แล้ว

      @@wikastana gan, saya sdh coba tapi putaran motor tetap satu arah walaupun encoder diputar bolak balik, bgtu juga putaran utk load platen sama eject platen kan seharusnya jdi beda atau berlawan putarannya tpi kok ini malah satu arah semua, apanya yg salah ya gan??

    • @wikastana
      @wikastana 5 ปีที่แล้ว +1

      @@uwtyhulonthalo3152 groundnya sudah bener belum, cek dulu encodernya , hrsnya bisa cek koneksi dng portnya harus betul2 nyambung, dan ini sudah saya uji dan tdk ada masalah

    • @wikastana
      @wikastana 5 ปีที่แล้ว

      @@uwtyhulonthalo3152 control motor yang saya gunakan TB6650

    • @uwtyhulonthalo3152
      @uwtyhulonthalo3152 5 ปีที่แล้ว

      @@wikastana klo sy menggunakan driver TB6560, ok gan ntar sy periksa ulang lagi, thanks

  • @angleprinting3731
    @angleprinting3731 5 ปีที่แล้ว

    Pc Arodino code not clear pls send code

    • @msr2363
      @msr2363 5 ปีที่แล้ว +1

      #define pha_a 2 // pin 2 on UNO is connected to phase a encoder
      #define pha_b 3 // pin 3 on UNO is connected to phase b encoder
      #define step_CLK 9 // pin 9 on UNO is connected to the CLK pin of TB6560
      #define dir_CW 10 // pin 10 on UNO is connected to the CLK pin of TB6560
      #define pin_EN 11 // pin 11 on UNO is connected to the CLK pin of TB6560
      static boolean rotating=false;
      volatile long motor_position,encoder;
      boolean A_set = false;
      boolean B_set = false;
      void setup() {
      pinMode(step_CLK,OUTPUT);
      pinMode(dir_CW, OUTPUT);
      pinMode(pin_EN, OUTPUT);
      digitalWrite(pin_EN, LOW);
      delay(1);
      pinMode(pha_a,INPUT);
      pinMode(pha_b,INPUT);
      digitalWrite(pha_a, HIGH);
      digitalWrite(pha_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;
      }
      void encoderPinChangeA()
      {
      if (digitalRead(pha_a)== digitalRead (pha_b))
      {
      encoder--;
      }
      else
      {
      encoder--;
      }
      }
      void encoderPinChangeB()
      {
      if (digitalRead(pha_a)!= digitalRead (pha_b))
      {
      encoder--;
      }
      else
      {
      encoder++;
      }
      }
      void loop () {
      // run when detecting notion
      if ( rotating ) delay (1);
      if (encoder >0)
      {
      digitalWrite(dir_CW, HIGH);
      digitalWrite(step_CLK,HIGH);
      digitalWrite(step_CLK,LOW);
      _delay_us(200);
      motor_position++;
      encoder =0;
      }
      else if (encoder

    • @angleprinting3731
      @angleprinting3731 5 ปีที่แล้ว

      @@msr2363 tanks