# The X axis.



## deeferdog (Apr 26, 2021)

In 2014 I purchased a Sieg milling machine, the SX2. It didn't take long to get tired of winding the X axis crank back and forth, motorising this was the first modification I did on the machine. I wasn't very cashed up at the time (I never am) so I utilized the motor from an old electric screwdriver and managed to cobble something together that worked OK for most of the time. The power in these little motors is quite astonishing and coupled with the planetary gear set it had little trouble in driving the table in either direction against a cutting load. Three problems with the system were; a) The motor would run on a bit after power was removed and this impinged on repeatability. I fixed this by connecting a relay across the motor terminals that shorted them out when the motor was powered off. The back EMF in the motor would bring about an instant stop. b) The motor speed is controlled by varying the applied voltage and the torque falls away dramatically at low speed, nothing I could do about that except to constantly adjust the speed. c) The setup needs some sort of clutch to disengage the motor from the X lead screw to allow the hand crank to be operated. Not that big a problem, I used a primitive form of dog clutch and this worked fine.
After two years I sold the little mill and invested in an Optimum BF20LV, similar to the Grizzly G0704. The X axis motor was simply transferred and has been working tirelessly ever since, however after making a motorised rotary table using a stepper motor I began to get the idea that  this type of motor might be ideal to use the drive table. That's what this blog is all about, using a stepper on a manual mill. More to come, a couple of pics of the gallant little screwdriver motor, I will be quite sad to see it go.
Cheers, Peter.


----------



## ShopShoe (Apr 27, 2021)

I've been considering using a stepper myself on my manual mill, rather than making something with a cordless drill/screwdriver motor or a wiper motor, so I will certainly be watching to see what you end up with.

--ShopShoe


----------



## deeferdog (Apr 27, 2021)

I decided to give fitting a stepper motor to the X axis of my mill, actually two of them but more on that later. There are a few reasons that make a stepper attractive for this task, they have good torque at low speed, they don't require a gearbox, are quiet compared to a planetary gear set thrashing around and are relatively cheap. Fitting them to the table is easy if no clutch or gearing is involved.
On the other hand, they have their downside, the biggest being speed control. A DC motor is very easy, vary the input voltage and the speed will vary accordingly. Steppers are different, the speed is determined by the frequency of pulses applied to the PUL terminals of the stepper motor driver. I do not pretend to be an expert on these things, most of what I know I have read up on at various web sites. I do have an electrical background and can generally follow explanations OK but I can get the wrong end of the stick as easily as anyone, so if there any glaring misconceptions, feel free to point them out.
Speed can be controlled quite easily through an Arduino or similar and I did look at that. It has its attractions, one being that position could also be programmed in, similar to a computer printer. Thus it would be possible to move the table to an exact position anywhere on the X axis through the use of a suitable controller. I gave this a lot of  thought and even tried a few things but there are some serious problems to overcome, all of them beyond me.
So, on to plan B. I decided to control the speed through the use of a frequency generator. These days they are very cheap, around $12AUD. The more common term for them is Pulse Width Modulators (PWM) and they can provide variable frequency pulses at the output terminals, the variation is achieved by either a knob or Mylar switch. The setting is displayed on a small screen. They also have a duty setting, if this is set at 50% then the output is a square wave which is just what the stepper driver likes.
So I brought a couple of these and started to play around with them. Speed control was great and the stepper behaved flawlessly but I could see a problem looming. What this was and how I worked around it......next post.  Cheers, Peter.


----------



## timo_gross (Apr 28, 2021)

A GRBL controller or the Stepper driving logic of a 3-d printer both could be used. That is basically already a first entry to CNC.
As a playing around starting point or for very basic application that might already do the trick to even use it as cnc control. Google for GRBL or "running Marlin on a mill" will show lots of examples.
I think Linux cnc is more complicated, but I found it much easier than most people think. With investments into more professional hardware Linux CNC can do a lot.


Greetings TImo


----------



## ignator (Apr 28, 2021)

