# Arduino based rotary controller project



## revwarguy

I've built a stepper motor driven indexing controller made from off the shelf parts of an arduino, stepper controller, and a display shield for the arduino.

It's use, build log and video of operation is described here, and it will be included as an article in Digital Machinist shortly.  The code for the arduino will be available from the magazine's website.


----------



## PurpLev

pretty cool. thanks for posting


----------



## arlo

revwarguy said:


> I've built a stepper motor driven indexing controller made from off the shelf parts of an arduino, stepper controller, and a display shield for the arduino.
> 
> It's use, build log and video of operation is described here, and it will be included as an article in Digital Machinist shortly.  The code for the arduino will be available from the magazine's website.
> 
> View attachment 67754


Yesterday, I got serious about restoring the Denford micromill I bought at an auction three years ago.  After a few hours of studying schematics and researching on-line, I got the X and Y axes to move manually and could control the number of steps and the direction.  Man, was I excited.  The Z axis connnector had been ripped out of the stepper, so some careful resoldering was required.  Either my rewiring wasn't careful enough or a pre-existing Z axis problem was the reason the machine was auctioned.  In any case, when I plugged it back in, one of the output drivers burst into flames.  And now I'm back at square one (or maybe some large negative number). 

 I've spent the last 24 hours debating whether to tear the whole thing apart and basically rebuild it OR to build my own design using the two good steppers, spindle and table along with an Arduino/Raspberry Pi based H bridge controlled power supply.  Your brilliant post is perfectly timed for me. I'd sure read any of your updates religiously.  Thanks for your hard work.


----------



## revwarguy

arlo said:


> I've spent the last 24 hours debating whether to tear the whole thing apart and basically rebuild it OR to build my own design using the two good steppers, spindle and table along with an Arduino/Raspberry Pi based H bridge controlled power supply.  Your brilliant post is perfectly timed for me. I'd sure read any of your updates religiously.  Thanks for your hard work.



Thanks, Arlo.  From your post, though, I am not sure what you are planning - do you want a full 3 axis CNC machine?  If so, then the stepper driver I used in my first post might not be good enough for that.  I chose it because it was cheap, and for my application there is no need for speed or much torque to speak of.  If I were going to CNC a mill, where speed and torque do matter, I would use a better stepper driver, like a Gecko g540 or bigger, depending on the kind of mill you have.  Also, you would probably need a full PC to run Windows/Mach3 to drive the thing as G-code interpretation and bit diddling a parallel interface is very compute intensive, beyond the capability of my Arduino, so far.  (I am showing my experience, er, bias, here in that the computer could also be running Linux and LinuxCNC - but AFAIK a Raspberry Pi also doesn't have the horsepower for that, either, but I could be wrong about that since I don't follow that world much.)

Anyway, there are lots of guys that converted their mills to CNC - there are forum groups on CNCZone.com or Yahoo groups or Google groups that discuss just that.

I don't want to discourage innovation here - if you really do want to try to use the setup to do something in between manual and a full CNC - kind of like a smarter power feed/DRO on each axis, then this might be a good place to start, but I would look at enhanced speed control, and some feedback for end stops and/or home positions.   (I built my own power feed on my mill, shown here, but I used a cheap gear motor, not a stepper.  I guess you could swap that with this setup.)

If you did this, your out-of-pocket would be about the same as for a full Linux CNC, though, but now you need to deal with the world of CAD.


----------



## arlo

My Denford is based on Sherline similar to this http://www.use-enco.com/CGI/INPDFF?PMPAGE=524&PMITEM=505-6694 but with Denford electronics and motors.  The steppers are 2 amp Nema 23.  I think the steppers in my machine are operational but I did order a NEMA23 Stepper with 185 oz in holding torque.  I think the motor you used had a holding torque of about 80 oz in. I got this to replace the motor with the damaged connector on the Z axis in case it has bigger problems.  I think I'll counterbalance this axis to further reduce the load on the stepper.

My initial goal is 3 axis DRO with manual jog in all three directions and spindle speed control/read-out.  You raise good issues about the Arduino's limited capabiities if I want a true CNC.  I think there are alternatives that I'll consider once I get a better handle on my processing requirements.  The Arduino Mega would provide some more processing than the Uno and I think both the Beagle Board Black and the Raspberry Pi could be suffiecient.  Another approach is to write the Gcode on a desktop and then transfer the raw coordinate data to the mill via an SD card read by the arduino.  And of course, there's always Blue Tooth and 801 wireless.


----------



## revwarguy

_"My Denford is based on Sherline similar to this http://www.use-enco.com/CGI/INPDFF?PMPAGE=524&PMITEM=505-6694 but with Denford electronics and motors.  The steppers are 2 amp Nema 23.  I think the steppers in my machine are operational but I did order a NEMA23 Stepper with 185 oz in holding torque.  I think the motor you used had a holding torque of about 80 oz in. I got this to replace the motor with the damaged connector on the Z axis in case it has bigger problems.  I think I'll counterbalance this axis to further reduce the load on the stepper."_

