Arduino Rotary Table for Dummies

Home Model Engine Machinist Forum

Help Support Home Model Engine Machinist Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.
inserting the change [line 152 should be ToMove=(long)((bob/360.0) *(float)( Multiplier + 0.5 - cumSteps));] from post 126 gives the error - It seems to be adding tomove to itself

'vert back to the original till the 'Why' is solved . . Been punching the A - B with 17 divisions for a while and so far error free . .

Thanks Foozer. Error was caused by misplaced brackets.
This seems to work better.
ToMove=(long)((float)(bob/360 * Multiplier + 0.5 - cumSteps));
 
Ok Guys here is my report. I fixed the case sensitive problems and I apparently transposed the numbers for rows and columns. I fixed that also. I am using an 84 ozin nema 17 motor to turn a Sherline rotary table that is 72:1. I changed the steps on the motor driver to 1/8 and in the sketch to 800 and all worked fine. I then tried 1/16 at 1600 and it worked also. The problem is with 1/16 it seams to lack enough torque and is really sloooow! In the end I put it back to 1/2 step and 400. I am using a 20v 3A power supply. I think the only thing else I could do is use a higher voltage supply in hopes that it will increase speed?

Thanks again for the help,

Jeff K.

Jeff
shouldn't 1/8 stepping be 1600 steps? I'm assuming a 200 step/rev stepper.
Raising the voltage will not increase the speed but will increase the torque.
You can increase speed by reducing "stepdelay" on line 20 of my sketch. I'm using 1000 microseconds. Bob is using 1 millisecond. If you're using Bob's sketch you will need to change the code in the rotation function to use "delayMicroseconds". Increased speed will need higher torque so you likely will also have to raise the voltage.
John
 
While watching Rick & Morty played around with the sketch
Sketch from post 80 has listed

const int stp = 8; // connect pin D8 to step
const int dir = 9;

8 & 9 are used by the keypad, haven't looked thru all the post to see if that was caught, changed them to 3 & 4
Also and this may just be the keypad library on my machine, changed all instances of 'Keypad kpd' to 'Keypad keypad'

To clean up screen
char key = keypad.getKey();
lcd.clear(); <---- added
lcd.print("Enter Selection:");

Buttons and screen working in harmony

Robert
Good catch. I'm using a pro micro and missed revising those two pins to reflect a UNO when I posted the code.
There must be some difference in the libraries we're using as I'm not having the keypad or lcd issue.
Cheers
John
 
That fixed it, 17 divisions 1694 steps with the occasional spread the error out 1695 popped in

Also changed line in printadvance from lcd.setCursor(13, 0) to lcd.setCursor(14, 0) to wipe out the left over trailing digit by the padding that follows [lcd.print(" ");]

I like half steps, so the motor buzzes a bit, my little rotary is 36:1 and @ 1600 steps per rotation the torque is so dropped off that I can with little effort finger stop it, plus my gray beard will grow an inch waiting for the next position to come up, not so much @ 400 steps . . . 400 is a reasonable bank for the buck . . .

Robert
 
