# Electronic Dividing Head - 4th Axis



## cfellows (Apr 16, 2014)

This is kind of a general interest post.  I was real happy with my success in the shop today, venturing further into CNC, Mach3, and programming in G-Code, so I wanted to share it with anyone who might be interested.

 About a year ago, I built this electronic dividing head, using an Arduino micro controller and software I wrote to control it. 







 It was my first foray into stepper motors and the Arduino.  Some months ago I had bought a newer, more powerful stepper motor and yesterday I finally got around to upgrading the dividing head with the new stepper.  Here's some pictures with the new motor installed.











 The motor replacement was easy since both the old and new motor were NEMA 23.  However, the motor is double the torque of the old one.  I ran into problems almost immediately with the electronics.  The stepper controller I used originally couldn't handle the current of the new motor.  So, I was faced with replacing it.  Also, the 12v rechargeable battery I had been using was no longer holding a charge very long and, at any rate, a battery is not the ideal power source for a dividing head... running out of juice in the middle of a job would not be good.

 I had converted my mill/drill to CNC a few months ago and the stepper controller I used was a Gecko G540.  It has a 4th axis output and is powered by a nice 24v, 15 amp power supply, so I put a new connector on the stepper motor and hooked it up to the Gecko.  I powered it on and it worked fine.

 I'm still a rank amateur with CNC, Mach3 and G-Code.  However, I have written software most of my adult life so, after an afternoon of reading and a few hours of fooling around with code, I wrote the following G-Code for Mach3.  Text inside the parentheses are comments.  Commands for the 4th axis use the letter A and the number that follows it is the absolute position, in this case the number of turns, to rotate the work.  So, for example, A1 tells Mach3 to rotate the work to 1 full revolution from the home position.  A .3333 will rotate the work 1/3 of a turn from the home position.  Note that I'm using absolute positioning, not relative.  This means that each command tells Mach3 where you want the work to be positioned, not how far to move it.  

 %
O0001                  (MAIN PROGRAM)
#100 = 36            (#100 is a variable name and is set to the number of divisions I want)
#101 = 1              (#101 is the variable which starts at 1 and gets incremented for each division)
A0                        (This line commands Mach3 to move the 4th axis (A) to the 'Home' (0) position)
M98 P0002 L#100 (This command calls subprogram P0002.  It loops the number of times specified in variable #100)
M02                      (This command halts the program)
 O0002                        (Subprogram called by the M98 loop command in the main program)
M00                           (This command pauses the program which I manually machine a gear tooth.  Clicking 'Cycle Start' resumes the program)
#33 = [#101 / #100] (This calculation sets variable #33 to the position of the next tooth, which is tooth number divided by number of teeth)
A [#33]                      (This command tells Mach3 to rotate the 4th axis to the position in variable #33)
# 101 = [#101 + 1]    (Increment variable #101 to the next tooth number)
M99                           (Subroutine end, return to main program)
%

 Works like a charm.  And, I now feel like this new 4th Axis has a lot of possibilities.

 Chuck


----------



## RonGinger (Apr 16, 2014)

Very nice. I am sure you will find many projects to use this. 

I think it is more common to set the forth axis to units of degrees, not full rotations. In Mach Motor Tuning screen change the 'units per' field to units  per degree. 

If you are going to use the indexer more like a spindle on a lathe then the units per rev might be useful. Of course you can have it both ways in Mach, just define a new profile with one set of units, then choose at startup which way you want to run.


----------



## kvom (Apr 16, 2014)

I'm more familiar with degrees as unit of rotation as well.  The gcode for that setting is almost identical; just set #101 to 360 instead of 1.

If you use that 4th axis on a CNC mill then you can engrave on cylindrical stock.


----------



## cfellows (Apr 16, 2014)

RonGinger said:


> Very nice. I am sure you will find many projects to use this.
> 
> I think it is more common to set the forth axis to units of degrees, not full rotations. In Mach Motor Tuning screen change the 'units per' field to units per degree.
> 
> If you are going to use the indexer more like a spindle on a lathe then the units per rev might be useful. Of course you can have it both ways in Mach, just define a new profile with one set of units, then choose at startup which way you want to run.



 Thanks, Ron.  I initially set the motor up to in Mach3 defining the number of steps required for one full revolution.   That makes it pretty easy to do calculations for indexing operations.  I used absolute positioning so I wouldn't get cumulative errors due to rounding.

 Chuck


----------



## cfellows (Apr 16, 2014)

kvom said:


> I'm more familiar with degrees as unit of rotation as well. The gcode for that setting is almost identical; just set #101 to 360 instead of 1.
> 
> If you use that 4th axis on a CNC mill then you can engrave on cylindrical stock.



 Thanks.  I've been looking at videos of 4th axis operations.  As I get more familiar with it I will undoubted try using degrees.

 My next experiment will be to replace the pause command in the g-code with a couple of y-axis movement commands to cut gear teeth.  That should pretty well automate the process of cutting gear teeth.

 Chuck


----------



## cfellows (Apr 16, 2014)

Well that wasn't so bad!  Here's a video of my first CNC gear cutting adventure using the 4th Axis.  It's a 24 DP and has 25 teeth...

[ame="https://www.youtube.com/watch?v=PNdI9fvrpc4"]https://www.youtube.com/watch?v=PNdI9fvrpc4[/ame]

There's a few things I could change to make it a little bit more efficient.  I'm cutting half the tooth depth in one direction, then to the bottom on the return.  I've got the X-axis travel more than it needs to be and I don't need to return the Y-Axis to zero between cuts, I could just go out to the halfway point.

Here's some pictures of the process of making the gear blank for those who are interested.  The gear is made from 1.125" aluminum rod.


























Chuck


----------



## AussieJimG (Apr 17, 2014)

Another very interesting project. I have purchased an Arduino as a winter project and will be following this thread closely. Thanks again Chuck.

Jim


----------



## kvom (Apr 17, 2014)

To engrave on a cylinder, you would need to do two things.

1) Have the CAD or CAM program convert all arcs to short line segments, as G2 and G3 commands will not work with A axis.  Therefore, the CAM program needs to output G1s for each line segment.

