Auto-Oiler replacement for Myford and other drip oilers.



Having owned my ML7 lathe for some 30+ years I learned to live with the vagaries of the spindle drip lubrication system. However, fitting an inverter and 3ph motor and running it at higher speeds set me wondering if such hit and miss lubrication was adequate.

After much pondering I came up with the idea of using a peristaltic pump driven by a stepper motor turning X number of steps to deliver a metered quantity of oil to each bearing, the stepper timing being controlled by an Arduino. After several prototypes and may hours of testing, it worked to a degree but I wasn’t happy with the repeatability nor my ability to write code for the Arduino.

At this point I turned to a very good and long suffering friend who, to say the least, is a bit of a whiz when it comes to programming. Mark had previously helped me sort out problems I was having with my electronic lead screw by writing software that counted encoder pulses and highlighted when the system was picking up spurious signals … a fantastic bit of work without which I’d have never got the system working accurately.

Now with some brains on the project things could progress to add more features and allowing a change to DC motors (although we have retained the code for stepper motors if people wish to use them). This is a relatively cheap, fully automated, oiling system which I believe solves most of the problems people experience with mechanical oilers.

The system is basically as follows … An Arduino controls two motors which drive two separate peristaltic pumps. The pumps draw from a small oil tank and pump oil to two sight glasses mounted on each spindle bearing. A thin pipe at the top of the sight glass drips oil into the bearing and triggers a photo interrupter (PI) sensor to confirm that the bearing has been oiled. The system will give an alert if no drip has occurred.

Above are all the components which comprise the system. It should be possible to build this for less than the cost of new manual oilers.

The system can work in three modes …

1) Oiling frequency irrespective of the lathe running. Whenever the Arduino is powered up a drips occur at a preset time interval until power is switched off. This is default mode and relies on the operator remembering to switch it on and off.

2) Oiling based on the lathe running. A signal to the Arduino whenever the lathe starts and stops initiates drips at a preset time interval. This set up will require the lathe to have both an isolator switch and a start/stop switch. Turning on the isolator also powers the Arduino which does an initial drip prior to the lathe running. It then operates at a preset time frequency based on whenever the lathe is running.

3) Oiling frequency based on lathe rpm. An isolator and a start/stop switch are required for this mode which again allows for oiling prior to the lathe being started. A tachometer or encoder is required or a PI sensor similar to the drip sensor can be used. With this mode drips are delivered based on a preset number of spindle revolutions so the faster the spindle is turning the more frequent the drip. This is the system I’ve built.

The system has an alert function which triggers if a drip is not detected after a preset number of seconds or revs.

Number of drips per cycle can be preset.

If required the Arduino sketches can control up to 6 motors.

Below are photos and brief explanations of the system I built. I employed the use of a 3D printer, but it would be quite possible to build a system using alternative components such as hobby electronic boxes and to fabricate the pump to motor adapter.

A full down load of Arduino sketches, software to write sketches, an in depth wiki explaining the Arduino library, electrical schematics, .stl files for 3D printing and a BOM can be made from on Marks GitHub at …

All the code on GitHub is freely available without restrictions on use.


A bill of materials with prices current at the time of writing is available here …

This lists all the major components required for the project. Parts could most likely be found cheaper with a little hunting around. I’ve assumed that as typical hobby engineers prospective builders will have a the usual bits of scrap, fixings and hoarded items available to complete most mechanical parts.

Sight glasses …

These are a relatively easy turning exercise I made mine from aluminium and 15mm OD acrylic tube although later experiments showed that 20mm acrylic (same size as the oil tank) tube could be used with the benefit of the PI sensor having more adjustment. The thread used between the Acrylic tube and aluminium housings was 15 x 0.75mm. A slot is milled in the acrylic to accept the PI sensor such that it’s a nice tight fit and held snugly.

A small bore tube which produces the drips is super glued into the top of the sight glass and if long enough can be used to strengthen the hose tail by running its full length. The one critical dimension is between the end of the drip tube and the top of the PI sensor which should be no less than 3.5 - 4mm. This allows a drip to leave the dip tube completely before triggering the PI sensor.

Acrylic tube of the appropriate dimensions is readily available on eBay as is the drip tube which was obtained by buying a couple of dropper bottles which come with a selection of interchangeable nozzles.

I used the 1.25mm OD nozzle which, as best as I can measure, has an ID of 1mm. Stripping the plastic off the tube in preference to cutting the tube should give sufficient length to reinforce the hose tail. A bonus of buying the tubes this way is that you get a couple of handy dropper bottles for cutting fluid or other duties.

The thread at the bottom obviously needs to suit the bearing you’re fitting it to which in the case of the Myford is 1/8 BSP. A Lock nut will be required to fix it in position with the PI sensor located to the rear of the lathe.

