Lesson 2. The turret: four pens

In pictures

After this lesson the plotter head is a turret: a turntable with four pens — black, red, green and blue. The SELECT button picks a colour, and the circuit turns the table by itself until the right pen reaches the work point. While the table is turning, the yellow BUSY lamp is lit and no pen touches the paper.


2.1. Idea: changing the pen means turning

The Apple colour plotter had just such a head: several pens in a circle, a turn brings the right one to the paper. Our table is a stepper motor with a disk and four holes d0…d3, 90° apart. The work point is where the black pen stands now (d0). A quarter turn — and the next pen comes to it.

d0d1d2d3CP = 0 — blackd0d1d2d3CP = 1 — redd0d1d2d3CP = 2 — greend0d1d2d3CP = 3 — bluea quarter turn clockwise = 6 steps of 15°to the work point (dashed) comes the hole that stood on top: d0 → d3 → d2 → d1so red (colour 1) goes in d3, green in d2, blue in d1
The turret: the table only turns forward, a quarter at a time. The CP counter is which pen is at the work point now; that one is always the one lowered.

2.2. Idea: the motor is two flip-flops in a ring

The table motor has four windings A B C D. Two neighbouring windings on — the rotor stands between them; switch to the next pair — the rotor steps 15°. The pairs go round: AB → BC → CD → DA → AB. A pair of CD4013 D flip-flops closed in a ring does exactly this: D1 = NJ2, D2 = J1, both clocked by the step STEPT. What happens on each step:

StepJ1J2A=NJ1 B=NJ2 C=J1 D=J2Windings
0001 1 0 0A B
1100 1 1 0B C
2110 0 1 1C D
3011 0 0 1D A
4001 1 0 0A B — round

Every clock — the next pair, the motor turns always the same way. Reset RST puts both flip-flops to 0 — the AB pair.

2.3. Idea: a quarter turn = 6 steps

A step is 15°, a quarter is 90°, so 6 steps. The CD4017 counts the steps: on each clock the next output O0, O1, … lights. When O6 lights, the counter is reset to O0 at once: QR = Q6 OR RST — the spare OR gate of the panel CD4071. We get a ring of 6 steps. The carry output CO is 1 on O0…O4 and 0 on O5; on the step O5 → O0 it rises — an edge once per quarter turn (QCO).

2.4. Idea: two two-bit counters

The colour number — 0 black, 1 red, 2 green, 3 blue — is two bits. Two toggle flip-flops from lesson 1 count 0, 1, 2, 3:

  • LC0 toggles on every SELECT press;
  • LC1 toggles when LC0 falls from 1 to 0 — its clock is NLC0, which rises at that moment.
SELECT (n)LC1LC0Colour
000black
101red
210green
311blue
400black

The same counter CP1 CP0 remembers which pen is now at the work point; it counts quarter turns (clock QCO).

2.5. Idea: turn until they match

What we want: if the chosen colour is not the pen at the work point — turn. Two numbers are equal when all their bits are equal. A bit «differs» is exclusive OR (CD4070): X0 = LC0 ⊕ CP0, X1 = LC1 ⊕ CP1. The numbers differ if at least one bit differs:

  • MOVE = X0 OR X1 (CD4071);
  • motor steps: STEPT = CKT AND MOVE (CD4081) — the 10 Hz clock passes only while we need to turn.

They match — MOVE = 0, the clocks stop coming, the table stands. Chose a colour «backwards» — the table still turns forward until it gets there: the turret has one direction, but the circuit is simpler.

2.6. Idea: BUSY — the pen is up while turning

The pen must not touch the paper while the table turns: an arc would be drawn across the sheet. A subtlety: MOVE goes out together with the last clock, while the rotor needs a moment to get there. So the circuit remembers for half a tick that it was turning: the second CD4013 flip-flop copies MOVE to MOVED on the falling edge of the clock (NCKT = NOT CKT). Hence:

  • BUSY = MOVE OR MOVED — the yellow lamp;
  • PDN = LPEN AND NOT BUSY — the pen may go down: the button says «down» and the table stands.

