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.
Hi bmac2, Thank you for producing a great explanation,I was considering trying out a rotary indexer but balked at the electronics side of it.
Will try it.
Allen
 
Hi Allen, I’m glad you like it. I’ve just been running it with the original sketch though Foozer, rodw, tjwal and others have put a lot of work into rounding errors. My setup is a little too dodgy to worry about getting to 9 decimal places.

[ame="https://www.youtube.com/watch?v=65NOxiFHoQI"]https://www.youtube.com/watch?v=65NOxiFHoQI[/ame]
 
Bob
Your original code declared Multiplier as an integer
const int Multiplier = (StepsPerRotation * TableRatio)/360;

Depending on the values for Steps and Table this can result in a significant error. In my case I am using a TableRatio of 4. With 800 steps, Multiplier should be 8.888... truncating it to an integer gives you 8, which is in error by over 10%. I believe you have a TableRatio of 36, which does not result in any truncation so you wouldn’t have noticed an error.

Changing Multiplier to a float as per billanygard’s post#70 fixes the Multiplier truncation error.

After that, you’re correct, most of the changes just add precision which might not even be noticeable. I believe my version of the code is like Chuck F’s code in that it distributes errors as they accumulate. In theory this should be more accurate but without a side by side comparison I don’t know whether it is noticeable.

I do like the keypad interface of your version over Chucks button interface.

Thanks again for the great construction tutorial.

John
Ps. My table ratio is actually 4.2, but knowing how the calculation works, I can enter it as 42 and my steps as 80
 
Hi Bob
First thanks for this thread. Ok so I got all the parts put everything together the lcd display works, keypad works able to scroll and enter degrees etc and direction but nothing happening on the step output it flashes “moving” for a split second put scope on direction it changes state but no step pulses.
I’ve tried 2 Arduino boards still nothing also reloaded program several times. Any ideas
 
Hi Bob
First thanks for this thread. Ok so I got all the parts put everything together the lcd display works, keypad works able to scroll and enter degrees etc and direction but nothing happening on the step output it flashes “moving” for a split second put scope on direction it changes state but no step pulses.
I’ve tried 2 Arduino boards still nothing also reloaded program several times. Any ideas



Figured it out won’t work if you put 400 steps per rotation for some reason
 
Figured it out won’t work if you put 400 steps per rotation for some reason

I'm not really familiar with this software or your hardware but most stepper motors are 200 steps per rev. If you set the software up to be 400 steps, that could be double the speed which might be more than the stepper can handle (most of them peak out at about 400-450 rpm). After this point, they do nothing (except maybe make some high frequency noise)
 
I'm not really familiar with this software or your hardware but most stepper motors are 200 steps per rev. If you set the software up to be 400 steps, that could be double the speed which might be more than the stepper can handle (most of them peak out at about 400-450 rpm). After this point, they do nothing (except maybe make some high frequency noise)



Installed the sketch that tjwal modified and everything works perfectly’ I have a 90 to 1 table so the calculations would not work with original sketch set to 400 steps. I’m an old guy learning new things. Thank you
 
Installed the sketch that tjwal modified and everything works perfectly’ I have a 90 to 1 table so the calculations would not work with original sketch set to 400 steps. I’m an old guy learning new things. Thank you



Did 400 steps work with my version?

With the original sketch 400 steps with a 90:1 table ratio will likely have an issue with integer overflow. I used double integers so overflow shouldn’t be an issue.

How fast is it with your 90:1 table? I didn’t implement accelerations so by default the stepping speed is fairly slow.

Cheers
John
 
Did 400 steps work with my version?

Cheers
John

I had a look at the code. there are a number of undefined type conversion which could catch you out. eg as one example

Code:
ToMove=(bob/360) * Multiplier + 0.5 - cumSteps;

Should be more like
Code:
ToMove=(long) ((bob/360.0) * (float) Multiplier + 0.5 - cumSteps);

If the compiler sees 360 it will probably think its a long or int but if its 360.0, it knows its a float as it has a decimal point. Also you are doing float maths but assigning the result to a long at the end plus Multiplier is a long used in a float formula. You must program defensively. I've been caught so many times with odd results due to incorrect type conversions.

Probably Multiplier should be defined as a float as thats how it is used.

In some languages, type conversion is automatic but in C it isn't. Don't depend on the compiler to do it for you. It might not get it right every time. Treat every compiler warning as if its a bug and eliminate it.
 
I had a look at the code. there are a number of undefined type conversion which could catch you out. eg as one example



Code:
ToMove=(bob/360) * Multiplier + 0.5 - cumSteps;



Should be more like

Code:
ToMove=(long) ((bob/360.0) * (float) Multiplier + 0.5 - cumSteps);



If the compiler sees 360 it will probably think its a long or int but if its 360.0, it knows its a float as it has a decimal point. Also you are doing float maths but assigning the result to a long at the end plus Multiplier is a long used in a float formula. You must program defensively. I've been caught so many times with odd results due to incorrect type conversions.