The stepper I used is # 57BYGH310 at Circuit Specialists and has a holding torque of 24 kg-cm which is 333 oz-in.
_
"My initial goal is 3 axis DRO with manual jog in all three directions and spindle speed control/read-out.  You raise good issues about the Arduino's limited capabiities if I want a true CNC.  I think there are alternatives that I'll consider once I get a better handle on my processing requirements.  The Arduino Mega would provide some more processing than the Uno and I think both the Beagle Board Black and the Raspberry Pi could be suffiecient.  Another approach is to write the Gcode on a desktop and then transfer the raw coordinate data to the mill via an SD card read by the arduino.  And of course, there's always Blue Tooth and 801 wireless_."

The Mega should be able to do it - come to think of it, most reprap 3d printers use a Mega Arduino with a stepper driver shield, like a RAMPS or RUMBA, and they do g-code interpretation as well as pulse drive their steppers.  

I've also seen some interfacing to be able to read the inexpensive units like I used for the DRO's on my mill, shown in the link below.  If the Arduino could read those, it could get and display position, as well as have positive feedback on movement.  I would lean toward a larger more graphic display than the 2x16, though.  There may not be enough control pins for everything, though, especially if you want to have a pendant-type control box.

PS Love Dayton, been to Wright-Pat many times


----------



## arlo

The stepper I used is # 57BYGH310 at Circuit Specialists and has a holding torque of 24 kg-cm which is 333 oz-in.

_I missed this motor when I visited Circuit Specialists.  It sound much better than the one I ordered so I've ordered it, too._

PS Love Dayton, been to Wright-Pat many times 		

_Coincidentally, I bought my Denford via on-line auction from the Springfield, Missouri school district._


----------



## arlo

I'm still waiting for my components to be delivered but I have come up with a few questions:
1.  Is protecting the motor controller from voltage spikes done on the controller circuit board?  The schematic I found at Sainsmart isn't very clear but does not show discrete diodes/capacitors on the motor outputs. I've looked at the Toshiba literature but it isn't clear how the 6560 protects itself.  It shows pin 19 as "Protect" but the notes say this is an output.  Should I be concerned with providing protection against voltage spikes?