2) Process the output g-code file through a program such as CNCWrapper http://www.cncwrapper.com/index.htm.  This will convert either the X or Y coords (depending on the orientation of the work) to A, and will also modify the feed rates to coordinate the axes.


----------



## RonGinger (Apr 17, 2014)

There is another way to engrave on a cylinder. Just drive the rotary axis with the Y axis drive. In Mach simply change the port and pin numbers. Then change the steps per unit for the Y axis to a value that works for the circumference of the cylinder that you want to engrave. 

This is a bit of a hack, but it works fine. I ran this as a demo at Cabin fever several years ago to engrave on the whistles our club made to give to the kids.


----------



## singtosawang (Apr 18, 2014)

Sent from my iPad using Model Engines


----------



## bb218 (Apr 18, 2014)

Chuck,
   You are having too much fun.  That looks like a really fun project.

Mike


----------



## Phnug (Apr 19, 2014)

Nice job Chuck and interesting discussion. That is a very useful piece of kit and looks fun to make. Thanks for showing it.

Ian


----------



## mc_n_g (Apr 20, 2014)

That is a nice job you did on that Chuck.
Arduinos are nice to program.  You might want to look at the Arduino Cookbook Edition 2 from O'Reilly Media publishing.  It has some great code examples you can use to interface with an incredible amount of electronic items.

I would cover the gear and belt at the end so you don't get a bunch of chips bound up in the timing belt.
I would not worry about the 'efficiency' of the code!  Are you making them for production where every second counts?  So you may run extra seconds cutting the part.  Unless you have to bang out 100's to tens of 1000's I would not worry about it.


----------



## wild350x (Apr 20, 2014)

Are you using a od specific involute cutter and single index cutting or flat side npa cutter and multistep profile milling? I'm guessing single indexing (multi pass to reach depth) with an involute cutter. If you need any advise on gear cutting let me know, I ran gear cutters and grinders for 15 yrs.


----------



## wild350x (Apr 20, 2014)

Also if you wanted to maximize cutter life between sharpenings or decided to make the of a tougher material you could rough them in with a ballnose endmill.


----------



## cfellows (Apr 21, 2014)

mc_n_g said:


> That is a nice job you did on that Chuck.
> Arduinos are nice to program. You might want to look at the Arduino Cookbook Edition 2 from O'Reilly Media publishing. It has some great code examples you can use to interface with an incredible amount of electronic items.
> 
> I would cover the gear and belt at the end so you don't get a bunch of chips bound up in the timing belt.
> I would not worry about the 'efficiency' of the code! Are you making them for production where every second counts? So you may run extra seconds cutting the part. Unless you have to bang out 100's to tens of 1000's I would not worry about it.


 
 Originally, I was powering this dividing head with an Arduino.  However, in this video, I'm driving it with Mach3 from my PC.  There's no Arduino involved.

 Chuck


----------



## cfellows (Apr 21, 2014)

wild350x said:


> Are you using a od specific involute cutter and single index cutting or flat side npa cutter and multistep profile milling? I'm guessing single indexing (multi pass to reach depth) with an involute cutter. If you need any advise on gear cutting let me know, I ran gear cutters and grinders for 15 yrs.



 I'm using a specific numbered involute cutter, although it would be easy enough to write the g-code for multi pass cutting using a flat side cutter.  I don't cut a lot of gears, but that might be useful for cutting gears that I don't have an involute cutter for.

 Chuck


