Upload
juliusjgunn
View
39
Download
1
Tags:
Embed Size (px)
DESCRIPTION
Allen Bradley PLC An Emphasis on Design and Application download pdf
Citation preview
GENERALINTEREST
60 Elektor Electronics 4/2001
Part 2: The controller
Design by T. Mller (Radix GmbH) www.radixgmbh.de
Our PCB drilling machine provides a link between a Windows PC and themotors and solenoids of the machine itself: a microcontroller integratedwith a high current drive circuit.
PCB Drilling Machine (2)
operating system, has other things to dowhile generating our output waveform.Updating the mouse position, checking forincoming e-mail, reading audio data from aCD, communicating with peripherals: allthese take processor time.
Windows is event-driven, which meansthat the various parts of the machine cancause the operating system to carry out oper-ations. This can be seen when printing, forexample: Windows launches a process tocommunicate with the printer, and suppliesit with new data as and when it is ready toaccept it. When that happens and how muchdata is transferred at a time is totally unde-fined, but nevertheless consumes processortime. This can interfere with the timing of oursquare wave and cause variations in itsperiod.
There are two ways to overcome this prob-lem. We could shut down all other processesand disable multitasking while we generateour square wave. Then we might as well useDOS, which is what most manufacturers ofthis type of control software for smallmachines do. Under DOS, an application pro-gram can use the full power of the processorfor itself. Of course, we sacrifice the ease ofuse of Windows, and, in spite of its power,the computer cannot be used for anythingelse.
There are various operating system add-ons available for Windows which amelioratethis situation and provide quasi-real-timefacilities. These are mostly VXD or TSR pro-
In the previous instalment (March2001) we described in detail thebasic principles of the CNC drillingmachine. The controller is just asunconventional: the machine is notdriven directly from a PC, but indi-rectly via a special controller circuit.For trouble-free communicationbetween the Windows PC and thecontroller over the Centronics inter-face we need to make use of severaltricks that take us beyond the stan-dard Centronics protocol.
Lets start by taking a look at therather straightforward hardware ofthe controller board. The basic circuitconsists on one side of a microcon-troller with a PC interface and on theother the output drive circuits, con-nected to I/O-port pins. Of coursethere is rather more to the designthan that.
Real-time with Windows?
How can we control a stepper motorfrom a PC? It goes without sayingthat we need an output drive circuitcapable of supplying the currentrequired by the motor, since none ofthe PCs interfaces can drive a motordirectly. And then, in order to makethe motor step smoothly, we needvery accurate timing.
At first blush it would be ideal ifwe could somehow connect the out-put stages directly to the PC andhandle practically all the control sig-nals directly as bits from the PC. Thecircuit would then be very simple,consisting of just a couple of latchesand an address decoder.
Unfortunately, Windows has arather unpleasant characteristic: itsoperations are totally asynchronous.It is impossible to say at exactlywhat time an event will occur.Approximate timing is possible, butas the specified time betweenevents gets smaller and more pre-cise, something eventually will gowrong. Windows on its own was notdesigned for control applications,and indeed is not suitable for them.It may be easy to use, but from thehardware point of view it is no moresuitable than older operating sys-tems such as DOS.
First of all, modern programminglanguages offer hardly any com-mands for access to the I/O-ports;and second, multitasking prevents
direct hardware access by programsthat attempt to bypass the operatingsystem. Special drivers are required,such as port.dll found in the Elek-tor Electronics book PC Ports underWindows (to be published soon).
Let us suppose that you haveavailable a programming languagethat lets you control the port signalsat will. We wish to generate a con-tinuous square wave on one of thedata pins of the Centronics port at agiven frequency. In software this is atrivial matter: we simply need to tog-gle the bit in question regularly. Inorder to obtain the desired fre-quency, the appropriate delay mustbe used. If the delay is reasonablylarge, say 0.5 s, we obtain a perfectoutput signal with a frequency of1 Hz.
If, however, we reduce the delayto say 0.5 ms and hence raise the fre-quency to 1 kHz, we hit a problem.The right frequency appears at theoutput, but only when averaged overa long period. The individual pulselengths are a little longer or shorterin a random pattern, and some arevery different from the specifiedperiod. Why is this?
Of course, modern processors arefast enough to toggle a bit 2,000times per second. No, the reason isthat Windows, as a multitasking
GENERALINTEREST
614/2001 Elektor Electronics
A universal controller boardThe controller board, with its power output stages and integrated microcontroller, hasbeen designed not just for use with the PCB drilling machine, but also with enough flexibil-ity to be used for many other purposes. The driver stages make it a very handy controllerboard for other equipment or machines that employ stepper motors and other high cur-rent devices. For this reason there are a few places in the layout where we have madeadditions that are not strictly necessary for the drilling machine application.
To take one example, the output stages are controlled by a GAL. The GAL is simply pro-grammed to combine the PWM signal with a two-bit address to activate the solenoid drive,and (with an enable input) the drill motors. This function could easily have been carried outusing a simple address decoder such as a 74138. However, by using a GAL we can com-pletely reconfigure the eight output stages. To this end, you will see that we have routedextra signals from the microcontroller to the GAL, in particular signals that can be assignedspecial functions in the microcontroller.
Series resistors and capacitors can be fitted at the inputs to the driver stages. The powerMOSFETs used in the drilling machine controller do not require these; but if you wish touse bipolar transistors in the drive stages, the spaces we have left on the board will come inhandy.
grams that are loaded when Windows startsup and then run in the background. Theseprograms run briefly, but at an exact momentin time; and they run at the highest priorityto guarantee having the necessary processorpower available to them.
These programs are rather critical and con-siderably increase the chances of Windowscrashing. They also permanently consumememory and processor time, because they arealways present and must always be ready tospring into action when required.
These programs are also often writtenusing undocumented features or back doorsin the operating system, and so are usuallyonly fully compatible with one particular ver-sion of the system.
Offloading the synchronisationproblemWe have therefore chosen an alternativeapproach to driving a stepper motor underWindows. Synchronisation is not left up toWindows software, but rather transferred toa microcontroller. The microcontroller receivesa control command (for example for a motorpulse), and rather than executing it immedi-ately, waits for further timing information toindicate when the data are to be processed.In this way, as long as the overall system isfast enough, we can obtain perfectly syn-chronised results using Windows.
The information passed to the microcon-troller to generate a square wave runs as fol-lows: bit high in 500 s, bit low in 500 s,Repeat. This information is sufficient for themicrocontroller to produce the signal inde-pendently, requiring no further interventionfrom the PC. The PC must deliver the datafast enough, each command arriving within500 s. This should not present any difficultyfor a reasonably fast PC.
To prevent the PC having to wait until themicrocontroller is ready for a new command,the controller is equipped with a small FIFOmemory with space for 40 entries. This allowsthe controller to be well decoupled from thePC. The PC can send off 40 precalculatedcommands for switching the various outputsignals to the controller and then has40500 s to prepare new data or carry outother tasks.
Shortly before the FIFO empties, this stateis flagged to the PC, which can then refill theFIFO with new data. This does not affect thecontroller, which continues executing com-mands one after another with perfect timing.
Using the Centronics interface
Communication with the controller could be
carried out over any PC interface.The Centronics and V24 (serial)interfaces are always available, andare particularly suitable candidates.
There are certain problems asso-ciated with the V24 interface: get-ting the wiring right and arranginghandshaking can be full of pitfalls.Matters are also more complicatedfor the microcontroller, which mustfirst convert the serial bit stream intoparallel bytes. And, if the microcon-troller does not contain a UART, thecontroller must detect and interpretthe start bits itself. This consumesprocessor time in the controller andultimately creates difficulties inensuring timely execution of com-mands.
For these reasons, we have cho-sen the Centronics interface. Thisinterface is also superior from thepoint of view of speed, becauseeight bits are transferred at a time:this also makes the data easy toprocess. The data are simply writtento a specific I/O address and the jobis done. It is also convenient for themicrocontroller to receive the data ina simple 8-bit format.
Eight bits may be a convenientnumber, but it is too few to specify acommand with timing information.Multiple bytes must be assembledtogether to construct a useful com-mand so that the controller canknow what to do with the data. Forour application, two bytes areenough for each command, but thatis too much to transfer in one go overthe Centronics interface. But whenthe 16 bits are divided into two inde-pendent bytes, a synchronisationproblem can arise.
The strobe-edge trick
How can the controller know whichof the bytes is the first and whichthe second? Counting is one option,but not a very reliable one: a singletransmission error and all successivecommands will be wrongly inter-preted. The error must be detectedand the controller reset. Alterna-tively, the data bytes could includefurther information to allow the con-troller to identify which is which.
However, this also has its disad-vantages. The marker bits naturallyreduce the amount of real informa-tion transferred, and so we have
fewer bits available for commands.For this reason we distinguish the
bytes externally using a meansalready provided within the Cen-tronics interface. Take a look at theprotocol as shown in Figure 1. Firstconsider normal operation,described at the top of the figure.The interface, however, will let ustransfer two bytes at a time withoutmodification. How that is achieved isdescribed at the bottom of the figure.
The handshaking process isunchanged: we have simplychanged the meaning of the signals.Two bytes are coalesced into a sin-gle packet, where the falling edge ofthe STROBE signal marks the firstbyte, and the rising edge, the sec-ond.
If an error occurs when the firstbyte is already in the process ofbeing sent, STROBE will eventuallyrise, if only because of the pull-upresistor fitted to the controller board.The transfer is then terminated, andthe pair of bytes remains together.Synchronisation problems are there-fore impossible, even though thecontents of the two bytes will be inerror. If on the other hand we hadsimply counted bytes, then all sub-sequent bytes would be interpretedwrongly, as they would all be inter-changed. If we were to continue inthis manner, the controller wouldcease operating correctly hence thesystem would have to be re-ini-tialised.
At start-up the control softwaresends a RESET command, whichcauses the controller to clear itsFIFOs and bring to a halt all move-ments in progress in the system.
Controller functions
We have now described the mainfunctions of the controller: acceptingthe 16-bit wide instructions, storingthem in the FIFO, and synchronouslyexecuting the commands stored inthe FIFO. Of course, the calculationof trajectories is not handled by themicrocontroller, since it is notdesigned for trigonometric calcula-tions and would be too slow. Itwould also imply programming thedynamic characteristics of the sys-tem once and for all into the micro-controller.
Instead, the movements are pre-
GENERALINTEREST
62 Elektor Electronics 4/2001
processed in the PC and then sent tothe controller in the form of primitiveinstructions such as motor 1 one stepcounterclockwise. All movements aredefined in the PC in this way. It ispossible to compute the step infor-mation for any desired motion andthen send it to the controller: andthus the microcontroller never needsto be reprogrammed.
Data format
Now that we have explained howthe command data are calculated inthe PC and transferred over the Cen-tronics interface to be synchronouslyprocessed by the controller, we cantake a look at to the internal struc-ture of the command data.
The two bytes are concatenatedto form a word. This word contains adata value, or operand, along withan address which determines howthe operand is interpreted: in otherwords, the particular command to beexecuted. The number of addressand data bit is variable, the numberof data bits shrinking as moreaddress bits are required. A com-mand with a short address field cancontain a longer operand, and viceversa. This kind of addressingscheme can be processed using asequence of branches, decoding thecommand using the divide and con-quer principle.
This works as follows: the firstaddress bit determines whether weare dealing with one particular typeof command (when the bit is a 1) ornot (when it is 0). In the secondcase we still do not know what typeof command we are processing, sowe examine the second bit. If this isa 1, then we have decoded a sec-ond class of commands, while if it is0, we proceed to examine the thirdbit, and so on. Of course, as we con-tinue to examine bits is this way,there remains less and less space forthe operand data.
The advantage is that we onlyneed one address bit for the firstcommand type, and so we have a full15 bits available for the operanddata. For commands whose addressfield is, say, three bits long we have13 bits available. Note that a three-bit address field allows at most eightdifferent commands to be separatelydecoded.
GENERALINTEREST
634/2001 Elektor Electronics
1
1
2
2
3
3
4
4 5
5
6
6 7 8010024 - 2 - 12
DATA
STROBE
BUSY
1. Quiescent condition:STROBE from PC to microcontroller is high. BUSY from microcontroller to PC is low.
2. The PC wishes to transfer data as usual, and puts the data byte on the eight data lines.
3. The PC takes STROBE low. The connected microcontroller (or peripheral device) seesthe low state and knows that the data are ready to be read.
4. The microcontroller takes the data byte and sets BUSY high in acknowledgement.
5. The PC takes the STROBE signal high again.
6. When the microcontroller has processed the byte, it indicates this state by taking theBUSY signal low. This completes the transfer of a byte. The system is ready to transferanother byte, the control signals (BUSY and STROBE) being once more in their originalstates.
1. Quiescent condition:STROBE from PC to microcontroller is high. BUSY from microontroller to PC is low.
2. The PC wishes to transfer data using the special mode, and puts the data byte on theeight data lines.
3. The PC takes STROBE low. The microcontroller sees the low state and knows that thedata are ready to be read.
4. The microcontroller now takes the data byte and sets BUSY high in acknowledgement.
5. The microcontroller processes the byte immediately and leaves the BUSY signal high.
6. The PC observes that the BUSY signal is high and therefore that the first byte has beenaccepted. It then puts the second byte on the data lines.
7. The PC indicates that the second byte is present by taking STROBE high again. Thiscauses the microcontroller to accept this byte also.
8. When the microcontroller has finished its processing, it sets BUSY low again.
Figure 1. The original Centronics protocol (above) and as modified for the drilling machine(below).
GENERALINTEREST
64 Elektor Electronics 4/2001
PIC16C64
OSC2
IC13
OSC1
MCLR
RB0RB1RB2RB3RB4RB5RB6RB7
RE0RE1RE2
RD0RD1RD2RD3RD4RD5RD6RD7
RA0RA1RA2RA3RA4RA5
RC0RC1RC2RC3RC4RC5RC6RC7
13 14
33
11
12 31
32
34353637383940 10
1920212227282930
1516171823242526
1
89
234567
X1
16MHz
C63
15p
C64
15p
+5V
R41
10k C60
100n
+5V
JP1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
K21
R231k
C39
820p
R24
1
1W
C40
820p
R25
56k
K15
+5V +30V
C38
100n
C41
100n
R261k
C43
820p
R27
1
1W
C44
820p
R28
56k
K16
+5V +30V
C42
100n
C45
100n
R171k
C31
820p
R18
1
1W
C32
820p
R19
56k
K13
+5V +30V
C30
100n
C33
100n
R201k
C35
820p
R21
1
1W
C36
820p
R22
56k
K14
+5V +30V
C34
100n
C37
100n
SEL
R111k
C23
820p
R12
1
1W
C24
820p
R13
56k
K11
+5V +30V
C22
100n
C25
100n
R141k
C27
820p
R15
1
1W
C28
820p
R16
56k
K12
+5V +30V
C26
100n
C29
100n
R351k
C55
820p
R36
1
1W
C56
820p
R37
56k
K19
+5V +30V
C54
100n
C66
100n
R381k
C58
820p
R39
1
1W
C59
820p
R40
56k
K20
+5V +30V
C57
100n
C67
100n
R291k
C47
820p
R30
1
1W
C48
820p
R31
56k
K17
+5V +30V
C46
100n
C49
100n
R321k
C51
820p
R33
1
1W
C52
820p
R34
56k
K18
+5V +30V
C50
100n
C53
100n
SEL STEPA1
PBL3717APHASEIC7
RSNS
IN0
V+A
CIN
IN1
REF V+B
16
11
12
14
13 10
PT
OB OA15
9
6
4 5
87
3
2
1
PBL3717APHASEIC8
RSNS
IN0
V+A
CIN
IN1
REF V+B
16
11
12
14
13 10
PT
OB OA15
9
6
4 5
87
3
2
1
PBL3717APHASEIC5
RSNS
IN0
V+A
CIN
IN1
REF V+B
16
11
12
14
13 10
PT
OB OA15
9
6
4 5
87
3
2
1
PBL3717APHASEIC6
RSNS
IN0
V+A
CIN
IN1
REF V+B
16
11
12
14
13 10
PT
OB OA15
9
6
4 5
87
3
2
1
PBL3717APHASEIC3
RSNS
IN0
V+A
CIN
IN1
REF V+B
16
11
12
14
13 10
PT
OB OA15
9
6
4 5
87
3
2
1
PBL3717APHASEIC4
RSNS
IN0
V+A
CIN
IN1
REF V+B
16
11
12
14
13 10
PT
OB OA15
9
6
4 5
87
3
2
1
PBL3717APHASEIC11
RSNS
IN0
V+A
CIN
IN1
REF V+B
16
11
12
14
13 10
PT
OB OA15
9
6
4 5
87
3
2
1
PBL3717APHASEIC12
RSNS
IN0
V+A
CIN
IN1
REF V+B
16
11
12
14
13 10
PT
OB OA15
9
6
4 5
87
3
2
1
PBL3717APHASEIC9
RSNS
IN0
V+A
CIN
IN1
REF V+B
16
11
12
14
13 10
PT
OB OA15
9
6
4 5
87
3
2
1
PBL3717APHASEIC10
RSNS
IN0
V+A
CIN
IN1
REF V+B
16
11
12
14
13 10
PT
OB OA15
9
6
4 5
87
3
2
1
D7D5D3D1D0D2D4D6
STROBED0
D1
D2
D3
D4
D5
D6
D7
R44
10k
+5V
ERROR
PE
SELECT
STEPA2STEPB2STEPA3STEPB3
STEPA5
PLSELECT
PE
IC2
16V8GAL
19
20
10
I0I1I2I3I4I5I6I7I8
F7
11I9
12 F013 F114 F215 F316 F417 F518 F6
123
67
8
45
9
+5V
D5
C15
220n
C14
100n
+15V
T5
R7100
K7
D1
C7
220n
C6
100n
+15V
T4
R3100
K3
D6
C17
220n
C16
100n
+15V
T6
R8100
K8
D2
C9
220n
C8
100n
+15V
T3
R4100
K4
D7
C19
220n
C18
100n
+30VT7
R9100
K9
D3
C11
220n
C10
100n
+30VT2
R5100
K5
D8
C21
220n
C20
100n
+30VT8
R10100
K10
D4
C13
220n
C12
100n
+30VT1
R6100
K6
ADR1DRILLADR0PWM
SPARE1SPARE0
R1
10k
R2
10k
R43
10k
R421k
BU4BU1 BU2 BU3
+5V
STEPB5CLKSTEPB4STEPA4STEPB1STEPA1SEL
SPARE0SPARE1PWMADR0ADR1DRILLSTROBEERROR
SOUT
8x 47k1
2 3 4 5 6 7 8 9
R48
+5V
BO1
BO2
BO3
BO4
BO5
R47
560
T11 T10 T9
R46
560 R45
560
+5V
R49
1k
D12
PL
K1
K2
C3
3300 50V
C4
3300 50V
C5
3300 50V
2A T
F2
2A T
F1
C1
100n
C2
100n
7805IC1
B1
B2
+30V
+5V
+15V
SOUT
PLCLK
C1[LOAD]
74HC165
IC14SRG8
C2/
1011121314
1
2D1D1D
1D
15
7
9
3456
21
C65
100nIC14
16
8
+5V
C62
100n
C61
100n
SPARE
SEL
SEL
SEL SEL
SEL
SEL
SEL
SELSTEPB1
STEPA2
STEPB2
STEPA3
STEPB3
STEPA4
STEPB4
STEPA5
STEPB5
DRILL4
DRILL3
DRILL2
DRILL1
COIL4
COIL3
COIL2
COIL1010024 - 2 - 11
COIL1/DRILL1COIL2/DRILL2COIL3/DRILL3COIL4/DRILL4
TARGETADR0 ADR10101
0011
D1 ... D8 = 1N4001T1 ... T8 = BUZ11
GBU6B
GBU6B
Figure 2. The drilling machine controller board: lots of brawn, and a little bit of brains!
The variable-length address field alsoallows a higher priority to be assigned tomore common or more urgent commands. Fora rarely used command, or one that initiatesa lengthy action, we can allow the addressdecoding to take a little longer.
The commands which are most commonlyused, and which sent to the controller at thefastest rate, are without doubt the steppermotor commands; they also require a longoperand, which is provided by the highestpriority command format. The format of thecommands for sending stepping pulses to themotors is set out in Table 1.
The second command class is the drillingcommand. Three address bits can be used forthis command without causing any difficulty
because its execution time is muchlonger than the motor step com-mands, and because it requires ashorter operand. The meaning of thevarious bits in the drilling commandis set out in Table 2.
These two commands suffice forbasic operation of the PCB drillingmachine. In fact there is a range ofother commands which are less rel-evant to our discussion and whichare not described here.
Brawn and brains
At first glance the circuit diagram inFigure 2 may look like an impene-
trably complex piece of electronics,but on closer inspection we see thatthe brains of the circuit are actuallyvery simple. The intelligence is con-centrated in a type PIC16C64 micro-controller from Microchip, clocked at20 MHz. This microcontroller boaststhe magnificent total of 33 individu-ally addressable I/O-ports, but only2 K of EPROM program memory and128 bytes of internal SRAM, hereused for (among other things) theFIFO memory. The PIC16C64 isequipped with peripherals such as areal-time clock, timer/counter andcapture/compare inputs. In thisapplication we do not use the 3-wire
synchronous serial SPI/I2C bus.The modified Centronics interface uses
port D (data signals), RC6 (active-lowSTROBE), RE1 (SELECT) and RC7 (ERROR).The BUSY signal from the microcontroller isnot wired to the standard connection on pin11, but to the PAPER EMPTY signal (PE) onpin 12. There are several reasons for this: first,it prevents the PCB drilling machine fromspringing into action when a print job isstarted under Windows, and second, itallows a printer to operate in parallel with themachine. Further, pulses on the STROBE andBUSY signals appear to affect the internalinterrupt processing of Windows: and that isbest left well alone.
R44 is the pull-up resistor referred to abovethat pulls STROBE high in the event of a sys-tem crash, thus deactivating the signal.
The microcontroller determines the config-uration of the drilling machine via the drillinghead limit switches connected to Bo1-Bo4. Ifa drilling arm is fitted and the head is in theup position, the corresponding switch isclosed. If an arm is not equipped with a limitswitch, the corresponding contacts remainopen.
OptSpare is an optical input that, like theswitch input Spare, is not used in the presentdesign. OptBase is an optical input used tocalibrate the reference positions of arm 1,arm 2 and the rotating table. OptAdd doesthe same job for arms 3 and 4. How exactlythe calibration is carried out will be describedin a later article in this series. The LED canbe used to indicate that the machine is oper-ating: it lights during drilling and during thecalibration process.
It may seem that 33 I/O-ports are plenty,but unfortunately are not enough for all thesignals just described. We therefore use ashift register type 74HC165 (IC14) to combinethe bits into a single byte read serially by themicrocontroller over a single port bit RA4(SOUT). A parallel load pulse loads the bitsinto an intermediate register where they arebuffered before being clocked out using theCLK signal (RB2).
The final item of information read by thecontroller is the stop signal from the sole-noid limit switch. These switches are con-nected to BU1-BU4. Since the current must beswitched off quickly, it is not feasible to readthese signals out slowly via a shift register.Instead, the stop signal drives the interruptinput RB0 low. Since only one drilling head isactuated at a time, the four limit switches canbe connected in parallel.
The rest of the circuit consists of the fouridentical output drive stages for the solenoids(T1, T2, T7 and T8), the drill motors (T3-T6)and ten identical integrated stepper motor
GENERALINTEREST
654/2001 Elektor Electronics
Table 1: Motor pulse command
MSB Byte1 Byte2 LSB1 Z Z Z D T T T Z Z Z Z Z Z Z Z
Addressing: bit 7, byte 1 = 1.
Z (11 bits): TimeThe time value specifies how long AFTER the execution of the motor pulse com-mand the controller must wait before executing the next instruction. If the valueis zero, then the next command (assuming it is also a motor pulse command) isexecuted immediately and synchronously with the present one.
T (3 bits): TargetThese three bits select the stepper motor drive stage affected by the command.The order runs from Target 1 (000), the output stage driving connectors K11and K12, through to Target 5 (100), the output stage driving connectors K19 andK20.Target addresses 6, 7 and 8 (101, 110 and 111) are reserved.
D (1 bit): DirectionThis bit specifies the direction in which the motors are to turn. D=1 specifiesclockwise rotation, D=0 counterclockwise.
Table 2: Drilling command
MSB Byte1 Byte2 LSB0 T T T 1 1 B B B B B D D D D D
Addressing: bit 7, byte 1 = 0; bits 2 and 3, byte 1 = 11.
T (3 bits): TargetThese three bits select the output stage for the drilling command. The machinecan be fitted with up to four arms, and each of these arms has its own drill and adedicated driver stage on the controller board. The targets are numbered fromleft to right, starting with Target 1 (000) at connector K10, where the solenoidfor the first arm is connected. The corresponding drill motor is connected to K8.Target 4 (011) is driven from connectors K5 (solenoid) and K3 (drill motor). Tar-gets 5 to 8 (100 to 111) are reserved.
D (5 bits): Drilling forceThe force applied to the drill by the solenoid can be controlled by this five-bitdata value. The value sets the amuont of energy delivered to the solenoid, andcan be set to any number in the range 0 to 31.
B (5 bits): Braking controlWhen the drilling head is withdrawn the solenoid cannot simply be switched off,since this would cause long-term wear on the mechanism. To prevent unduestress on the motor guide spring, the magnetic field in the solenoid is graduallyreduced, so that the drilling head is withdrawn gently.In principle this value can be set in advance for a particular weight of drilling head.Here, however, we have the possibility of optimising the value. If, for example,you use a more powerful drill motor or a 3-jaw chuck instead of the collet chuck,the weight of the drilling head may be significantly different.
drivers type PBL3717A from ST Microelec-tronics. The datasheet for this IC can readilybe found on STs website at www.st.com.
First let us consider the drill motors andsolenoids. These are not driven directly, butrather via a programmable logic device typeGAL 16V8. You can read the reasons for thisin the box A universal controller board.Address signals ADR0 (RC3) and ADR1 (RC4)select from the at most four motors and sole-noids in the order shown. The level on DRILL(RC5) selects either the motor (when RC5 islow) or the solenoid (when RC5 is high). Inthis way we make sure that in the case of afailure in the circuit the drill will not turn andthe drilling head will be up. When the circuitis switched on, the PICs ports are in a highimpedance state, and resistors R1 and R2hold the signals at suitable levels to ensurethat the motors and solenoids are safelyturned off.
The controller activates the selectedmotor/solenoid pair using port pin RC2. Thepin does not just turn on and off, but providea current control using a PWM signal, differentfor the solenoid and for the motor.
The solenoids are controlled using a rathercomplicated current waveform. The timingdepends on the instantaneous position of thedrilling head (which is determined from thetwo switches on the head guide), the valuespecified in the drilling command, and onwhether an error situation arises due, forexample, to a timeout resulting from ajammed or dirty guide. The important fact isthat the PWM control value is calculated ateach point in time to actuate the guide sole-noid as smoothly as possible.
The solenoid coils are rated for continuousoperation at 12 V, and they are driven
(although only momentarily) from thesame +30 V supply as the steppermotors. This produces an enormousmagnetic field to force the drillinghead down. As soon as the appro-priate Bo switch opens, the PIC candeduce that the solenoid has movedand it then proceeds to regulate thecurrent to the value specified in thedrilling command using the PWMsignal. Although the solenoid is ini-tially overdriven, in continuous oper-ation it is only driven at effectively12 V with an 80% duty cycle. This iswithin the specified limits. Overall,with typical activity, the duty cycleis only a few percent, and in practicethe coils only get warm to the touch.
The drill motors are controlledduring switch-on and running usinga PWM ramp that reaches 100% dutycycle during drilling.
The stepper motors are activatedusing the STEP signals. EachPBL3717A integrated driver controlsone motor winding, and two drivers(STEPAx and STEPBx) are allocatedto each motor. The drivers areresponsible for producing the drivepulses and for converting the +5 Vlogic levels to +30 V, the operatingvoltage of the stepper motors. Themicrocontroller activates the drivervia the level (repsectively fromSTEPAx and STEPBx) at the PHASEinput, and a current then flows fromOA to OB. Inputs IN0 and IN1 have aspecial function: they allow controlof the output stage drive current.
This is normally achieved using a
retriggerable timing circuit for eachoutput stage. If no more motion isrequired of the motors, the pulsesstop and the current is reduced inthe motors. Here, this is realised viathe signal from RB7 (pin 40) con-nected to the IN1 pins of all thePBL3717s. When motion is required,all the motors are driven with fullcurrent (even those which are not tomove), by setting IN1=0. Shortlyafter the motion stops, IN1 is set to1 again, and the current drive isreduced to 19%.
Why do we increase the currentto the motors not involved in amotion? Partly because in this waythe power supply is loaded to thesame extent independent of themotion, and partly because, as aresult of various resonances in thesystem, those motors driven at 19%of the maximum current can bejogged out of position. Although thisis rather unlikely, it would lead toerrors almost impossible to trackdown.
(010024-2)
In the next instalment of this serieswe get down to the construction ofthe controller board as well as thenuts and bolts of the project. The var-ious parts of the PCB drillingmachine will be brought together,with illustrations and lots of glueand grease!
GENERALINTEREST
66 Elektor Electronics 4/2001