Flowcode programmed Rotary Axis

One of the most common challenges / complaints I hear about with small companies using manual rotary tables when milling is the pain of manually turning the hand wheel five turns for just one revolution. It seems fairly inconsequential in hindsight but I thought it would be worth investigating whether there was a project I could get my hands into easily to make the job easier.


If you have ever tried to cross drill a tube with equally spaced holes around the circumference, or machined a hexagonal head like a bolt you will find life difficult without a rotary table alongside your milling machine.

The challenge when doing such jobs, is keeping count of the number of hand wheel turns required to get the job done accurately and efficiently. On more than couple of occasions, I have made errors and had to start the job over again because of my own inaccuracies.

This is not a fault of the rotary table itself, they are brilliant and extremely accurate. This got me thinking – perhaps the introduction of a stepper motor driven rotary axis (using the motor below) would solve the ongoing issues for me…


The particular motor I chose is geared 6:1, i.e. the stepper motor turns six revolutions for one revolution of the chuck via timing pulleys and toothed belt. My choice was also determined by the fact I was opting for a hybrid stepper motor which has 200 steps per revolution.

Another of my key decisions when deciding on the right motor was that I required a one-degree resolution. This called for a digital stepper motor drive that can be customised into micro stepping. I would need to convert it for a 6:1 ratio so I could get one-degree increments, as 1200 steps cannot be divided by 360 to get full steps for my desired system.

So, I set micro stepping to ‘3’ and the coil current to 2.5 amps.

(Micro step 3 x 200 = 600 steps x 6:1 ratio makes it 3600 step pulses per 360 Degrees, giving me 10 steps per degree)


The system used a 24v direct current to drive the motor coils and logic signals for “Step and Direction” from a PIC based 16F88 microntroller (pictured above).

The way I wanted to control the “step and direction” was from an MPG hand wheel of a C.N.C machine.


Here is some of the feedback experienced from the system:

Encoder Inputs to the PIC16F88 from MPG viewed on an oscilloscope.


Above: Clockwise Rotation                 

CH1 = A     B.6   Pin 12

CH2 = B     B.7   Pin13


Above: Anti-clockwise Rotation

CH1 = A    B.6    Pin12

CH2 = B    B.7     Pin13

Working with a colleague, I sketched the basic connections for a pin out for the PIC microcontroller I had chosen alongside an LCD that would work with a hand wheel encoder.

I used “Livewire” to draw the schematic (see below).


Next up was to develop the PCB. I used a simple package; “PCB Wizard” for the artwork then printed this on to acetate. Next, I used a light box to develop the image on to the PCB and ferric chloride to etch the board correctly.


The correct programming of the microcontroller was the next big challenge I faced. I have used Flowcode before and with some help through the Matrix forums from the Flowcode development team, I was able to do the necessary work.

Below, you can see the ‘TimerTick’ flow chart produced in Flowcode.


Using the controller:

  • On power up, you will hear the stepper motor lock up.
  • The display shows “SPEED” (set to 25 by default) use the MPG to select 0 – 200. This sets the rotational speed
  • Turn the MPG clockwise to increase or Anti clockwise to decrease the value. The speed is derived from: 8000000/4/4/15/(256)
  • 0 = 130 Hz to 200 = 595Hz (Frequency of the Step pulses)

(The software also controls a ramp up, so there are no pulses dropped by the stepper driver)

Press the button to continue…

  • The display shows “ANGLE” which sets the number of degrees to move.
  • Turn the MPG clockwise for a positive value or anti-clockwise for a negative value.
  • One index mark equals One Degree on the MPG. This controls the chuck direction, controlled by the “Direction output to the Driver”

Press the Button to start the operation (it counts the degrees on the display)…

  • Once its finished it reverts back “SPEED 25”

The images below show the controller working.



In use it’s reasonable accurate. The chuck has a 30-micron radial run out. What must be remembered is that this is not for heavy duty milling, as it relies on the holding torque of the stepper motor whereas the manual rotary table has separate way of locking the chuck rigid.

Here is a short video of the machine in use following the development of the rotary axis and controller.

Flowcode example program for this can be downloaded here: flowcode-example-file

You can download Flowcode 7 for free today here. Or buy a professional or academic licence, add features of support for further microcontroller families here.

5,181 total views, 1 views today


Leave a Reply