I've looked into doing this as well. I could not find a stepper motor that had enough torque to drive the feed screw without a reduction gear box. 
I do think, a separate encoder is needed in the event of a lost step or two. I see the advantage of using the Arduino so electronic limit end stops can be produced. As well, a program to select the feed rate of the table, using some of the cutting tool parameters, like SFM for the material, spindle RPM, diameter, number of cutting teeth, and other things to control the tooth loading. 
And a simple disengage clutch. Lever operated would be preferred.
So I'm currently working on using a off the shelf power feed, with its universal motor, and modifying it to use DC PWM control method. I'm at the point of getting an encoder on the motor shaft to count pulses in either direction. And this causes other design issues, as the pulse rate may be too fast for the arduino to keep track of, so a separate counter circuit may be needed, and this forces an interface to the arduino. And it's summer with the minions of other projects, so back burner till winter on this.


----------



## timo_gross (Apr 29, 2021)

I think trying to incorporate an encoder into Arduino will run into difficulties. High risk to spend many hours to save some bucks and beeing disappointed at the end.  It will for sure require a high awareness what you are actually doing, programming at very low hardware level and still be limited to slowish encoder counts and speeds.
The standard GRBL does not have this features, marlin based printer hardware will not provide this. ( at least not yet ) 
There is a certain level were all this just starts costing money. Not totally out of reach, but not at the cost of "10 coffee to go". 
Cost is driven by:

documentation available ( I tend to spend more now, because I am fed up with saving 200 USD and then wasing 20h or 40h of my time extra often with an inferior result )
power ( 1A at 24V can be had for 2.3 USD a proper servo driver will cost 100 times that even from China )
accuracy,
reliability/safety ( dangerous products out there ).
quality, occasionally
You run into similar issues like electronic lead screws for a lathe. Once busy doing it and adding features, it becomes more and more expensive and complex. Finally ending up with a cnc machine.  
If you think Arduino, encoder and a little torque:
Get a decent closed loop stepper driver with matching motor as a set. There are mains voltage versions with integrated power supply, or 
drivers with DC input. You have to add the cost of a decent power supply to your equation in case it uses DC input.
Do not ceap out on power supply, good ones have a better power to smoke ratio.
Hook the arduino up to the logic inputs of the driver. If that does not work out or your needs outgrow the logic capability, the expensive part can be reused in the upgrade. 

As far as I recall the small milling machine has 60V and 6A steppers coupled with a rubber clutch. It is better than nothing, but far from perfect.
The stepper on the rotary axis runs at about 2-3A. The gear reduction is 1/7. I will not admit that it is a horrible design, because I would feel bad.


----------



## awake (Apr 29, 2021)

timo_gross said:


> I think trying to incorporate an encoder into Arduino will run into difficulties. High risk to spend many hours to save some bucks and beeing disappointed at the end.  It will for sure require a high awareness what you are actually doing, programming at very low hardware level and still be limited to slowish encoder counts and speeds.



<TLDR warning>

I agree that there are other microcontrollers that are better suited than the Arduino for handling high-speed encoders, but as someone who used to write embedded software for a living, I feel compelled to make a comment on the matter of "programming at very low hardware level." In general, if you are talking about capturing time-sensitive, high-frequency hardware signals, you can't and shouldn't avoid programming AND electronics at a low hardware level, even when using a much faster MCU. You will either need a dedicated quadrature-phase counting circuit (I have seen at least one MCU that had that function built in), or you will need to use interrupts, or both. You will definitely need to think about noise, possible ringing or bouncing of the signal, etc.; these may be addressed with hardware conditioning or software or both.

It may be that you can find or purchase a ready-made solution (hardware and/or software library) that has already done that low-level work for you ... but that does not eliminate the low-level programming; it simply puts it "under the hood." For someone doing their own CNC-type work, you may or may not be able to get away with not understanding what is going on "under the hood," but I would think at least some understanding would be helpful.

One of the problems of the "ease of use" of the Arduino is that people assume that everything can and should be done using higher-level code placed in the standard setup() and loop() structure of the Arduino IDE, or conversely that if the Arduino cannot handle something written that way, it means the Arduino is too slow and one must throw a faster MCU at the problem. As an example, I have seen various stepper motor libraries that depend on the standard "loop" function; frankly, I find these to be woefully inadequate, _and would find them just as woefully inadequate if implemented on a 1GHz Arm processor instead of the 16MHz Arduino_. Use of such an approach makes any processor not only seem much slower than it actually is, but also can lead to dropped signals and considerable inconsistencies in the timing of the signals.

