Arduino Rotary Table for Dummies

Discussion in 'Machine Modifications' started by bmac2, Apr 24, 2017.

Help Support HMEM by donating:

  1. Mar 11, 2019 #241

    lkrestorer

    lkrestorer

    lkrestorer

    Well-Known Member

    Joined:
    Aug 1, 2009
    Messages:
    45
    Likes Received:
    0
    Gender:
    Male
    Location:
    Minnesota
    Wow! It works! And it worked the first time and all the smoke stayed inside! It even turns very smoothly.

    Now I have to wander into never-never land and modify the sketch to deal with my hardware.

    Thanks for the help, guys.

    Len
     
  2. Mar 12, 2019 #242

    lkrestorer

    lkrestorer

    lkrestorer

    Well-Known Member

    Joined:
    Aug 1, 2009
    Messages:
    45
    Likes Received:
    0
    Gender:
    Male
    Location:
    Minnesota
    Ok, I can assemble everything needed but when it comes to the software I hit a wall. I loaded the original sketch and everything "worked" - but it didn't work well. My first problem was with my keypad and that was simple to fix. At first it was sending what appeared to be random inputs so I totally reversed the connections (1 through 8 to 8 through 1) and the right stuff came out.
    I was not getting the proper number of steps so I changed the TableRatio from 36 to 90 to match my table. The step count came out to -3690 and nothing moved. To troubleshoot it I entered 72 (as was mentioned in the original post) and it worked and the number of steps and the degrees-moved doubled. I read farther and found some (to me) obscure references about why this happened.
    Next, I loaded the sketch in message 145 thinking that it might give me some way to fix this but my keypad was totally dead. No key selection did anything. I then loaded the sketch from message 149 with the same results. This gave me the setup screen but with a dead keypad it was the end of the line. (As a hardware test I then reloaded the original sketch and the keypad worked fine eliminating the possibility of disconnected wiring.)
    Right now I'm stuck until I can program in the 90:1 ratio that my rotary table requires. I can follow directions but without spending considerable time learning this sketch language I am not going to get much farther.
    Help? Please?

    Len
     
  3. Mar 12, 2019 #243

    kquiggle

    kquiggle

    kquiggle

    Well-Known Member

    Joined:
    May 29, 2012
    Messages:
    301
    Likes Received:
    85
    Len -

    You might want to try the (based on the original but very much revised) sketch I wrote, which is available at the link below (scroll down to Part 3: Coding - and look for Rev7). The revised sketch allows you to input all required values from the keypad, so you can easily experiment with various settings (option D on the Menu).

    https://sites.google.com/site/lagad...es-mills-etc/build---electronic-indexing-head
     
  4. Mar 12, 2019 #244

    lkrestorer

    lkrestorer

    lkrestorer

    Well-Known Member

    Joined:
    Aug 1, 2009
    Messages:
    45
    Likes Received:
    0
    Gender:
    Male
    Location:
    Minnesota
    kquiggle,

    I will have a chance to get back in the shop tomorrow sometime so I will give it a try then. Will my keyboard work with your sketch as it works with bmac2's original sketch?

    Len
     
  5. Mar 13, 2019 #245

    kquiggle

    kquiggle

    kquiggle

    Well-Known Member

    Joined:
    May 29, 2012
    Messages:
    301
    Likes Received:
    85
    If bmac2's original sketch works on your hardware, my sketch should also work; they both work on my set-up.

    Please let me know how it works for you.
     
  6. Mar 13, 2019 #246

    ignator

    ignator

    ignator

    Well-Known Member

    Joined:
    Jan 22, 2012
    Messages:
    95
    Likes Received:
    11
    Gender:
    Male
    Location:
    USA, Iowa
    If you can leave your programming computer connected to the Arduino board, you can install some debugging code in your program, and use your computers monitor to display the Arduino IDE popup screen monitor. To get this serial monitor on your computer screen, you select "tools" on the IDE program window, and select "serial monitor" (or you can press CTRL+SHIFT+M on the computer keyboard).
    In your code you will need to insert program text that writes to this monitor. And every time build and program the Arduino micro controller.

    In the setup part you will need this line of code
    // Just whilst we debug, view output on serial monitor
    Serial.begin(115200); //found with China copy of DUE, could not run this faster

    Then print statement related to the variables used in the program, example;
    I pulled this from one of my sketches
    Serial.print("I"); // put out an I for interrupt
    Serial.println(InterruptTime_avg); //and print the average last 1000 interrupts
    // Write out to serial monitor the value and direction
    Serial.print("\t");
    Serial.println(virtualPosition);

    lkrestorer, go to the Arduino web site and look up the Serial function to see how to use it for debug.
    Here is a link,
    file:///C:/Program%20Files%20(x86)/Arduino/reference/www.arduino.cc/en/Reference/Serial.html

    The above link will have examples and such. But the idea is to "instrument" your code, to see where it is going wrong.
    Strange you had it working and then it stopped, seems like a loose connection or something bad like ESD.
    edit
    OK, the serial.begin, I set up a very high speed baud rate of 115200 bits per second. You have to set the popup screen to this same baud rate. I was using a DUE board, as in my use, was decoding an quadrature encoder which was using interrupts of the Arduino. I was testing to see if some were being lost. So I used a very high speed baud rate as the program was writing to the popup screen often. And a slow baud rate would be buffered by the computer and cause all sorts of problems, with Serial.print putting out data faster then the default slow baud rate could be displayed on the virtual popup screen. I see I have a comment about the slow DUE board China copy I was using, as all this data has to flow through the USB port from the Arduino board to the connected computer, to the popup screen. I can't recall the default baud rate, but 4800 seems correct from memory.
     
    Last edited: Mar 13, 2019
  7. Mar 13, 2019 #247

    seleveng

    seleveng

    seleveng

    New Member

    Joined:
    Mar 13, 2019
    Messages:
    4
    Likes Received:
    0
    Gender:
    Male
    Location:
    Germany
    Hi All,

    really appreciate this project - it brings me forward a lot!
    With my little Nema17 stepper motor everythzing works just fine.
    Now I also want to use a stronger Stepper motor size Nema34.
    But I'm having the same problem like "dembelneizbezen" Post #198. Smooth ramps are required.
    Like many others here I'm not really familiar with programming the Arduino yet.
    I know there is a stepper motor library and as far as I know you can specify ramps for accelaration and decelaration.

    I also found an interesting video on youtube.. it also covers the "backlash topic".



    Would be good if somebody can help!

    Reagrds,
    Sebastian
     
  8. Mar 13, 2019 #248

    bluejets

    bluejets

    bluejets

    Well-Known Member

    Joined:
    Apr 22, 2014
    Messages:
    69
    Likes Received:
    44
    I for one find the input from #246 confusing and I am experienced with Arduino programming.
    e.g. if one wants the serial monitor pop-up, there is a "radio-button" in the top right corner of the IDE screen. Run your cursor over it and it tells you "serial monitor".

    Never really found the need for a stepper driven rotary table and all seems like a bit of a novelty thing to me really.
    Unless of course one has full cnc.

    The Op said he has problems with software so best would be to let him explain details of his problems as much as he possibly can.

    Important to provide the problems in sequence and hardware used so a logical answer can be provided by others.
     
  9. Mar 13, 2019 #249

    tjwal

    tjwal

    tjwal

    Well-Known Member

    Joined:
    Sep 22, 2013
    Messages:
    62
    Likes Received:
    6
    Len
    In message 128 I posted a sketch to debug the keypad. You can monitor which key is pressed in the serial monitor. I’m sure there is a logical way to connect the keypad so it works but I used the trial and error approach. Once you get the keypad working then if necessary copy the definitions into the indexing sketch.

    John
     
  10. Mar 14, 2019 #250

    seleveng

    seleveng

    seleveng

    New Member

    Joined:
    Mar 13, 2019
    Messages:
    4
    Likes Received:
    0
    Gender:
    Male
    Location:
    Germany
    Does anyboday have an idea how to add smooth motion for the stepper motor?

    Sebastian
     
  11. Mar 14, 2019 #251

    elcid

    elcid

    elcid

    Member

    Joined:
    Feb 18, 2010
    Messages:
    6
    Likes Received:
    0
  12. Mar 14, 2019 #252

    kquiggle

    kquiggle

    kquiggle

    Well-Known Member

    Joined:
    May 29, 2012
    Messages:
    301
    Likes Received:
    85
    Sebastian - keeping in mind that I am pretty new to all this stuff myself, here is my understanding: You can sort of smooth out the stepping using microstepping (smaller finer steps) , but the trade-off is you lose torque. You can also use gear or belt reduction to effectively reduce the step size at the business end. I think the requirements for 3D printing and indexing are similar but not the same. With 3D printing you want accuracy and smooth motion along the print path; with indexing you want accuracy, but it doesn't matter all that much of the motion between indexes is jerky as long as you end up in the right place.

    I used a stepper motor with a built-in planetary gear reduction (~27:1) on my indexer, and this is working for me (link below).

    https://sites.google.com/site/lagad...es-mills-etc/build---electronic-indexing-head
     
  13. Mar 14, 2019 #253

    seleveng

    seleveng

    seleveng

    New Member

    Joined:
    Mar 13, 2019
    Messages:
    4
    Likes Received:
    0
    Gender:
    Male
    Location:
    Germany
    Thanks for your responses... but I'm still not sure, if I have explained my problem exactly enough. It is probably not that easy in German language, but even harder for me to do it in English :) Let me try again... My stepper is a Nema 34 34HS1456 (3V, 5.6A, 840Ncm torque). The rotary table I'm using is a Knuth RT250 with a 200mm 6 jaw chuck mounted! I also want to use a planetary gear connected to the stepper motor (ratio 20:1) and a geared belt (HTD 5M, ratio 6:1). I will not use the integrated worm drive in hope to minimize backlash. With 1/4 microstepping (800 pulses per rotation) I will end up having 96000 pulses per rotation (800x20x6). On a disc with 500mm diametre that means about 0,016mm deviation per pulse along the perimeter... that's what I'm aiming for! But because the rotating mass will be at least 30kg, it is important to accelerate und decalerate smoothly!

    Regards,
    Sebastian
     
  14. Mar 14, 2019 #254

    kquiggle

    kquiggle

    kquiggle

    Well-Known Member

    Joined:
    May 29, 2012
    Messages:
    301
    Likes Received:
    85
    Sebastian - I think I understand what you are looking for now (you're English is excellent by the way, so the confusion was on my end). Anyway, you may be interested in this:

    http://www.airspayce.com/mikem/arduino/AccelStepper/

    With 30kg of mass to move, acceleration may well be an issue but I would try it first without trying to compensate to see if controlling acceleration is really necessary.

    Additional note - I think not using the integral worm drive may reduce backlash a bit, but you will still have backlash in the planetary gears and the belt system so I don't know that it will make a difference overall. My novice opinion is that the system should always be driven in one direction so that backlash is not an issue; also, I always drive my indexer one full 360° rotation before I start my actual indexing just to remove any slack in the system.
     
  15. Mar 14, 2019 #255

    seleveng

    seleveng

    seleveng

    New Member

    Joined:
    Mar 13, 2019
    Messages:
    4
    Likes Received:
    0
    Gender:
    Male
    Location:
    Germany
    Over the weekend I will read through the explenation of the AccelStepper library to get a better understanding... maybe I can find something helpful!
    Thanks for the link!

    Sebastian
     
  16. Mar 15, 2019 #256

    weir-smith

    weir-smith

    weir-smith

    Bruce W-S Project of the Month Winner

    Joined:
    Jan 30, 2015
    Messages:
    32
    Likes Received:
    33
    Occupation:
    Retired
    Location:
    Perth Western Australia
    Len

    I can see that you are having a few problems with this project. I have made several of these units without difficulty however, if it is all new then its a case of plodding through all of the issues.

    A quick fix for the sketch for 90:1 rotary tables is to edit the file by making the "Multiplier = 100" rather than "Multiplier = (StepsPerRotation* TableRatio)/360". Just scroll down to the "const int" and the fifth is the Multiplier. There is an issue with the code when you set the variables for 90:1 and while I am sure of the solution, I need to test it across a range of numbers to be sure. I will do that in the next couple of weeks. For 90:1, the multiplier needs to be 100 if you are using the setting on the stepper driver of "2". On the stepper controller module, you can set the max current and the stepping mode some times shown as excitation mode via dip switches. You can select 1, 2, 8, or 16 and you require 2.

    So for a 90:1 rotary table, 4 deg is equal to 1 complete turn of the stepper or 200 steps for the standard stepper motor. So 4 deg x 100 = 400 and this is what you will read on your display. The stepper controller will divide the input steps by 2 e.g. 400 steps /2 = 200 or one revolution.

    My fix is a quick one however is works without problems and as I said before, I will put in a correction which is easier to implement. I have two rotary tables of different ratios and I want to use the same controller so I will need an extra menu etc. I have also added an additional feature in my controller that provides continuous rotation with forward and reverse etc.

    Also happy to answer any more of your questions.

    Bruce


    20190202_121626.jpg
     
  17. Mar 15, 2019 #257

    lkrestorer

    lkrestorer

    lkrestorer

    Well-Known Member

    Joined:
    Aug 1, 2009
    Messages:
    45
    Likes Received:
    0
    Gender:
    Male
    Location:
    Minnesota
    kquiggle,

    I followed your link and loaded the sketch (Rev.7). Everything worked according to schedule until it was loaded. The display reads:
    Enter Selections
    Degrees = A
    Divisions = B
    JOG = C

    And that's it. There is no "option D" on the menu and at that point I cannot do anything with it. None of the keys on my keypad register at all. The problem I had with the original bmac2 sketch was that the wrong keys sent the wrong information. I reversed the connections to the Arduino board and everything worked correctly - the order just had to be reversed. With each of the other sketches (including Rev7 that I just loaded) there is no response to any key stroke. Without changing any wiring connections I reloaded the original sketch and the keypad works fine.

    You can see that I become stumped quite easily with this sketch language. I'm fairly good at building stuff but this is a foreign language to me. I can see some of the operation of the program but it doesn't take long for my eyes to cross and I have to walk away and make another pile of swarf to reset my senses.

    Len
     
  18. Mar 15, 2019 #258

    ignator

    ignator

    ignator

    Well-Known Member

    Joined:
    Jan 22, 2012
    Messages:
    95
    Likes Received:
    11
    Gender:
    Male
    Location:
    USA, Iowa
    This can be a problem jumping into a full system, and not playing with the piece parts.
    So go to youtube, search for "arduino keypad tutorial", I found this one below that seems simple;

    This youtube has a link to the software he's using, click the link, copy past the code into a new arduino sketch window. Then program your arduino with this code.
    I copied this code below. You can leave all the other hardware connected for this test setup, but play with it, and verify you get the correct keys displayed on the arduino serial monitor.
    You can find code for each piece part of what you are trying to debug. This also gives you some understanding of the piece parts of program operation, so you are not lost.
    -------------
    /*
    * Original sourse: https://playground.arduino.cc/Code/Keypad
    * This is the Arduino code for 4x4 keypad.
    * watch the video for details and demo
    * *
    * Written by Ahmad Nejrabi for Robojax Video channel www.Robojax.com
    * Date: Dec 18, 2017, in Ajax, Ontario, Canada
    * Permission granted to share this code given that this
    * note is kept with the code.
    * Disclaimer: this code is "AS IS" and for educational purpose only.
    * this code has been downloaded from http://robojax.com/learn/arduino/
    *
    */
    /* @file HelloKeypad.pde
    || @version 1.0
    || @author Alexander Brevig
    || @contact alexanderbrevig@gmail.com
    ||
    || @description
    || | Demonstrates the simplest use of the matrix Keypad library.
    || #
    */
    #include <Keypad.h>

    const byte ROWS = 4; //four rows
    const byte COLS = 4; //three columns
    char keys[ROWS][COLS] = {
    {'1','2','3','A'},
    {'4','5','6','B'},
    {'7','8','9','C'},
    {'*','0','#','D'}
    };

    byte rowPins[ROWS] = {2, 3, 4, 5}; //connect to the row pinouts of the keypad
    byte colPins[COLS] = {6,7,8,9}; //connect to the column pinouts of the keypad

    Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

    void setup(){
    Serial.begin(9600);
    }

    void loop(){
    char key = keypad.getKey();
    // just print the pressed key
    if (key){
    Serial.println(key);
    }

    // this checkes if 4 is pressed, then do something. Here we print the text but you can control something.
    if (key =='4'){
    Serial.println("Key 4 is pressed");
    }
    }
    ---------------

    I hope this helps.
     
  19. Mar 15, 2019 #259

    lkrestorer

    lkrestorer

    lkrestorer

    Well-Known Member

    Joined:
    Aug 1, 2009
    Messages:
    45
    Likes Received:
    0
    Gender:
    Male
    Location:
    Minnesota
    Bruce,

    Yes, It is all new - but interesting. I don't know if I'll be willing to put in the time to become proficient at it but I would like to play around enough so that I have a little understanding of what's going on. There is a lot of excitement when something actually works, though. Like my first steam engine build when it actually rotated the way it was supposed to when I put air to it (a PM Research engine).

    I made the changes to the sketch just as you suggested and my excitement rose dramatically when it traveled properly. When I put in 4 degrees it traveled 4 degrees and the display showed 400. I played with it quite a bit and it worked quite well until I tried 360 degrees - I had to disconnect the power after watching it go around three times. It works fine up to 320 degrees. 330 degrees and above runs constantly (I did not try each degree between 320 and 330 to see how it performed). If this is how it works I'm sure I can live with it.

    I like the "continuous" feature on your controller but you may have just helped me build it into mine. (humor).

    Len
     
  20. Mar 15, 2019 #260

    lkrestorer

    lkrestorer

    lkrestorer

    Well-Known Member

    Joined:
    Aug 1, 2009
    Messages:
    45
    Likes Received:
    0
    Gender:
    Male
    Location:
    Minnesota
    ignator,

    Thank you. I will look at your keypad information in the near future. I don't want to sound like a complainer or excuse maker but it seems like my family doesn't understand the definition of the word "retirement" the same way that I do. The fact that I have finally made this rotary table work in a way that I had never even thought about a couple of months ago is encouraging so I will continue on.

    Len
     

Share This Page