PI sensors and cable
s …

I used USB cables as these have the correct number of cores, are cheap and are readily available as are the sockets into which they plug. The PI sensors are ref number H92B4 also readily available on eBay. To pre-empt questions... yes they seem to work just fine doused in oil.

Wires were soldered to the PI sensor and it was then potted with hot melt glue using a simple mould machined out of a suitable plastic. Be careful not to use too much glue when potting as it’s possible to fill the sensor completely and obscure the LED and photo transistor. If you buy fabric braided cable, putting a drop of superglue on the braid before cutting keeps everything neat and tidy until you pot it.

Motor and pump housing …

The peristaltic pumps available on eBay or Ali express are supplied with a direct drive motor which is way too fast for this duty. I replaced the motors with 12vDC geared motors type S30K and incorporated an adapter into the housing design to couple the two together. Alternatively stepper motors type 28BYJ-48 can be used along with the driver board type ULN2003.

As can be seen from the photos I 3D printed my housing but if you don’t have access to a 3D printer an adaptor between the pumps and motors could be made using the plastic flange supplied with the pump and a machined block of plastic or aluminium and mounted in a proprietary project box.

A drive adapter needs to be made to connect the motors to the pumps.

Thin end directly drives the pump rollers and the slot engages with the motor shaft. In testing I noticed a slight erratic rotation which, although it worked just fine, I believe is due to this coupling. It’s effectively half an Oldham coupling, so as an improvement I’d suggest a full Oldham coupling could be made. Ref …

The pump housing contains a small, cut down bread board and a couple of USB sockets. The bread board is used as a means of connecting a multi-way cable from the Arduino, the motors and the USB cables from the PI sensors along with associated resistors all as shown on the electrical schematic.

Oil tank …

The oil tank in my design is made from 20mm acrylic tube glued to a printed manifold and the assembly glued on to the motor housing. Making it separate to the housing made for easier printing.

Brass hose tails were turned with an M5 thread, heated up and screw into M5 modelled threads in the manifold. If you get the temperature right and don’t mess them around whilst cooling, this fixing method forms an exceptionally strong and oil tight joint.

A press fit lid was printed to cover the top of the tank.

I had considered other ways of making an oil tank. Top of the list was a Tic Tac sweets container which is transparent and has a ready made cap. It seemed a little large so I made my own, but the idea may be of use to those without a 3D printer.

Arduino and screw shield …

An Arduino Uno is used to control the system. A screw terminal shield is well worth the investment as it allows mounting of various components and makes for easy connecting to the Arduino. The two green LEDs indicate a pump motor is running and the red LED is the alert indication.

I 3D printed a simple bracket to mount the Arduino in an existing electrical cabinet which allows the USB socket to be accessed through a cut-out in the enclosure, this would be an easy fabrication for those without a printer.

Electronics …

Not my area of excellence, so if anybody spots any errors please flag them up!

An electrical schematic for the DC motor version can be down loaded from here …

and the stepper motor version from here …

The drawings show specific pins being used but any digital pin can be used for any duty provided it’s correctly detailed in the Arduino sketch.

Where you mount the various components will depend on your build, but follow the schematic and everything should work!

Pulsed signal for spindle revs …

This is only required if using “work done” mode. On my system I used a spare phase from a spindle driven encoder fitted for my electronic lead screw. However for completeness and to assist others who may be interested in implementing the “work done” mode I made a quick lash-up of an encoder using the same PI sensor as used to monitor the oil drips and tested it with Marks Oilerlib sketch to in excess of 1200 rpm. The total cost is probably no less than a couple of quid depending on materials to hand.

My version really was a lash-up using a hose clip, a bit of bent aluminium clamped to the collar on the left of the spindle ‘V’ pulleys and I used the mould I made for potting the PI sensors and a G clamp on the front edge of the head stock casting.

A far more elegant solution could be fabricated with a custom made clamp round the spindle. The sensor would be better located behind the spindle where there is more space and bracketed off the casting which supports the counter shaft, down here...

Arduino sketches and software …

As with electronics, this is not my area of excellence. All the sketches and software for this system were written by Mark without whose expertise this project would not have been possible.

I’ll assume for the sake of brevity that people wanting to build this project have a basic knowledge of things Arduino and concentrate more on Marks clever bit of software which complies the sketch for you.

If you haven’t already, download and install the Arduino IDE from …

Download and install Marks software and sketches from …

(Note release down load will include electrical schematics,.stl files for 3D printing and a BOM) and install OilerLib-1.5.7 in your Arduino folder and be sure to put a copy in you library folder too.

You can build your Arduino oiling sketch using the examples included in the OilerLib release and the extensive GitHub Wiki but an easier method for those not used to programming is to use the included OilerBuilder MS Windows application. This application allows the user to enter the pin numbers and parameters of the system they want to build, and it then auto generates an Arduino sketch.