By contrast, with appropriate use and setup of timers and interrupts, you can easily and reliably generate at least 30k steps per second on a plain old 16MHz Arduino, including the logic needed to handle acceleration and deceleration - as evidenced by the GRBL or the Marlin firmware. Sure, some of that firmware is written at a higher level, but the really time-sensitive parts are down in the low-level, bit-banging, hardware weeds - as they should be. Again, you may or may not need to understand what's going on under the hood ... but it probably woudn't hurt to have at least a general idea.

Let me stress that I am *not* arguing that an Arduino is the way to go for the topic under discussion. It is not as slow as people sometimes think it is, but it is not nearly as fast as many alternatives. For reliably handling a rotary encoder plus other logic, I personally would want something faster and/or with built-in quad-phase counting. Let's do the math: Since 30k seems to be the number widely used for the maximum steps per second that an Arduino can reliably generate, let's assume that a similar figure applies to the number of samples per second for reading a quadrature encoder. Let's say we are encoding the spindle on my Bridgeport at a 1:1 ratio. The maximum spindle rpm is 3600, which translates to 60 revolutions per second. If I use a typical 600-ppr encoder, that puts me at 36k pulses per second - a bit too much to handle based on the assumptions above. Maybe some clever coding could just handle it ... but I would advise against designing right at the edge of the MCU's capabilities, because that leaves no headroom for dealing with extra or unexpected events.

</TLDR warning>


----------



## mnay (Apr 29, 2021)

There are lots of ways to skin the cat.  I converted my bridgeport type mill to cnc and used timing belts to drive the screws.  I also made the brackets so the stepper motors could swing away allowing me to remove the belt and go back to manual mode in just a couple of minutes.
See this thread.  Mill 2 axis conversion | Home Model Engine Machinist


----------



## deeferdog (Apr 29, 2021)

Thanks for all the input, especially about the Arduino and other electronic control systems, I decided to stick solely with mechanical control for this as I understand levers, cams and such much better. Anyway, back to the speed control issue. Feeding the output of the PWM into the stepper driver gave excellent control over the motor speed but they vary their frequency quite slowly using the selector switch. This is OK when deciding an initial feed speed for the table but makes it difficult for a fast return feature. I think that the ability of the table to fast return is not only desirable but necessary.
After a bit of fiddling around with a few options I decided to bring a second PWM into the system, this one set to a much higher frequency output than the variable feed PWM. The trial setup with an old stepper, breadboards, switches, a pushbutton switch and two PWM's worked very well. The variable PWM was set to around 120Hz and the return PWM to 500Hz. When powered up the stepper would crank away at low RPM simulating the table traversing to the right. Reversing motor rotation was simply a matter of throwing the switch, then I would press the pushbutton switch to bring about a rapid return of the table, the PB switch would do this by breaking contact with the variable PWM and making contact with the rapid PWM. The advantage of this method is that the initial feed setting is not touched, letting the PB switch relax reverts the stepper back to the initial feed speed, this should lead to more consistent machining finishes and I need all the help I can get.
Based on this success I ordered two stepper motors and drivers from eBay, 1 Axis Stepper CNC Kit 3Nm Nema 23 Stepper Motor 4.2A & Stepper Driver DM556Y  | eBay. These are  3Nm Nema 23 Stepper Motor 4.2A & Stepper Driver DM556Y. Deciding if they provided enough torque for the task was a bit of a "seat of the pants" calculation but that's probably one of the few advantages of getting old, bluffing your way through. I needed two steppers because I have two mills to modify and I'm confident that this is going to work, let's hope I don't come a gutzer.
Next post, I'll start the fitting of the motors and making the control box. The circuitry needs a bit of refinement and I have decided on adding another feature that's going to take heap of brain cells to nut out, more on that next time. Thanks for reading, Cheers, Peter.


----------



## timo_gross (Apr 30, 2021)

awake said:


> <TLDR warning>
> ....
> </TLDR warning>



Hello Andy,

a little OFF Topic yet again.... <TL warning> from me too.

I googled the warning after reading.  still some useful information.
What I basically extracted from your post is, I was right about my feeling concerning the Arduino plus Encoder. DO NOT TRY, unless you like the challenge!
Todays available technology in the reach of a home gamer, is far to advanced to dive into every rabbit hole.
Sometimes I want to "keep the hood" closed as much as possible. Sometimes I want to scratch open the surface to have a look at the rabit holes first floor.
GRBL and Marlin can do an excelent job in my opinion to achieve already quite something for a very low budget. ( without gaining expertise in automation )
Encoders!? The two mentioned systems do not have up their sleeves (yet maybe they never will ). 