2.7. Idea: which pen to lower

We lower only the pen at the work point: the number CP1 CP0 → one of the four pins DOWN0…DOWN3 (a decoder on ANDs):

CP1CP0PenFormula
00DOWN0PDN AND NOT CP1 AND NOT CP0
01DOWN1PDN AND NOT CP1 AND CP0
10DOWN2PDN AND CP1 AND NOT CP0
11DOWN3PDN AND CP1 AND CP0

The shared halves of the formulas are built once: E0 = PDN AND NOT CP1, E1 = PDN AND CP1, then DOWN0 = E0 AND NOT CP0 and so on — eight AND gates on two CD4081s.

Why red goes into hole d3 and not d1: the table turns forward, and after a quarter turn the hole that comes to the work point is the one that stood before it — d3, then d2, then d1. Round: black d0, red d3, green d2, blue d1.

2.8. Build

On top of lesson 1. New chips and a few rewirings: to rename a label on a pin, double-click the label and type the new name; on an empty pin, double-click the pin.

Step 1. The SELECT button

PartPin / actionLabel / where
Button «SELECT»outputSELB

Step 2. The colour counter

The second flip-flop of the lesson 1 CD4013 (PEN UP/DOWN) was tied to GND — now it is the low bit of the colour.

PartPin / actionLabel / where
TI CD4013BS1
R1
D1
CL1
Q1
QN1
S2
R2
D2
CL2
GND
RST
NLC1
NLC0
LC1
NLC1
GND
GND
GND
GND
PartPinDetach fromAttach to
TI CD4013B, the one whose output = LPENR2GNDRST
TI CD4013B, the one whose output = LPEND2GNDNLC0
TI CD4013B, the one whose output = LPENCL2GNDSELB
TI CD4013B, the one whose output = LPENQ2— (not connected)LC0
TI CD4013B, the one whose output = LPENQN2— (not connected)NLC0

Leave unconnected: Q2, QN2 on the CD4013B.

Step 3. The motor clock

Clock — click until it shows 10Hz.

PartPin / actionLabel / where
Clock 10HzoutputCKT

Step 4. Compare and BUSY

PartPin / actionLabel / where
TI CD4070BA
B
J
C
D
K
E
F
G
H
LC0
CP0
X0
LC1
CP1
X1
GND
GND
GND
GND
TI CD4071BA
B
J
C
D
K
E
F
G
H
X0
X1
MOVE
MOVE
MOVED
BUSYH
GND
GND
GND
GND
TI CD4013BS1
R1
D1
CL1
S2
R2
D2
CL2
Q2
GND
GND
GND
GND
GND
RST
MOVE
NCKT
MOVED
TI CD4069UBA
B
C
I
D
J
E
F
GND
GND
BUSYH
NBUSY
CKT
NCKT
GND
GND

Leave unconnected: L, M on the CD4070B; L, M on the CD4071B; Q1, QN1, QN2 on the CD4013B; G, H, K, L on the CD4069UB.

Step 5. The motor and the pens

PartPin / actionLabel / where
TI CD4081BA
B
J
C
D
K
E
F
L
G
H
M
CKT
MOVE
STEPT
LPEN
NBUSY
PDN
PDN
NCP1
E0
PDN
CP1
E1
TI CD4081BA
B
J
C
D
K
E
F
L
G
H
M
E0
NCP0
DOWN0
E0
CP0
DOWN1
E1
NCP0
DOWN2
E1
CP0
DOWN3
TI CD4013BS1
R1
D1
CL1
Q1
QN1
S2
R2
D2
CL2
Q2
QN2
GND
RST
NJ2
STEPT
J1
NJ1
GND
RST
J1
STEPT
J2
NJ2
TI CD4017BCLOCK
RESET
INH
O6
CO
STEPT
QR
GND
Q6
QCO
TI CD4013BS1
R1
D1
CL1
Q1
QN1
S2
R2
D2
CL2
Q2
QN2
GND
RST
NCP0
QCO
CP0
NCP0
GND
RST
NCP1
NCP0
CP1
NCP1
PartPinDetach fromAttach to
TI CD4071B, the one whose output = LRGGNDQ6
TI CD4071B, the one whose output = LRHGNDRST
TI CD4071B, the one whose output = LRM— (not connected)QR

