Tachometer for an Engineering Mill
October, 2008 | By: John
This design originally appeared in issues 115 and 116 of Model Engineers Workshop. Full text of article by Tony Jeffree is here
The first modification was the replacement of the aged 16F84 PIC with a more modern 16F628, cheaper and greater functionality. This reduces the component count, because it dispenses with the need for a timing crystal or resonator. I considered that the accuracy of the device was sufficient for the purpose, see the note on read averaging below. Below is a summary of the changes that I made. to the code and some notes:
- Read averaging
Rather than just count the pulses in a single period and calculate the spindle speed, I chose to average several readings. By using some simple maths I could then display the speed and append a zero to give the final speed, so the displayed value always ends in a zero. I arranged for the rotating head to have 12 segments, 6 balck and 6 white. The sensor will then read 6 white to black (or vice versa) transistions per revolution. By counting the pulses every 250mS and averaging the last 4 counts, I get the revolutions per minute divided by ten. [ If the spindle is rotating at say, 360rpm, the sensor will see 6 revolutions in 1 second. Each of these will generate 6 pulses for the sensor. Hence totalling the last 4 readings will be 36. Just append the zero for the final reading] The display is updated every 1/4 second.
- Speed variation detection
Whilst the spindle is rotating, The system keeps track of the current speed and will display an increasing or decreasing symbol, if the current speed varies by 20rpm from the previous readings. It will display a level symbol if the speed remains (roughly) contstant.
- Stop detection
The logic detects when there are no pulses detected over 4 separate time periods and instead of showing 0 rpm it displays the word STOPPED.
- Stopped - eye candy
Ok I have to admit this was a bit of an indulgence. If the spindle remains STOPPED for more than a minute the display is slowly replaced by a snake that goes round the display clockwise, clearing each character. As soon as the sensor detects a pulse the tachometer reverts to a normal display.
- Mill Usage
I though that it might be useful to record how long the mill spindle was rotating. It counts the time intervals and when these reach 240 [60 seconds time 4 intervals] it adds 1 to the minute counter. It rolls this up into hours. When the spindle stops it updates some NVRAM with the new values if any of these have changed. The time values are read back when the tachometer initialises on power up. The timer will roll over to zero when it goes past 99 hours 59 minutes. I have also included a reset facility, to zero the NVRAM value if certain conditions are met at power up.
- 2 line display
With all the extra information, that I wanted to display, I settled on a 2 line diplay, with the top line showing the usage time and the lower for the actual spindle speeds.
The code was written using the free Boost C compiler for PICs and debugged using the SourceBoost IDE Plugins. These latter items are very useful and dramatically cut the development time. A license is required, but the cost is well worth the time saved. I have included quite a lot of notes within the code. I found a USB powered programmer on eBay, from somewhere in China that works very well. I had in the past built my own, but they were powered from the serial port, which are fast disappearing, especially on laptops.
Bolt on or re-engineer
Not content with adding a tachometer display to the existing mill, I decided, for neatness, to replace the control box on the side of the mill head with something that housed both the display and the rest of the wiring.
I have put the code in the downloads page, see top level menu at top of the page.