Home > Advanced Projects > CNC Drill > Electronic Control
CNC PCB DRILL - ELECTRONICS

Modified: 23:23, 26 October 2013

SPECIFICATION:

This project has a lot to it so has been split into the following pages:
  • Reads .drl gerber format files
  • 0.001" resolution
  • 0.002" accuracy
  • 265mm x 280mm table
  • Manual feeds
  • LCD display
  • Serial connection.

BLOCK DIAGRAM
Below is a block diagram of the circuit. The heart of the circuit is a PIC16F873 micro-controller. It interrupts 10,000 times a second to read inputs and update motor PWM control. The rest is basic I/O circuitry. It can easily be broken down into sections.

1 - Input switches/sensors and multiplexer
2 - PIC Micro-controller
3 - Output decoder and latches
4 - H-Bridge and Darlington drivers

Click on any section for circuit diagram for that part.


INPUT DECODER
The input section is shown below.
The X/Y limit switches are slotted opto switches Q2, 3, 5 and 6 which are all buffered by IC4. The buffer outputs are connected to LEDs via IC5 which is a Darlington driver. They also are multiplexed onto the IBus0-3 via IC6 which selects the signals when IOSEL=00 using the BCD decoder IC8. Note the sensor inputs are inverted by the time they get to the IBus. The buffered inputs also go to the braking logic in the Output Decoder section.

The X/Y position sensors are also slotted opto switches which connect to Schmitt inverters to clean up their signal and connected directly to the micro-controller and IC5 to drive 2 green LEDs/

The Z postion (drill height) is found using a slide potentiometer whichi s connected to one of the analogue inputs of the micro-controller.

The PIC keeps track of the X and Yposition by counting each slot on the slotted wheels connected to the X and Y axis drive threads. Each slot produces a pulse representing 1/1000 of an inch. The position is held inside the PIC and displayed on the LCD screen. The pulses are only monitored when the motors are actually running so it knows whether to count up or down.

This also means that if the drill position is out by any amount, the drilling procedure can be paused by the PC and the position corrected by turning the threads by hand. It may seem a bit of a bodge but it is actually a quick and effective method of adjusting the position, even if you do get greasy hands from the threads.

The 2 pairs of dots on the bottom row reflect the status of the X and Y minimum and maximum sensors - eg. if Xmax has been hit the dots change to "X+" and Xmin display "X-"

The switch on the left selects between USER and AUTO MODE.

In USER mode the user can move the X, Y and Z positions using the 2 x 3 array of buttons next to the switch. The HOME button first raises the drill to the maximum height if needed, then moves the drill to bottom left corner until the limit sensors are hit, then nudges out just clear of them.

In AUTO mode, the PC has sole control over the drill position and the drilling. All manual operations can also be done from the PC in the VB program - but only when the drill is in AUTO mode since this is the only tie it responds to the serial port.

Twelve switches are multiplexed in banks of 4 when IOSEL=01, 10 and 11. These switches are for manual feeds and for menu control on the LCD. IC8 (BCD-decimal decoder) selects which bank of 4 inputs are connected to the IBus which carries input data to the micro-controller.

IOSEL1
IOSEL0
IB3
IB2
IB1
IB0
0
0
XMax
XMin
YMax
YMin
0
1
X Up
X Dn
Y Up
Y Dn
1
0
Z Up
Z Dn
Menu+
Menu-
1
1
Menu
MSel
Auto
Set
The X axis position sensor. Laser cut birch plywood with 59 slots. The thread pitch is 1.5mm so one turn = 1.5mm = 59/1000" The Y axis position sensor. Laser cut birch plywood with 39 slots. The thread pitch is 1mm so one turn = 1mm = 39/1000". The Z position sensor mounted at one end to allow movement of arc from driilling arm. The slider is wired to the arm. One of the X axis limit opto switches mounted on the base, lines up with a lug on the underside of the table. There is one at each end, Xmin & Xmax. One of the Y axis limit opto switches mounted on a vertical support, lines up with a lug on the drill carriage. There is one at each end, Ymin & Ymax.