Probably Multiplier should be defined as a float as thats how it is used.



In some languages, type conversion is automatic but in C it isn't. Don't depend on the compiler to do it for you. It might not get it right every time. Treat every compiler warning as if its a bug and eliminate it.



Controller not mounted to table yet, that’s up next.

View attachment IMG_1512614970.327171.jpg


Hey if I don’t have turn a crank it’s fast enough!
 
I built this and had trouble getting the steps right. In the end I // some of the code so it is closer to steps per degree.

This was an awesome starting point for me just needs more tweaks.
Les
 
Just want to thank you for an awesome write-up. I've been wanting to learn more about stepper motors, and I am also interested in building an indexer, so your post hit every target.
 
I have a question,would a 250 watt 12 volt ATX power supply have enough amps to power the electronics package and a nema 23 57BYGH310 stepper?

ATX:

Dell HP-P2507F3B

120v 6a input
5v 22a output
3.3v 18a output
12v 14a output

24.0 kg-cm (333.2 oz-in) 4 Wire NEMA 23 Stepping Motor;


  • Step angle: 1.8°
  • Voltage (V): 8.6
  • Current (A): 2.0
  • Resistance (Ohms): 4.3
  • Inductance (mH): 16.2
  • L0 Dimension (mm): 76
  • L1 Dimension (mm): 21
  • Holding Torque (kg.cm): 24.0


I'm thinking it would, but then again I've made the magic blue smoke more than I care to.


I want to use an ATX power supply because it has the 3.3, 5 and 12 volt rails, and the purple wire that is 5v always on if plugged in, I connect it to a usb and use is as a usb phone charger, when ever I use one of these. I have lots of these lying around cause I pick up discarded computers for them.
 
In my experience, even 24 volts is not enough. Go 48 volt if your controller can handle it!
 
It will work but your torque will drop off dramatically as your rpm goes up. With every step the current in each phase has to go from maximum in one direction to maximum in the other direction. Higher voltages are needed for this to happen quickly. If you’re using an Arduino the pololu drivers are supposedly good up to 2 amps and are rated for 36 volts. They have current limiting so won’t supply any current above their set point. You can adjust it to a lower value if you don’t require full torque. At the higher current levels they do run extremely hot. If you need full torque you’re better off with a separate high voltage driver like Rod suggests.
 
I'm not using pololu drivers, I'm using the stepper driver based on the Toshiba TB6560 chip.

The data sheet says voltages above 24 volt isn't recommended.

The ATX would give me 24 volts across the +12 and -12 volt rails, unless I can't do that with an ATX power supply.
 
I'm not using pololu drivers, I'm using the stepper driver based on the Toshiba TB6560 chip.

The data sheet says voltages above 24 volt isn't recommended.

The ATX would give me 24 volts across the +12 and -12 volt rails, unless I can't do that with an ATX power supply.

A couple of problems come to mind

First the -12v typically has a low current rating. I looked at one of mine and the -ve rail is only good for 0.8 amps. That’s not enough to adequately drive your stepper.

The second issue is that the ground of your driver board will be at -12v. The +5 from the supply is now +17 v when referenced to the driver. If you’re using the +5 to power an Arduino or something else connected to the driver then unless the grounds are kept separate you will be shorting out the -12v rail.
 
Hi clifwst.
“would a 250 watt 12 volt ATX power supply have enough amps to power the electronics package and a nema 23 57BYGH310 stepper”

Yes of course it will. The Manufacturer of your stepper rates it to operate at 2amps, 8.6Vdc. Limit the current to 2 amps and it will run all day on the 12 volt output from the AT Supply.

Upping the voltage is preferred IF you are going to be using micro stepping, but if you are planning to use a rotary table I personally don’t see any need to go below quarter step.

Microstepping increases the resolution at the stepper and is advantageous with an indexer with a low mechanical reduction but comes at a cost of a reduction in torque and speed.

https://www.micromo.com/technical-library/stepper-motor-tutorials/microstepping-myths-and-realities

If I remember correctly Diller’s rotary table is 90 to 1. Set to quarter step he would be sitting at 72,000 steps per revolution with tons of torque.

I’m using a high torque Nema 17 stepper set to quarter step with a 36 to 1 table ratio. The stepper is running off 12 volts with the current limited to .6 amps. This gives me 28,800 steps per revolution. I’ve cut dozens of gears (and they work) and find myself using it more and more for milling so long as the piece will fit on the little 3 inch table. And yes lite cuts 5 or 10 thou max.

Sorry to any one I may offend but with 80 steps per degree of rotation if it drops a couple through rounding errors I just don’t care. It cost less to build than buying a single dividing plate, I don’t have to turn the crank and it doesn’t lose track of the number of holes.
 

Latest posts

Back
Top