After reviewing the code from the original project (Reference #3 below), I decided to make some major changes. The revised code can be downloaded here:

Arduino_Rotary_Table_Control_2017_Rev5.ino : https://drive.google.com/open?id=14_J0URvgsPYnLZ1EFZD2IRKg-7uJEYHN

The code changes were made so that when stepper motor and rotary table parameters are entered into the program, calculations will be made in two ways:

[Note: In the explanation below, I will use "steps" to mean either full steps or microsteps, which the stepper motor is set for.]

First, the program will calculate the exact ("theoretical") number of steps required to move a specified number of degrees; this may be a fractional number even though the stepper motor cannot move a fractional step. The program also keeps track of the total number of theoretical steps moved.

Second, the theoretical number of steps are converted to "actual" (integer) steps. The program also keeps tracks of the total number of actual steps moved.

The determination of the required number of steps to move is in all cases based on the theoretical steps, which are then converted to actual steps. This method provides the best approximation (typically with an error less than 0.01%), and enables the easy use of gear and table ratios which do not divide exactly into 360.

Updates or corrections will be posted on my build log here:

https://sites.google.com/site/lagadoacademy/machining---lathes-mills-etc/build---electronic-indexing-head?pli=1
 
Thank you John and Foozer,
I am not sure I follow where to make the changes you suggested in regards to the screen:
"To clean up screen
char key = keypad.getKey();
lcd.clear(); <---- added
lcd.print("Enterction:"); "
However I made the bracket change to the "To Move" line and that worked great. Yes you were correct I miss typed 1/16 instead of 1/8, 1600 steps. I decided to try several delays along with different step resolutions. I ended up with 1/8 step at 200 milliseconds. It runs reasonably fast and I am unable to stall the rotation by hand. If However I wanted to mill a curved slot, with the table set horizontal, I think it would be a bit too fast. I found for milling I would need to reload the sketch at a delay of 500.
This begs the question, can another menu item be added that allows the selection of that delay from the LCD screen. If so one would have the ability to adjust feed speed when milling. I assume that most people doing this is for indexing and would not require speed adjustment. I am hoping to extend the capabilities to include all the typical uses of the rotary table in addition to indexing.
On another note, I looked at kquiggle's sketch and to not understand how he is accounting for cumulative error? The sketch that John made keeps track and adjusts for it if I am reading it correctly?

Thanks again,

Jeff K.
 
...snip....

This begs the question, can another menu item be added that allows the selection of that delay from the LCD screen. If so one would have the ability to adjust feed speed when milling. I assume that most people doing this is for indexing and would not require speed adjustment. I am hoping to extend the capabilities to include all the typical uses of the rotary table in addition to indexing.

.....snip...

Thanks again,

Jeff K.

Jeff
I&#8217;m working on a version with a menu to change the table and stepper ratios. It will be easy to include the delay. The data is stored in EEPROM so it only has to be done when a change is needed. It&#8217;s a work in progress but I&#8217;ll upload a &#8220;working&#8221; version later today.

John
 
Jeff K. -

My sketch avoids cumulative error by calculating the exact "theoretical" position for each move, and then converting that to an integer "step position". Subtracting the previous "step position" gives the required number of steps for each new increment.

Before writing the code I modeled this in a spreadsheet and tested different numbers of divisions. Here are the calculations for 7 divisions (note: 3200 steps per 360 degrees for my set-up, so 0 and 3200 are the same position).


[FONT=DejaVu Sans Mono, monospace]Div Theoretical Actual[/FONT]

[FONT=DejaVu Sans Mono, monospace]0 0.000 0 [/FONT]
[FONT=DejaVu Sans Mono, monospace]1 457.143 457 [/FONT]
[FONT=DejaVu Sans Mono, monospace]2 914.286 914 [/FONT]
[FONT=DejaVu Sans Mono, monospace]3 1371.429 1371 [/FONT]
[FONT=DejaVu Sans Mono, monospace]4 1828.571 1829 [/FONT]
[FONT=DejaVu Sans Mono, monospace]5 2285.714 2286 [/FONT]
[FONT=DejaVu Sans Mono, monospace]6 2742.857 2743 [/FONT]
[FONT=DejaVu Sans Mono, monospace]7 3200.000 3200[/FONT]
 
The attached file includes a menu system to change the settings of the indexer. The included text file goes into detail.
I'm working with a pro micro but I have tried to save the pin setting for a UNO. Check these to make sure they match your setup.
Comments and suggestions are requested.

Cheers
John

View attachment Dummies_Rotary_Table_Eprom_2018uno_beta.ino.zip
 
I am not sure I follow where to make the changes you suggested in regards to the screen: "To clean up screen Jeff K.
The post 80 script . . .

In the void printadvance() section
From - lcd.print(ToMove);lcd.setCursor(13,0)
To - lcd.print(ToMove);lcd.setCursor(14,0)

Was doing, say 17 divisions, 400 steps, 72:1 the 5th rotation advance reports 105.88 degrees- go back one rotation which should read 84.71, reads 84.718
Not a big thing.

"kquiggle's sketch and to not understand how he is accounting for cumulative error?"

It does, just doesn't show it on the screen - can check it by commenting out the stepper commands in void rotation(long tm, int d) and adding
Serial.println(tm);

will show 1694 steps with each advance with the odd 1695 showing up when the error requires . .

I don't know seems like this new one should have a post of it's own, the original work which works fine for it's intended usage is kinda getting lost . .
Robert
 
As I do not want to detract from this post in any way, or risk making comments which are starting to veer off the main topic, I have started a new post on my related build (Electronic (Arduino) Rotary Indexer - Another One). If anyone is interested my build and related programming, I'll be posting updates there.

Thanks again to bmac2.
 
Thank you John,

I loaded your sketch and it works great for speed adjustment. While playing with it I noticed I have .5 degrees of backlash. I adjusted out the lash and found that the 84 ozin motor dose not have enough torque to rotate the rotary table. It seems the highest torque motor I can find in nema 17 is 92ozin. I did find one that was 115 but way to pricey. I chose the nema 17 for clearance reasons and size of motor driver. I am now in a quandary as I am not sure another 8ozin will make a difference or do I need lash adjustment in the sketch. I would hate to have to start over with a nema 23 and a larger driver?
I feel like I am imposing to ask if you could add lash adjustment to the sketch? I am not even sure it is doable?

As for comments in regard to your latest sketch I have a few. It works great as is but you must turn it off and back on to change the settings. It might prove more convenient to be able to press the A key on the splash screen for changes without having to re-power the controller. I added an on off switch to my control box so that it would not be an issue for me. My other comment is when in the set up screen you need to put all the variables in every time even if you only want to change one. It would be convenient if the settings defaulted to the last one if you just hit the enter key without a change.

I am grateful for the sketch as is but you asked for comments and I thought you would be interested in the observation. It feels like I am complaining about a gift!

Thanks so much for your efforts,

Jeff K.
 
Jeff
Have you tried running with a longer stepdelay? If that will work then increasing your supply voltage will also help. For indexing, backlash usually isn&#8217;t a problem, you just need to approach your position from one side. I think the same thing goes for milling but conceivably it could be a problem.
I agree with you that having to enter all three variables is a pain. I will try to fix that.

If you&#8217;re in one of the moving menus, pressing &#8220;C&#8221; resets the Arduino and the splash screen comes up. I&#8217;ve set the display time to be fairly short but if you&#8217;re quick should be able to press &#8220;A&#8221; and get to the settings.
Comments are welcome as they help me to improve the code.

John
 
John,

If you power up the controller, go through set up and then run whatever. You then hit c and yes you do have time to hit the a but it will not take you to the settings screen? Maybe I am just not fast enough or I need to increase the splash screen time?

I did lots of permutations with step delay and step resolution. I only changed 1 variable at a time. I did try a higher voltage supply in my earlier testing and found it did not perform as well. I ended up with a 20v 4.5a dell power supply. I have a 24 volt adjustable supply but I did not think the extra 4 volts would make a great deal of difference. The other one I mentioned before was 32v but only 1.6a. The motor is 2a with low inductance so I opted for the lower voltage and higher amps.

As for the lash issue I was more concerned with a circular groove. You would have to exit the cut, go past the start, come back to the start and then re-enter the groove. You would also loose the ability to reverse direction to clean up the opposite side of the groove. You would always have one side climb milled and one side conventional.

It would also be a time consuming process something like the following: Say you wanted a 45 degree arc. You would set up for it and then plunge and cut. You would then lift the cutter exit and reverse say 50 degrees. You would exit again and then reset for 5 degrees forward. You would then exit again and rest for 45 degrees, plunge in and the run forward. This would be the process for each depth of cut. Sounds a bit tedious? I may be missing something I'm not sure?

Jeff K.
 
Jeff - Re torque problem: I'm new to stepper motors myself,but my understanding is that more power (amps) = more torque, so you should set the running current on your controller to the setting that equals (or is just below) the rated current for your motor. Microstepping reduces torque slightly, so if you can get away without microstepping you should gain a bit of torque that way.

Another option (which I am considering for my own build) is to get a stepper motor with built in planetary gear reduction. I don't know what space limitations you are working with, but this might still fit your requirements (random ebay pick to show what I mean) : https://www.ebay.com/itm/Extruder-G...397028&hash=item4896881c77:g:tN8AAOSwM8ZZeZ9G

For your backlash issue, it would be possible to program in "backlash correction" but only if the backlash is constant. For example, if you had to advance exactly 8 steps every time to take out the backlash, this could be programmed in, but if it varied among 7,8,9 steps then I don't see how to correct for that. I'm assuming the backlash in your system is in the rotary table gears, so is maybe fairly constant. But it could also drift over time, so you might have to reset the backlash correction every time you use the table.
 
OK I was missing something. If you have a known amount of lash it is easy to compensate for. Take my earlier example of a 45 degree arc. You would first set up for the 45 degrees, plunge in and then cut. You then exit out and set up for 45.5 degrees (.5 degrees of lash compensation) and reverse. You can now move forward and back as you will be compensated with each reversal. You would just need to keep track of your last move for your next operation to know which direction your lash is in.

Though increasing voltage and reducing micro-stepping will increase torque it appears it is not sufficient to overcome the friction of near zero lash with my current motor. That being said I would be dubious of a planetary gear reduction as it would induce additional mechanical lash through the gear train.

The reason I suggested programmable lash compensation is for the same reason you use it on a cnc with lead screws. Lead screws require a bit of clearance unlike ball-screws. Usually you try to remove as much mechanical lash as possible and then measure what remains. This is easy to do on a linear axis with a dial indicator. Once the amount is determined you just insert the dimension in the software like Mach 3. I suppose you could do the same with the rotational axis using trial and error until the indicator showed zero. Though lash will increase over time due to ware, It just requires occasional inspection and adjustment like any other system.

My real issue is the programming end! I am still trying to work out visual basic for the tool changer I built. In addition I have been reading about c and c++. It is a lot to learn.

Jeff K.

Everything is easy once you know how!
 
Personally, I would not bother about backlash compensation for indexing on a rotary table. Its easy to work around just by taking it up before you start machining and always move in the one direction just like we take up backlash on a manual machine. The only time it could possibly be an issue is if you are milling a slot on an arc but if it was too much to bear, you could just add a bit onto the angle you are cutting.

For the budding programmers out there I strongly recommend you skip Visual Basic and go straight to C or C++. If you have an environment that mandates Visual Basic, find another environment. Usually, you can interface to external DLLs etc with either language. C is just so much more efficient when you want to get things done!

If you need a scripting language, then consider Python which is used in LinuxCNC. Google has a week long recorded Python programming course to get you going. What might take 1000 lines in C, you can often get done n Python in under 100.
 
Jeff -

I think my revised Sketch could be modified without too much work to add backlash correction. With my mechanical set-up, I don't have a good way to test, but if you are interested I can make the modifications and share them with you for testing. Let me know if you are interested.
 
Attached is the latest version of my sketch. The sketch allows the table ratio, steps per revolution and the step delay to be entered and stored in EEPROM. I've added a selection to the first menu to select Settings. The settings can be stepped through without changes by just pressing the "#" key. Unless I've broken something, it should work on a UNO.

View attachment EEPROM_2118-2.zip
 
Hi.
I'm completly new to all this but thought I would have a go. I downloaded bmac2's sketch onto my Arduinno R3. If I change the steps per rev to 200 & Table ratio to 90 ( for my Vertex RT) it works OK. But when I change steps per rev to 400 ( for half stepping) and ratio to 90 I just get "moving " on the LCD for a fraction of a second and Steps = 7380 but no pulses to the stepper motor driver (TB6560 set for 1/2)
Has any one had it working for 400 steps 90 RT ratio?

Thank You
Ian

PS .
I tried tjwal's latest sketch which loads OK but does not respond to key pad.
 
Back
Top