The OilerBuilder application will be found in the OilerLib- 1.5.7 down load in examples\OilerBuilder folder.

For demonstration I’ll show OilerBuilder populated for the system I built, a two DC motor system controlled by lathe rpm, but mention alternative variations as I run through. The example uses the pin numbers shown on the electrical schematics.

Open the OilerBuilder application and you'll most likely get a warning because it’s by an ‘unknown publisher’. Ignore this and after a splash screen you’ll arrive at this page …

Motor 1 tab

This first page defaults to a DC motor but at the top is an option to set up a 4 pin stepper motor if preferred.

Inputs Pin#’ is the pin to which you’ve connected the output from the PI sensor pertaining to motor 1.

Inputs PinMode’ selects INPUT or INPUT_PULLUP. The electrical schematic shows a pull down resistor so INPUT is appropriate, but if you are using an alternative circuit internal pull up resistors can be set here if required.

Inputs # Drips’ to stop motor is pretty self explanatory, it’s the number of oil drips required from this motor each time it oils.

Inputs Debounce time (ms)’ This setting determines the minimum number of milliseconds required between valid signals from the Photo Interrupter. By setting a minimum value, it prevents duplicate or spurious signals implying a drip has occurred when it hasn’t. If for any reason you find that one drip is being recorded as multiple drips this value can be increased.

Outputs Pin 1#’ is the out put pin which drives the relay to operate motor 1

Motor 2 tab

This is a repeat of motor 1, but obviously with the pin numbers to suit motor 2.

Alert tab

Alert pin#’ sets which pin gives the alert signal.

Level held at during alert’ dictates how the pin behaves. High means it out puts 5v in alert condition and low means it sits at 5v all the time there is no alert, dropping to 0v in alert condition.

Alert threshold’ sets the number of seconds or revs (dependant on later configuration) should pass between the start of an oiling operation and the alert being triggered. Be aware that the pumps will take time to produce a drip so don’t set this number too low or the system will trigger the alert before the drip has occurred.

Oiled Machine tab

Here you can set the mode of operation, either ‘Power on’ or ‘Work done’ mode. You can enter details for both modes, but in the final tab you specify which mode you wish to use. If neither is selected i.e. both input pins are set to -1 the system will run in default mode where the system oils every X number of seconds all the time the system has power irrespective of what the lathe is doing.

Power on’ mode uses a signal to say the lathe is running, typically an output from a relay operated by the lathe start/stop switch. The pin to which this out put is connected is entered into the ‘Input pin # box’.

Inputs PinMode’ selects INPUT or INPUT_PULLUP. The electrical schematic shows a pull down resistor so INPUT is appropriate, but if you are using an alternative circuit internal pull up resistors can be set here if required.

Sig level’ dictates how the pin should recognise the input signal. High means that 5v will indicate the lathe is running and 0v indicates the lathe is stopped.

Low means the pin operates in the opposite fashion to above i.e. 0v means the lathe is running and 5v means the lathe is stopped.

Work done’ mode uses a pulsed signal for spindle speed.

The pin to which this pulsed signal is connected is entered into the ‘Input pin # box’.

Inputs PinMode’ selects INPUT or INPUT_PULLUP. The electrical schematic shows a pull down resistor so INPUT is appropriate, but if you are using an alternative circuit internal pull up resistors can be set here if required.

Final tab

Set Motor Restart Mode’. Here you set the event that triggers motors to (re)start oiling. Not all options will be visible depending on previous settings, but the three options are:

On elapsed time (secs)’. Default mode, where the system restarts the motors after a configured number of seconds. Irrespective of what the lathe is doing.

On powered time (secs)’. System counts seconds that the lathe has been running and when this hits the configured limit it restarts the motors

On machine work (units)’. System restarts the motors after a configured number of revolutions of the lathe spindle.

Select whichever mode you are using then, in the ‘Threshold’ box, enter the number of seconds or revs. between oiling operations.

And finally ‘Sketch pathname’. If you have the Arduino IDE installed, then it will attempt to create the sketch in a folder called OilerBuilder in the standard Arduino sketch directory (i.e. in the same place the Arduino IDE normally stores sketches).

If this cannot be found it will create the OilerBuilder sketch in the temp directory.

You can change the path to another destination if you wish.

That should be it, click ‘Create Sketch’ and open the file. You should have a sketch similar to this …

Upload it to your Arduino and things should spring into life.

You can change any of the #define parameters in the sketch. Each has a description of its purpose. Alternatively you can make changes in OilerBuilder application and create another sketch which will overwrite the first.

In the time I’ve been running the completed version of this system it’s worked well. I’d welcome any suggestions, improvements and corrections.

Join to automatically receive all group messages.