So what I wanted to say.
If you need a professional solution
a) "open the hood" and pay with many many hours of your time, and maybe even a lot of money to make a cheap system. 
b) Or buy something that does the job and pay with money.
It all depends were the focus is. "time equals money".
"You get what you pay for" I see too many people not factoring in their time, frustration and effort into the "pay" part of that expression.

I had the impression the original poster is after some simple power feed for a budget. To make swarf. Not trying to compete agains Fanuc and their Chinese competition. 

Cheers Timo


----------



## timo_gross (Apr 30, 2021)

Hello,

I feel we got side tracked a bit.
I think your solution with PWMs gets a bit complicated.
My proposal, guessing what you want and hopefully useful.

Get cheap GRBL shield
get an Arduino UNO or alike clone.
Hook Arduino up to PC upload program to Arduino.
Install Grbl Controller from Internet
Just ignore all extra buttons.
Connect the motor driver that you already ordered from Ebay to the GRBL shield.
Try if motor speed and torque are good enough for what you want
If that was a miss, you will have spent few hours to figure it out plus approx. 10 USD for hardware, that is still useable for another toy.
You will be able to drive your axis back and forth with the buttons on the computer keyboard, easy. Some people hook up a wireless number pad for jogging. 
This is different from your 1st proposal only in the way that all the software and speed control is already prepared by others and you can just use it more or less out of the box. To make things even easier for step 1-3 you can even find preinstalled single boards.

Greetings Timo


----------



## Leonardo (Apr 30, 2021)

Hey *Andy*, I do not know why but your post remembered me that old joke...
"There are 10 types of people in this world, those who understand binary and those who don't!"


----------



## Leonardo (Apr 30, 2021)

*Peter*,
You can use that PWM appliance to control your old screwdriver mod. You can set a frequency and then varying the duty cycle you can control the motor's speed with little power lost at low speeds.

Also I would like to comment that you do not need an Arduino or any other micro-controller to send pulses to the stepper motor driver in your application. A simple square wave oscillator make with a 555 IC will do the trick. Furthermore, with a 556 (double 555) you can have a double oscillator to set the two speeds that you need. You will have just two potentiometers to control the speeds quickly.
There are thousands of examples in the web and also you can find some tiny cheap commercial boards, just look for "555 pulse generator".

Regards, Leonardo


----------



## deeferdog (Apr 30, 2021)

I'm taking note of the feedback but I won't comment individually, I'll just say thank you for the interest shown and press on with the project. The mounting of the stepper to the table was very simple as the design of the motor makes this easy. I decided not to use a flexible coupling as I did on the rotary table because I just cannot see that are necessary. I only used one because it seemed that most other people did and I thought that it was required with steppers. The thing cost $40AUD and I'm not one to fling money to the wind.
I made the coupling from steel with enough length so that both the table and stepper shafts were fully incorporated into it. This, plus the snug fit, ensured good alignment and then I tightened the mounting bolts. The first thing to check was how the manual operation of the table would be affected and I'm happy to report that there was almost no difference between the motor being connected  or not. A slight opposition was all that was felt. Wonderful, no belts, clutches or gears, just a straight connection.
The next horror thought was about the EMF that would be generated in the motor fields as the rotor was being rotated, would this spike the connected electronics? Well, all I could was hope that it wouldn't.
A quick jury rig of the wiring proved that the solid couplings worked just fine and the speed control of the motor was buttery smooth. I wasn't able to do much in the way of a load test other than push opposite against the table when it was traversing, it didn't even slow down. All the dip switches were set for minimum current and the draw was around 0.5 amp. The power supply was a 48VDC Meanwell. I'll do full testing and a video when I get the circuit finished and the control boxes built.
I had put a great deal of thought into the actual layout of the control box and it's associated parts. I ratted through all my bits and pieces boxes and came up with various switches and relays to use. Some of them were not quite ideal but I went ahead and used them anyhow and this will explain the sometimes odd configuration. Sorry about that.
 The final piece of this puzzle is the limit switches. The old system had two micro switches attached the front on the machine and the table slid past them. I f I wanted to use these to set traverse limits I mounted actuators to the table at the appropriate position, these would trip the switch and the motor would stop. I wanted a similar setup on this but it needed to be more sophisticated. What I wanted was for the table travel to a position that I set and then stop, I called this HOME. When ready, I would press a button and the table would move in the opposite direction until it reached a position I called REVERSE whereupon it would reverse its direction until it once again hit the HOME position and stop. The cycle would be repeated when I again pressed the button.
