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.
My rotary table has a 72:1 table ratio, NEMA 17 1.8 degree stepper motor - 200 steps per rotation , a 5:1 reduction... I can not get the table to rotate to the correct position. example with a 45 degree input the table only rotates about 10 degrees.

72 by 5 by 200 gives a number too large for the code to handle (72000) It'll choke on a full turn . 200 steps per degree have to change the setup a bit to handle the math


from
const int StepsPerRotation = 200;
const int TableRatio = 360;
to
unsigned long StepsPerRotation = 200;
unsigned long TableRatio = 360;

Might be more in the code that would have to be changed - BUT - your timing belt - It's going to bite you sooner of later. Chips will cut the belt eventually. Better off fabbing a direct mount - i.e.
DSCF0306.JPG


Boo Boo in my direct mount - the open slot in the top lets chips in, piece of tape settles it.
Direct mount better, makes math easier . .
 
Thanks for your reply.
I believe you are correct, change the mounting of the stepper motor to direct drive. Thought that may be the solution but I wanted to post the problem out to the community for comment and direction.
 
[QUOTE="anderi, post: 316174, member: 37607"<ship>
This gives 24*400=9600 steps for a complete turn. For 57 teeth you get 9600/57=168 steps per tooth but with a remainder of 24 steps. To make a complete 360 degree turn they have to be added to the 57*168 steps. In the program I referred to he spreads the 24 extra steps by inserting them as evenly as possible during the cutting. There will be a small error on some teeth but it is so small it falls within the tolerances.
The Arduino should be capable of making the calculation and to distribute the extra steps if someone who is familiar with the program could modify it.[/QUOTE]
Anderi
The code I posted in message 149 distributes the error.
The original code does what you describe, it calculates the number of steps per division and uses that amount for each tooth. As such the error adds up like you describe.
The approach I used was to calculate the total number of steps for each tooth. For your example it would calculate and move 168 steps for the first tooth. For the second tooth it would calculate 2*9600/57=336.8
This would be rounded to 337. Since the first tooth is already at 168 steps the program would calculate that an additional 169 steps is required to get to the second tooth. It continues to do this for all 57 teeth. Assuming I’ve coded it correctly there should be no more than ½ step error at each tooth.
Sorry for the long explanation but talking code can get me excited.

Cheers
John
 
Me thinks that the OP failed to post the edition where his wife told him to go pound sand. As is the case with mechanical indexers the gear ratio in the table will impose limitations. Therefore not all index patterns will be possible without cumulative error. The higher the resolution the less the error will be. All of my experience has been with closed loop drive systems so I know nothing about stepper motors other then that they typically have a very low resolution. Below is a program that I wrote for setting up a dividing head with an internal gear ratio of 40:1 which is the common gear ratio. Rotary tables have a 90:1 gear ratio. If interested then download the attached .TXT file and change the extension to .EXE

NOTE: Norton and other anti-virus programs now recognize Win 32 files as being a virus. I contacted Norton about the problem and the agent asked permission to take control of my computer. I agreed and the agent ran Norton Power Eraser on my computer. When my computer rebooted then I was advised that my computer was now safe. My desktop was missing a **** load of icons and that was when I figured out what the GEN 32 virus was because Norton Power Eraser deleted every one of my programs that I wrote for my needs. I gave that Norton AV agent a big piece of my redneck mind and I'm sure that I expanded his Indian vocabulary. Fortunately I had back up files on other computers.

upload_2018-12-30_8-34-7.png
 

Attachments

  • DIVIDING HEAD SETUP.TXT
    44 KB · Views: 688
I'm not sure the stepper motor resolution is much of a problem as long as the resolution errors are not cumulative, which can be accounted for in the code. Keeping track of accumulated error and accounting for it at each calculation should result in plus or minus one step (or one microstep) for any graduation. Even with a direct 1-to-1 drive (which I assume nobody is using direct drive), a 200 step stepper motor running microstepping to 800 steps-per-revolution equates to a maximum error of 0.225 degrees. Add in a 40:1 reduction and the maximum resolution error drops to less than 0.005 degrees.
 
Hi
Working out fractional steps to keep within tolerance should use of floating point multiplication included in the Aduino language.

For the rotary table problem, probably the best solution is to calculate the steps from a zero reference point to get to each division,
then keep a cumulative total of the steps actually moved from the reference.
The next division would be calculated by taking the difference between the current position ( = steps taken from reference ) and the next division ( = steps from reference to next position).
Then round solution to calculate the step count.

This is computationally inefficient because each step requires multiplications but it avoids having to account for cumulative errors. Basing all calculations from a starting reference point prevents cumulative errors.
 
The attached file contains the arduino sketch I wrote for my dividing head. The math algorithm is written to assure that the 0 (zero) location always winds up at the same point of rotation. As it moves, it recalculates the position from zero so no matter how many times it goes around or back and forth, it maintains positional integrity. The algorithm should work for your rotary table as well.
Chuck
 

Attachments

  • dividing_head.zip
    2.3 KB · Views: 809
Chuck, Thanks again for sharing your work with the forum. Back when you first posted it, I modified your code to work with my 4" rotary table. I used that setup for quite a while making gears.
Then I got the idea to add a 4x4 matrix keypad to enter data rather than the 5 button LCD setup. A fellow(no pun intended) named Bob Pratl posted a code using such a keypad. I played with the 2 versions until I had one that worked with my configuration. I really like it and use it often. Thanks again for providing the inspiration.
 
You're welcome, Chuck. I guess I just like to show off... :)
 
Hi

For the rotary table problem, probably the best solution is to calculate the steps from a zero reference point to get to each division,
then keep a cumulative total of the steps actually moved from the reference.
.
That’s the method I use in the version I posted in message #149.

I modified the code posted by Bmac to get rid of the cumulative error. While I was at it, I made a few other changes which I hope are improvements.

Many thanks to bmac and everyone else who were involved in the evolution of this code.
 
Hello bmac2,
Thought I would give your project a quick whirl.
bought the components but settled for a cheap stepper for testing purposes as my stepper motors did not match the driver board.
Had fun assembling and installing the program.
Fired it all up and hey presto it works.
Unfortunately I am not getting on with the build of my Locking lever frame, but heyho its cold outside.
Now to find a box, and maybe a decent stepper at the Ally Pally Model Engineering show London.
Keep up the good work.
Nigel
UK
 
I have been reading this post with huge personal interest since I have developed a 32 bits controller successor to the 8 bits Arduino controller. I will be posting my topic "Cheap 5 axis G-code controller" separately. So look out for my post. Enjoy!

Feedback question:
It would be really great to get some feedback from machinists why there is so little uptake in it despite a successful Kickstarter. I still see posts and videos with stepper solutions based on a PC with basic parallel port solution with no intelligence (240 Aussie pesos) and Mach3 (licence 600 bucks) which is way more expensive than my controller assembled and further Grbl Arduino's which are cheap but limited in functionality (32kB memory ceiling and 30kHz step freq.).

For those interested: I added 2 more axis (5 in total), a soft start spindle feature (pwm from 60Hz upto 80kHz), M6/Tn ATC support, onboard spindle motor drivers (150/750W), step sticks capable of driing 4 Amp stepper motors. All opto coupler based i/o for those with a plasma cutter.
 
I have been reading this post with huge personal interest since I have developed a 32 bits controller successor to the 8 bits Arduino controller. I will be posting my topic "Cheap 5 axis G-code controller" separately. So look out for my post. Enjoy!

Feedback question:
It would be really great to get some feedback from machinists why there is so little uptake in it despite a successful Kickstarter.
Often getting the word out is a big factor. In some cases it represents a significant cost per device. So in my case this is a relatively new device.
I still see posts and videos with stepper solutions based on a PC with basic parallel port solution with no intelligence (240 Aussie pesos) and Mach3 (licence 600 bucks) which is way more expensive than my controller assembled and further Grbl Arduino's which are cheap but limited in functionality (32kB memory ceiling and 30kHz step freq.).
Actually I have no idea what 240 would be in US dollars. Here in the USA Centroid has a DIY solution that starts at $299 right now. Centroid has been into CNC control for decades now so has a very robust CNC solution. There are other GRBL ARM ports running on far cheaper hardware. Beyond that it is uncertain where official GRBL is going as far as ARM support goes. If one wants to remain in the GRBL community then that would mean staying with the official tree.
For those interested: I added 2 more axis (5 in total), a soft start spindle feature (pwm from 60Hz upto 80kHz), M6/Tn ATC support, onboard spindle motor drivers (150/750W),
I really have no idea why people would stick a motor controller on a logic board. It seems to have become a thing of late but in my estimation it just reduces flexibility. The same pretty much applies to steppercontrol too. The last thing I’m looking for in a board is integrated motor control.
step sticks capable of driing 4 Amp stepper motors. All opto coupler based i/o for those with a plasma cutter./

In don’t want to appear unkind but that web site doesn’t inspire a lot of confidence. Honestly it is a mess! Of course this is personal preference but if I find a web site frustrating I don’t do business with that company if I can help it.

In any event one of the biggest problems small companies have is product promotion. That can mean many things but almost all of them cost money. For example this weekend I braved blizzard to go to a model engineering expo. While the trip was cut short due to the weather, I did spend a few minutes with some vendors handling DIY CNC hardware. That is a very good way to get your name out there and converse with potential customers, it is however expensive. A far cheaper alternative is to send out free samples to sites that will review your product.
 
Actually I have no idea what 240 would be in US dollars.
About $140-160 USD.

In don’t want to appear unkind but that web site doesn’t inspire a lot of confidence.
This is important feedback which I am after so I can action it. What is it: text, format, relevance, lack of photos/information?

loose Flexibility
This great to hear since the board provides that flexibility for drivers on board or just leave them out and use external drivers. All ports have been provided as breakout connections. The PWM for a VFD is 5/10V opto coupler. So will update the description.

That is a very good way to get your name out there and converse with potential customers, it is however expensive.
Yes, I am already doing so. Next Makerfaire in the USA is on my itinerary. My first product sold on the spot at the Bay Area Makerfaire 2017. Australia is just very small for this kind activity and we hardly have Makerfaires (23M people dispersed over a country as big as the USA).

A far cheaper alternative is to send out free samples to sites that will review your product.
Yes, we have contacted various Vloggers (never got a single reply) and I guess just mailing them a controller might be easier. They might throw it in the bin or review it...I guess it's worth it.
Thanks for your reply, I really appreciate it.
 
Last edited:
Good evening gentlemen. I'm jumping threads and I hope it's ethical. I started the thread "Servo Feed For A Lathe Compound". The replies overwhelmingly kept referring me to this thread and I became fascinated with the idea. I have temporarily abandoned the compound feed and turned my attention to fitting my 8" rotary table with a stepper motor. I have read and re-read these posts and several others and have purchased the components to modify the table.
By following bmac2's instructions I have been able to get the basics working but now I'm up to connecting the stepper driver and I ran into a snag. I'm using a "Longs Motor DM542A" driver and I'm confused about comparing the Arduino wiring connections between the TB6560 driver described in this thread to the connections on the DM542A.
This is the way that the TB6560 is supposed to be connected:
img_1905-jpg.88567


These are the corresponding connections on the DM542A:
upload_2019-3-10_18-43-40.png


The first shows nothing connected to the EN(able) terminals. I thought that they would get a 5-volt supply connection. What corresponds to what? I'm assuming that PUL means pulse and DIR means direction. How do they cross to CW and CLK? Do I jumper the DIR- and PUL- terminals and connect them to Arduino GND? And which ones do I connect to D2 and to D3 on the Arduino?
Hopefully this is a question that you are just shaking your heads at and it will have an obvious (to you) answer. I have gotten this far without letting the smoke out of anything and I figured it would just pay to ask.
I have built a mount for the motor with the flex coupling and moving parts enclosed in a piece of 4" x 1/2" wall aluminum tubing and it moves very smoothly and is ready for power to see what happens.
upload_2019-3-10_19-5-27.png
 
Hi,

I'm assuming that PUL means pulse and DIR means direction. > Yes it does mean PULSE (stepper pulses) PUL=CLK
How do they cross to CW and CLK? > CW means Clock Wise or in other words direction. CW=DIR
Do I jumper the DIR- and PUL- terminals and connect them to Arduino GND? > Yes these are the grounds. The stepper driver uses opto couplers which need a return path.
And which ones do I connect to D2 and to D3 on the Arduino?> These are the clock stepper pulses so they go to PUL+ (you need two drivers for two axis)
#define X_STEP_BIT 2 // Uno Digital Pin 2
#define Y_STEP_BIT 3 // Uno Digital Pin 3
Pin layouts are described here https://github.com/gnea/grbl/blob/master/grbl/cpu_map.h

I have written an article about the setpper driver which might give you some help too: https://www.instructables.com/id/Eagle-Hackstricks-Example-TB6600-CNC-Mill-Stepper-/

Also check out my other projects like Super Gerbil...
 
I found a copy of the user manual here
https://images-na.ssl-images-amazon.com/images/I/718BBSVkxPL.pdf
Use the connections shown in figure 2, pul-, dir- and ena- are connected to ground.
The corresponding pulse and dir will be asigned to the Arduino pins in your code.
The driver I use in enabled when ena+ is either held to ground or is left open. It appears
Ena+ must be held high to enable the DM542. You could try it both ways, it won’t hurt anything.

John
 
Back
Top