----------



## LSEW (Apr 21, 2014)

Chuck, the application of your 4th axis for cutting gears looks really nice. Watching it, I was wondering, since you are pioneering things, have you considered cutting bevel and miter gears. Those are a lot harder to come bu, and would be a big value added for the hobby. 

In Machineries there is a write-up about making bevel & miter gears on a horizontal mill. The tooth shape is approximate, but would be good enough for hobby use in all but the most critical cases I believe. It involves using a cutter for, I believe the small end of the tooth, and making 3 passes with in your case a slight movement in the Z axis. 

Food for thought.

maury


----------



## RonGinger (Apr 21, 2014)

If you want to cut gears with a CNC machine you need gearotic.com This is a package written by Art Finerty after  he retired from writing Mach3. It is amazing software- it lets you design gear trains of great complexity, including spur, bevel spiral, cyclodial and about any thing else you can imagine. Of course it generates gcode to directly cut the gears. Not only to cut with standard gear cutters, but using normal square end mills. The tooth profile is formed by a motion of the gear rotating and the Y axis moving. If you have a small enough cutter, or large enough gear it will generate the code to do a 2d profile cut.

It is really amazing software and fun to play with even if you never cut a gear.


----------



## cfellows (Apr 22, 2014)

LSEW said:


> Chuck, the application of your 4th axis for cutting gears looks really nice. Watching it, I was wondering, since you are pioneering things, have you considered cutting bevel and miter gears. Those are a lot harder to come bu, and would be a big value added for the hobby.
> 
> In Machineries there is a write-up about making bevel & miter gears on a horizontal mill. The tooth shape is approximate, but would be good enough for hobby use in all but the most critical cases I believe. It involves using a cutter for, I believe the small end of the tooth, and making 3 passes with in your case a slight movement in the Z axis.
> 
> ...



For some reason I've just never had any interest in bevel gears, so I read up a little about them yesterday in my Colvin & Stanley Guide to Gear Cutting book. The biggest problem with bevel gears is that the inner diameter pitch is different than the outer diameter pitch. This makes using a single pitch involute cutter less than ideal. However, I think using a straight sided cutter with multiple passes per tooth would work... Might have to give it a try!

Chuck

Chuck


----------



## cfellows (Apr 22, 2014)

RonGinger said:


> If you want to cut gears with a CNC machine you need gearotic.com This is a package written by Art Finerty after he retired from writing Mach3. It is amazing software- it lets you design gear trains of great complexity, including spur, bevel spiral, cyclodial and about any thing else you can imagine. Of course it generates gcode to directly cut the gears. Not only to cut with standard gear cutters, but using normal square end mills. The tooth profile is formed by a motion of the gear rotating and the Y axis moving. If you have a small enough cutter, or large enough gear it will generate the code to do a 2d profile cut.
> 
> It is really amazing software and fun to play with even if you never cut a gear.


 
 I remember when Gearotic was first released and I was really excited about it.  I'd love to give it a try, but, at $120, it'll have to wait... there are other, more pressing priorities for my hobby budget.  

 Chuck


----------



## cfellows (Apr 29, 2014)

So, used my small 4th axis today to make a helical gear.  I wrote the G-Code myself and it was surprisingly simple.  Gotta say, I'm having way too much fun.

 [ame]https://www.youtube.com/watch?v=nXIe-yX0MB4[/ame]

 Here's a couple of pictures of finished gear.












 And here's the G-Code for Zee (and others) to admire...  

*%
O0001 (MAIN PROGRAM)
(Initialization)
  G01
  #100 = 6                  (Number of Divisions)
  #101 = 0                  (Initialize Tooth Number to 0)
(Main Program Loop)
  M98 P0002 L#100          (CALL O0002, Loop once for each gear tooth)
  M02                  (Program Finished)
(Sub Program)
O0002                   (SUB PROGRAM, Cuts Tooth, Increments Tooth Number)
  # 101 = [#101 + 1]   (Increment Tooth Counter by 1)
  #33 = [#101 / #100] (Calculate tooth rotational position)
  #34 = [#33 + .75]         (Calculate rotation movement to cut tooth)
  A [#33]                  (Rotate 4th Axis to next index position)
  X0.35 a[#34] F4         (Cut the tooth while rotating the 4th Axis)
  X0 a[#33] F8                 (Return X & 4th Axis to Home Position)
  M99                   (Exit the SUB PROGRAM)
%*

 Hmmmm, had those comments all lined up when I composed the message...  :thinking:

 Chuck


----------