I managed to get it all together eventually, remember this is all done mechanically and this does lead to a very simple design to operate. Using electronics does not always produce this result. I suppose that might put the cat amongst the pigeons.
More later, Cheers, Peter.


----------



## timo_gross (May 1, 2021)

Leaving out the coupling puts you at (limited)  risk to damage something, shaft end or bearing, so what? You can just  and repair it, when and if it ever happens. ( there are more scary things out there  )


----------



## BaronJ (May 1, 2021)

Hi Guys,

When I made my mill table traverse, I used a car window wiper motor and a tumbler reverse !  It gives me variable speed, by varying the voltage and forwards/stop/reverse functions.  I tend to run it at about six or seven volts using a couple of amps.  I can get fast traverse by cranking the voltage up to 30.






Mounted on the left side of the table, the wiper motor has two speeds plus what ever voltage you feed it with.


----------



## awake (May 1, 2021)

Leonardo said:


> *Peter*,
> You can use that PWM appliance to control your old screwdriver mod. You can set a frequency and then varying the duty cycle you can control the motor's speed with little power lost at low speeds.
> 
> Also I would like to comment that you do not need an Arduino or any other micro-controller to send pulses to the stepper motor driver in your application. A simple square wave oscillator make with a 555 IC will do the trick. Furthermore, with a 556 (double 555) you can have a double oscillator to set the two speeds that you need. You will have just two potentiometers to control the speeds quickly.
> ...



I had the same thought - just a simple oscillator with the rate controlled by a potentiometer - and you don't even need two oscillators if the one has enough range; just a push button switch to override the potentiometer setting.


----------



## weir-smith (May 2, 2021)

awake said:


> I had the same thought - just a simple oscillator with the rate controlled by a potentiometer - and you don't even need two oscillators if the one has enough range; just a push button switch to override the potentiometer setting.


----------



## weir-smith (May 2, 2021)

Peter

I have been down this path many times in that I have converted a lathe and a couple of mill plus CNC routers.
Depending on what your end game is will determine the path you take. For example, if you just need power feed on either the X or Y travel the solution is quite easy depending on what you have to hand. Further, do you need just variable speed or do you need to set a particular distance of travel. Alternativly, is this the first step to modifying your mill to CNC?  In this case, you are looking at a stepper motor with some form of pulse generator eg cheap and easy.
One of the problems with stepper motors is their low torque at higher speeds. By using a 48 volt switch mode power supply can help eg a cheap and easy solution.

I have always used some form of reduction gear box usually made from gears that I have, to keep it robust. I have also used both direct drive, or used toothed timing belts. A lot depends on the machine and available clearences. The last one I made from the gear box from a disability scooter motor drive which came my way. It made a very smooth running arrangement and could also be disengaged which was a bonus. If you have a hunt around there are quite a few around.

If your decision is to go down the path of using a stepper, there are now two types of stepper controllers eg one with feed back and the more common without feedback. Both are easy to use. The controllers with feedback simply compare the input with the feedback and if there is any slippage, it will correct it. If you are going down the path of converting at some time to CNC then it is a good option.

To simply have variable speed travel, they are not worth the additional cost. For basic speed control, you just need a suitable sized stepper motor, a stepper motor driver, power supply and pulse generator. I use a cheap unit off eBay for less than $10 AU and I am happy to send you the details plus wiring diagram. The board provides variable speed, forward and reverse, and if you want, you can fit switches to select the speed range. Speed range is normally selected using plug in links.

So in summary, it's all been done before and all you need to do is ask.

Bruce Weir-Smith
Western Australia.


----------



## deeferdog (May 2, 2021)