Leave unconnected: O0, O1, O2, O3, O4, O5, O7, O8, O9 on the CD4017B.

Step 6. The BUSY LED

PartPin / actionLabel / where
LED, yellowinputBUSYH

Step 7. The head

The table pins A…D were empty — put labels on them. The lesson 1 pen — from LPEN to DOWN0. Three new pens go into holes d3, d2, d1; colour — Alt/⌘+click the pen.

PartPin / actionLabel / where
Pen — redcolour (Alt/⌘+click)
DOWN
mount
red
DOWN1
on d3 (hole d3 of the table)
Pen — greencolour (Alt/⌘+click)
DOWN
mount
green
DOWN2
on d2 (hole d2 of the table)
Pen — bluecolour (Alt/⌘+click)
DOWN
mount
blue
DOWN3
on d1 (hole d1 of the table)
PartPinDetach fromAttach to
Turntable — the headA— (not connected)NJ1
Turntable — the headB— (not connected)NJ2
Turntable — the headC— (not connected)J1
Turntable — the headD— (not connected)J2
Pen — blackDOWNLPENDOWN0

2.9. Check

  1. Turbo mode, switch the power on. The black pen is at the work point.
  2. PEN UP/DOWN, draw a line — black.
  3. SELECT — the yellow BUSY lights up, the pen lifts, the head turns a quarter: red is at the work point. BUSY goes out — red comes down by itself (PEN UP/DOWN is still «down»). An arrow — a red line from the same point.
  4. SELECT again — green, blue, black again.
SELECT (n)At the work pointWhile it turns
0black
1redBUSY lit, the pen is up
2greenBUSY lit, the pen is up
3blueBUSY lit, the pen is up
4black againBUSY lit, the pen is up

Lesson 2 paste (Cmd+I)