2.  In my recent stepper motor education I've found a couple of sites that recommend controller voltages that are 5 to 10 times higher thant the stepper motor rated voltage.  The stepper you're using (and one that I've ordered) are rated at 8.6 volts.  Is there a reason that your power supply is 12 volts?  

3.  In your video, there is a semi-conductor hanging between the Arduino and the controller board.  Is this the second thermal sensor.


Thanks again for your write-up.  So far I've figured out how to energize my spindle and I've rigged up a test using DPST switches to test my original Z-axis stepper.  Using this test set up, I've learned that the stepper works correctly and that my probme must have been in the Denford motor driver.

arlo


----------



## revwarguy

arlo said:


> I'm still waiting for my components to be delivered but I have come up with a few questions:
> 1.  Is protecting the motor controller from voltage spikes done on the controller circuit board?  The schematic I found at Sainsmart isn't very clear but does not show discrete diodes/capacitors on the motor outputs. I've looked at the Toshiba literature but it isn't clear how the 6560 protects itself.  It shows pin 19 as "Protect" but the notes say this is an output.  Should I be concerned with providing protection against voltage spikes?



The TB6560 driver is not a great driver - I chose it primarily because it is inexpensive and this application is probably the least demanding of stepper performance that I can think of, making them a good fit.  I can report that I've played with this thing quite a bit and haven't had any failures with it. However, DON'T disconnect the stepper from the driver with the power on - this is true for ANY driver, with protection or not!  I haven't actually tried that, but then again, I know better!  If you want to upgrade to a better driver, I can heartily endorse the Gecko drives that are out there, as I use them for my CNC work but they are 3-4x in cost.



arlo said:


> 2.  In my recent stepper motor education I've found a couple of sites that recommend controller voltages that are 5 to 10 times higher than the stepper motor rated voltage.  The stepper you're using (and one that I've ordered) are rated at 8.6 volts.  Is there a reason that your power supply is 12 volts?



Going to a higher voltage will make the stepper more efficient as well as increase its top speed.  Do we really need that in this application?  Speed wasn't much of an issue here for me.  I chose 12v because the Arduino only goes up to 12, and I wanted to keep it simple with a single supply.  There is a 24v version of the Arduino, called a Taurino, which would let you double the voltage if you feel you need to without changing anything else. Or, you could use an even higher voltage (up to the rated limit of the driver) if you broke off the Arduino's 12v with a 7812 regulator or any other dual voltage power supply kind of arrangement.



arlo said:


> 3.  In your video, there is a semi-conductor hanging between the Arduino and the controller board.  Is this the second thermal sensor.



Yep, I just hadn't had a chance to use the thermal epoxy to adhere the temp sensor to the heatsink before I shot that video.  I have seen little to worry about in terms of overheating, so you can skip the temp stuff if you want, but the sensors are very cheap and I like to be able to measure things.  Perhaps in the next version of the software I'll make the temp mode easily removed from the firmware at compile time.

Good questions! Let me know when you get your parts!


----------



## arlo

Thanks for your response.

I regularly see threads about sharpening drill bits. There's an interesting one going right now. Have you considered the possibility of adapting your digindexer to this?  I sometimes try to sharpen bits by hand but I agree 100% with the davidh's comment that "I don't have enough Saturdays left in my life".

Could the indexer be set at the proper angle on the mill table and then rotated to the proper orientation.  With a grinding stone in the mill, advance the table to grind.  Retract, rotate exactly 180 degrees (using the digindexer's accuracy) and repeat?  Maybe a similar process would work for mills with the rotation a function of the number of flutes.

Or is the initial angular/rotational alignment too difficult to get accurate enough?


----------



## revwarguy

arlo said:


> I regularly see threads about sharpening drill bits.   I sometimes try to sharpen bits by hand but I agree 100% with the davidh's comment that "I don't have enough Saturdays left in my life".



I guess I have to agree with davidh, especially on the smaller bits. Larger ones are sometimes worth sharpening though.



arlo said:


> Could the indexer be set at the proper angle on the mill table and then rotated to the proper orientation.  With a grinding stone in the mill, advance the table to grind.  Retract, rotate exactly 180 degrees (using the digindexer's accuracy) and repeat?  Maybe a similar process would work for mills with the rotation a function of the number of flutes. Or is the initial angular/rotational alignment too difficult to get accurate enough?



Offhand I could could think of some simple jigs to do a 180 alignment of a rotating collar or chuck that doesn't need steppers, etc. but the step indexer would surely turn it accurately enough.  I would be concerned that, depending on the angle presented to the wheel, that the stepper has enough holding torque to keep the bit locked in place - you might need a brake on it.


----------



## Rbeckett

Arduino is such a nice platform to work from. The plethora of different shields and available open source code makes project development a real breeze.  Usually you can go from proto to working hardware in one or two sittings as long as what you require is fairly common.  The available code is astounding and all you have to do is a quick search and you can usually get a snip or enough code to get going pretty quickly.  The beauty of that is most of the bugs have been found and worked out already so it becomes an exercise in cut and paste and logical progression.  I also work with the much slower Picaxe platform and I have been experimenting with PIC Microcontrollers using C and C++. But I really prefer the Arduino and picaxe platforms for ease of use and easy prototyping.

Bob


----------



## revwarguy

The Digital Machinist Article is now out, and if anyone is interested the Arduino code for the project is available at www.digitalmachinist.net and select the "Interactive...Downloads" menu items, and the right download for the Winter 2013/2014 issue (Vol8 No4).  Support for the project is at http://bbs.homeshopmachinist.net/forums/9-Digital-Machinist

Thanks,


----------



## arlo

Thanks for providing the code.  I got it to compile the first time and the quantity of comments is great.


----------



## revwarguy

I finished an enclosure for the project, shown below.


More about the box at http://www.liming.org/millindex


----------



## revwarguy

There is an update to Step Index available, version 2.2.  You can download it from the Digital Machinist website, and there is more info about it and an update video on the website given in the last post.


----------



## Charley Davidson

I already have the steppers, driver & power supply, Benny is ordering the rest of the needed components this week so him & I are building one at the same time. I may have to build 2 as I have 2 RT's or make it so I swap the drive mechanism between the 2.

Thanks for this thread & links.


----------



## Charley Davidson

To clarify I plan on using this to turn my rotary tables


----------



## revwarguy

Charley Davidson said:


> To clarify I plan on using this to turn my rotary tables



That should work - I presume that both of the tables have the same gear ratio (usually 90:1 or so) but if not the recent version allows you to specify different ones you can select from at run time.  

However, you may want to eliminate using micro stepping.  With 16 microstepping, you have 16*200*90 steps per revolution, or 288,000 steps to move the table around.  The Uno is fast, but it still takes time to generate that many pulses, and the stepper needs a finite pulse width.  With no microstepping, you have 18,000 steps, which still provides plenty of resolution, but the table will position much more quickly.


----------



## revwarguy

There is a new version available from the DM magazine website, version 2.3.  One reader reported that his fixture had a ratio of 4.5:1.  Oops.  I simplistically assumed that all gear ratios had a denominator of 1.  In the new version you can declare at compile time the denominator of ratios as well as the numerators, so he could enter 9:2 to match his machine.  Also, he was from Sweden, and wasn't friendly with Fahrenheit, so I added the compile time ability to display Celsius in the temp mode as well.


----------