To continue with this project. If you care to look at the limit switch's on my machine, the pic is in the previous post, there is one really dreadful design fault. If the operator, (me) forgets that the stops have been set and cranks the table handle past this point, the stop smashes the limit switch. It's obvious how I know this. I decided to replace the limits, this time mounting them sideways so the stops slide over the top. The next thing was to change the stops. I used some donut magnets and put them on a mandrel turned to slip into the slot on the table. These are very quick to place in position and adjust precisely and adhere strongly to the metal. If they are left in place and the table moved past the stop point they simply slide along without damaging the limits.
The construction of the control boxes came next and because there are two machines I wanted to make everything interchangeable. I used plugs for all the electrical connections. I call them microphone plugs because you see them a lot on audio equipment. They are quite reasonable in price. The enclosures are just plastic jiffy boxes, mainly available at electronic parts retailers. I generally like to stick a fan in the box if I can to help with the cooling, these are two dollar computer fans rated at 12 VDC but they run quite well on 5 volts. 
The 48VDC input was broken down to 5VDC using a DC to DC converter, this voltage was used for the fan and the stepper driver. The only relays in my junk box were 12VDC so that is why the Limit Control Box is fed that voltage and there are two switches to change from TABLE to LIMIT in the System Control Box rather than one because I didn't have a triple pole switch.
I realize that there are many ways to do what I'm attempting and I appreciate the offers of help and advice, however this is the way I did it and anyone is free to copy and modify to suit their own particular needs. 
Well, at the end of the day, did it work? Emphatically yes. The stepper is very quiet and the table glides effortlessly. It generates enormous low speed torque and does not slow down as cutting loads are imposed on it. The fast return performs well. When the table is used in the manual mode, cranking is easy and if any internal EMF's are generated in the stepper they do not appear to be impacting the electronics. The installation looks neat and tidy, there are no belts gears or levers. Nothing gets hot, max current draw is around 1 amp and the dips are set to minimum.
The electrical circuit may not be the most elegant and I'm certain it could be improved but it took me quite a bit of time to work it out and I'm pleased with it.
Here are a few general pics of the project. In the next post I will upload a video. If anyone has any questions I will try my best to answer them. Cheers, Peter.


----------



## ignator (May 2, 2021)

I really like your limit switch design. I have this problem with my Align power feed, I don't damage anything, but it rolls the microswitch box over when I manually crank. I understand you keeping this simple. I'm surprised that you don't feel cogging of the stepper motor when manually cranking this, so this is a good thing. I'm guessing your stepper amplifier has some protection diodes to protect the output transistors. I'll have to keep that in mind and check that with my future install.


----------



## animal12 (May 3, 2021)

nice job . I'm wondering which pins you hooked the frequency generator to ?


----------



## BaronJ (May 3, 2021)

Hi Guys,

The complexity of using a stepper motor to drive the table was one of the reasons that I went for the DC wiper motor and a variable voltage power supply.  The bonus of using a tumbler is that you get a neutral position that completely disconnects the drive.

I actually made two of these with wiper motors from two different cars. One drives from the left and the other from the right.  The first one of them placed the motor above the end of the mill table, which is why I got a second wiper motor and built a second one.


----------



## deeferdog (May 3, 2021)

Thanks for the interest shown in this post. Here are the three circuit drawings. There really only needs to be one combined drawing but I have broken them up in three because that's how I built this project, a Control box, a Stepper control box and a Limit control box., the last only being used when it is required to set the table stops. The circuit could certainly be refined but as I am not into production with these, as long as it works then I'm happy.
I have included a drawing of a latching relay circuit for those that may not be familiar with them.
 The following notes will help understand the Limit Control box:
i) Relay 1 will latch when HOME limit switch makes.
ii) Relay 2 will de energise when PUSH is pressed. This will cause the stepper to rotate CCW and unmake the HOME limit.
iii) When REVERSE limit switch unmakes, Relay 1 will unlatch. This will energise the stepper to rotate CW until HOME limit makes, causing Relay 1 to latch. The stepper will stop and the green LED READY will illuminate. The circuit will now wait until the operator presses PUSH, whereupon the cycle will repeat.
I will try and upload the video by tomorrow.
Cheers, Peter


----------



## deeferdog (May 4, 2021)

Here is a video link showing some clips I stuck together of a gear being cut on my mill with the stepper motor as the X axis power drive.  Thanks for watching. Cheers, Peter.


----------