PIC MICRO CONTROLLER
The micro-controller is the heart of the system. It controls all communication for the serial port and for input signals. It also generates 3 PWM outputs multiplexed onto one 4-bit bus and it sends messages to the LCD display. The IC runs at 20MHz clock speed which is just fast enough to complete all the tasks.
The communication to the serial port is via IC2 an MAX232 transceiver which generates the correct voltages for transmission. The Baud rate is set to 9600 which is fast enough. The software implements a 12 byte buffer since the longest reception will be 11 bytes long being the co-ordinates

The display is a 4 x 16 LCD display which shows the following information:

  • 1st Line: The USER/AUTO mode or current actions such as HOMING...
  • 2nd Line: The co-ordinates recieved and the destination for the drill
  • 3rd Line: The current x/y position of the drill in 1/1000"
  • 4th Line: The current z positon of the drill dipslayed in inches above or below the surface of the table. It also shows X/Y limit switch status.

The clock is generated from a 20MHz crystal oscillator module.

The INPUT BUS (IB0-3) takes signals from the multiplexed buttons and limit switches. The x/y/z positions are not multiplexed as they change very quickly when the motors are running and would skip slots.

The OUTPUT BUS (OB0-3) sends the PWM signals to the data latches for each motor.

IN/OUT SELECT (IOSEL0-1) provide the address for the mulitlpexed inputs and outputs on the I/O BUSSES..


OUTPUT DECODER

The output decoder controls the signals that drive the X, Y and Z axis motors.

The signal for each H-bridge motor driver is sent via OBus0-3. The signal is latched into one of 3 latches (IC11-13) that are actually pre-settable binary counters that I had a few of and utilised the fact that they also act as a 4-bit latch.

IC10 is a BCD to decimal decoder and determines which latch the data goes to. The address on IOSEL is decoded providing the preset signal for the latches.

IOSEL1
IOSEL0
Latch
0
0
None
0
1
X axis motor
1
0
Y axis motor
1
1
Z axis motor

IC14 and 15 were an attempt to implement hardware braking should the PIC lock up and leave the table or carriage motors running flat out towards the end of their travel. Unfortunately there is a fundamental flaw in that the OBus is multiplexed yet the X/Y limit switches are not meaning the reset signals are not generated correctly. But it doesn't seem to adversely affect the operation of the drill, and the PIC program has been reliable. I will fix this in due course.


MOTOR DRIVERS

The motor drivers are H-Bridge type with NPN transistors used to interface to the MOSFETs which run at a voltage of 12v. D1-4 are protection diodes againsgt emf from the motor. The data signals come from the latches in the Output Decoder.

The switching codes are shown to the right with the associated function.

The MOSFETs get barely warm and can be stacked next to each other on the PCB to save space since there are 12 MOSFETs and 12 TO220 type diodes also..

D
C
B
A
Motor Function
0
0
0
0
Brake - both connections to 0v
0
1
1
1
Brake - both connections to +v
0
0
1
1
Forward - run towards max sensor
1
1
0
0
Reverse - run towards min sensor
0
1
1
0
Open circuit - motor free to run
x
x
0
1
Short circuit in left drivers - FATAL
1
0
x
x
Short circuit in right drivers - FATAL

MODIFICATIONS
A 5v regulator as a seperate PCB was added for the circuit supply and to power the opto-switch LEDs. There are 6 of these and the original regulator on the PCB did not have the room for a heatsink and used to get quite hot. I haven't actually measured the current but I should imagine it's around 400mA.

There is a bug in the program where once in a while the drill down/up cycle doesn't complete properly leaving the drill stuck in the down position with a very delicate tungsten carbide bit embedded in the board. When the table moved it obviously had it. I was going to implement some checks in the software but decided instead to put 2 microswitches in series with the supply to the X/Y motors that were disconnected when the drill was not in the up position. Now when the error occurs, the drilling procedure simply halts. It must be a conflict in the interrupt where a rare set of circumstances produces an error - perhaps register corruption as it did get tight on RAM memory - I will fix it....

Another mod was to put thermal resettable fuses in series with the motor supplies. I had a short between the PCB and the meccano frame holding it in place - the motor shorted and killed a MOSFET in seconds - lesson learnt.


by Phil Townshend 2012

www.edutek.ltd.uk - Working Electronics For Students & Teachers