Paste into the Apple ][ machine (the DEMO button) instead of lessons 1–2: it places everything built by the end of lesson 2.

# Lesson 2 - the turret: 4 pens on a turntable, SELECT, turning to the chosen pen.# ---------- mechanics: X axis, Y axis on its carriage, the head on the Y carriage, black pen, paper ----------maxis ax{len=400}(STEP=LXS, DIR=RIGHT, L0=XL0, L1=XL1, STALL=XSTALL)maxis ay{len=300, ang=90}(STEP=LYS, DIR=DOWN, L0=YL0, L1=YL1, STALL=YSTALL)mount(ay, ax.car)mtable tt(A=NJ1, B=NJ2, C=J1, D=J2)mount(tt, ay.car)mpen k0{color=black}(DOWN=DOWN0)mount(k0, tt.d0)mpaper p{w=460, h=360}at(p, 0, 0)at(ax, p, -41, -138)# ---------- panel: step clock, arrows, PEN UP/DOWN ----------clock{rt=60}(CKL)button{label="LEFT"}(LEFT)button{label="RIGHT"}(RIGHT)button{label="UP"}(UP)button{label="DOWN"}(DOWN)button{label="PEN UP/DOWN"}(PENB)# ---------- CD4071: an X arrow pressed, a Y arrow pressed; ERROR - a carriage is stuck ----------"TI CD4071B"(A=LEFT, B=RIGHT, J=LR, C=UP, D=DOWN, K=UD, E=XSTALL, F=YSTALL, L=ERROR, G=Q6, H=RST, M=QR)# ---------- CD4081: steps - the 60 Hz clock while an arrow is pressed ----------"TI CD4081B"(A=GND, B=GND, C=GND, D=GND, E=CKL, F=LR, L=LXS, G=CKL, H=UD, M=LYS)# ---------- CD4013: PEN UP/DOWN - a toggle flip-flop ----------"TI CD4013B"(S1=GND, R1=RST, D1=NLPEN, CL1=PENB, Q1=LPEN, QN1=NLPEN, S2=GND, R2=RST, D2=NLC0, CL2=SELB, Q2=LC0, QN2=NLC0)# ---------- POWER and ERROR LEDs ----------led{color=green}(VCC)led{color=red}(ERROR)# ---------- the SELECT button ----------button{label="SELECT"}(SELB)# ---------- CD4013: the high bit of the colour ----------"TI CD4013B"(S1=GND, R1=RST, D1=NLC1, CL1=NLC0, Q1=LC1, QN1=NLC1, S2=GND, R2=GND, D2=GND, CL2=GND)# ---------- the turret motor clock ----------clock{rt=10}(CKT)# ---------- CD4070: colour differs from the pen at the work point ----------"TI CD4070B"(A=LC0, B=CP0, J=X0, C=LC1, D=CP1, K=X1, E=GND, F=GND, G=GND, H=GND)# ---------- CD4071: MOVE - turn; BUSY - turning or has just finished ----------"TI CD4071B"(A=X0, B=X1, J=MOVE, C=MOVE, D=MOVED, K=BUSYH, E=GND, F=GND, G=GND, H=GND)# ---------- CD4013: MOVED - MOVE half a tick ago (second flip-flop; the first one - lesson 3) ----------"TI CD4013B"(S1=GND, R1=GND, D1=GND, CL1=GND, S2=GND, R2=RST, D2=MOVE, CL2=NCKT, Q2=MOVED)# ---------- CD4069: NOT BUSY, NOT the clock (inputs A and B - lesson 3) ----------"TI CD4069UB"(A=GND, B=GND, C=BUSYH, I=NBUSY, D=CKT, J=NCKT, E=GND, F=GND)# ---------- CD4081: motor step, the pen may go down, a pair of pens ----------"TI CD4081B"(A=CKT, B=MOVE, J=STEPT, C=LPEN, D=NBUSY, K=PDN, E=PDN, F=NCP1, L=E0, G=PDN, H=CP1, M=E1)# ---------- CD4081: which pen to lower ----------"TI CD4081B"(A=E0, B=NCP0, J=DOWN0, C=E0, D=CP0, K=DOWN1, E=E1, F=NCP0, L=DOWN2, G=E1, H=CP0, M=DOWN3)# ---------- CD4013: motor phases - two flip-flops in a ring ----------"TI CD4013B"(S1=GND, R1=RST, D1=NJ2, CL1=STEPT, Q1=J1, QN1=NJ1, S2=GND, R2=RST, D2=J1, CL2=STEPT, Q2=J2, QN2=NJ2)# ---------- CD4017: a quarter turn = 6 steps ----------"TI CD4017B"(CLOCK=STEPT, RESET=QR, INH=GND, O6=Q6, CO=QCO)# ---------- CD4013: the number of the pen at the work point ----------"TI CD4013B"(S1=GND, R1=RST, D1=NCP0, CL1=QCO, Q1=CP0, QN1=NCP0, S2=GND, R2=RST, D2=NCP1, CL2=NCP0, Q2=CP1, QN2=NCP1)# ---------- the BUSY LED ----------led{color=yellow}(BUSYH)# ---------- pens: red, green, blue ----------mpen k1{color=red}(DOWN=DOWN1)mount(k1, tt.d3)mpen k2{color=green}(DOWN=DOWN2)mount(k2, tt.d2)mpen k3{color=blue}(DOWN=DOWN3)mount(k3, tt.d1)

Stuck? Something doesn't work →