Lesson 1. The plotter and the panel

In pictures

After this lesson a plotter stands next to the Apple ][: two axes with stepper motors, a head with a black pen and a sheet of paper. No computer yet — the plotter is driven by a panel, like a real one: the arrows move the pen, the PEN UP/DOWN button lowers and lifts it, the red ERROR lamp is lit when a carriage hits the end.


1.1. Idea: two axes — any point of the sheet

A plotter’s pen moves along two axes. The X axis lies along the sheet, the Y axis rides across it on the X carriage. The Y carriage carries the head with the pen. Move X by 120 steps and Y by 60 — the pen is at (120, 60). All plotters and CNC machines draw this way.

Each axis is driven by a stepper motor. An axis has two input pins and three output pins:

  • STEP — a step: on a change from 0 to 1 (a rising edge) the carriage moves exactly one step;
  • DIR — where: 1 — away from the motor (right, down), 0 — towards the motor;
  • L0 — the carriage is at the motor, L1 — at the far end (limit switches);
  • STALL — the step failed: the carriage is stuck.
X axis →Y axis ↓ (on the X carriage)L0L1CKLRIGHTLXSLXS = CKL AND (LEFT OR RIGHT)DIR = RIGHT: right — 1, left — 0each rising edge — one carriage step
Left — the plotter from above: the X axis along the sheet, the Y axis on its carriage, the head with the pen on the Y carriage. Right — the steps: the 60 Hz clock reaches the X motor only while you hold the arrow.

1.2. Idea: an arrow means steps from a clock

The motor steps only on an edge. While you hold an arrow, you need edges one after another — the 60 Hz clock (CKL) gives them: 60 steps a second. What we want for the X axis:

LEFT, RIGHTX axis STEPX axis DIR
both up0 — standsdoes not matter
RIGHTCKL clock1 — right
LEFTCKL clock0 — left

Hence the formulas:

  • «an X arrow is pressed»: LR = LEFT OR RIGHT — an OR gate (CD4071);
  • steps: LXS = CKL AND LR — an AND gate (CD4081): the clock passes only while an arrow is held;
  • direction: DIR = RIGHT — no gate needed: RIGHT pressed — 1, LEFT pressed — 0.

The same for Y: UD = UP OR DOWN, LYS = CKL AND UD, DIR = DOWN.

1.3. Idea: PEN UP/DOWN — one button, two positions

A button gives 1 only while you hold it, but the pen has to remember: down or up. A flip-flop remembers. A CD4013 D flip-flop copies D to its output Q on a rising edge at CL. Feed its own inverted output QN into D:

Q beforeD = QNQ after the press
0 (up)11 (down)
1 (down)00 (up)

Every press flips Q — a toggle flip-flop (T flip-flop). Its output LPEN is the pen’s DOWN pin. R1 = RST: when the machine resets, the pen goes up.

1.4. Idea: ERROR

A carriage reached the end of the rail but the arrow is still held — the motor steps, the carriage stands, the axis gives STALL = 1. The ERROR lamp should be lit if either axis is stuck: ERROR = XSTALL OR YSTALL — one more OR gate of the same CD4071.

1.5. Build

Open the Apple ][ machine (the DEMO button) — the plotter goes next to it, on the same canvas: in lesson 3 it connects to the machine through a card. Power (VCC, GND) and reset RST are already there in the machine. A label on a pin — double-click the pin and type the name.

Step 1. Chips into the library

If the library has no Plotter folder yet: the import button in the library → the kit file plotter-chips.json. A folder with the chips for the whole kit appears (TI CD4013B, TI CD4017B, TI CD4019B, TI CD4069UB, TI CD4070B, TI CD4071B, TI CD4072B, TI CD4081B).

Step 2. Mechanics

Parts come from the Mechanics button. Put the X axis to the right of the machine. Turn the Y axis by 90° and drag it by its orange nut to the X axis carriage — it snaps on. The Turntable goes the same way onto the Y axis carriage, the pen into hole d0 of the table. Move the paper so that the pen stands at its top-left corner.

PartPin / actionLabel / where
Linear axis — X axislength (handle)
STEP
DIR
L0
L1
STALL
place
400
LXS
RIGHT
XL0
XL1
XSTALL
the black pen at the top-left corner of the paper, 30 points from the edges
Linear axis — Y axislength (handle)
rotation
STEP
DIR
L0
L1
STALL
mount
300
90° — the carriage moves down
LYS
DOWN
YL0
YL1
YSTALL
on car (carriage of the X axis)
Turntable — the head—
mount
pins — in lesson 2
on car (carriage of the Y axis)
Pen — blackcolour (Alt/⌘+click)
DOWN
mount
black
LPEN
on d0 (hole d0 of the table)
Papersize (corner handle)
place
460 × 360
to the right of the machine, where there is room

Step 3. The panel

Clock — click its body until it shows 60Hz. The caption on a button — double-click it.

PartPin / actionLabel / where
Clock 60HzoutputCKL
Button «LEFT»outputLEFT
Button «RIGHT»outputRIGHT
Button «UP»outputUP
Button «DOWN»outputDOWN
Button «PEN UP/DOWN»outputPENB

Step 4. Chips

PartPin / actionLabel / where
TI CD4071BA
B
J
C
D
K
E
F
L
G
H
LEFT
RIGHT
LR
UP
DOWN
UD
XSTALL
YSTALL
ERROR
GND
GND
TI CD4081BA
B
C
D
E
F
L
G
H
M
GND
GND
GND
GND
CKL
LR
LXS
CKL
UD
LYS
TI CD4013BS1
R1
D1
CL1
Q1
QN1
S2
R2
D2
CL2
GND
RST
NLPEN
PENB
LPEN
NLPEN
GND
GND
GND
GND

Leave unconnected: M on the CD4071B; J, K on the CD4081B; Q2, QN2 on the CD4013B.

Step 5. LEDs

The LED colour — Alt/⌘+click it.

PartPin / actionLabel / where
LED, greeninputVCC
LED, redinputERROR

1.6. Check

  1. Turbo mode, switch the power on. The machine boots as usual; the plotter works next to it. The green POWER is lit.
  2. Hold RIGHT — the X carriage moves right, 60 steps a second; LEFT — back. DOWN and UP — the Y carriage.
  3. PEN UP/DOWN — the pen goes down; steer it over the paper with the arrows — it draws black. Once more — it goes up.
  4. Drive a carriage to the end stop and keep holding the arrow — the red ERROR is lit: the motor steps but the carriage stands. The LED stays on until you move away with the other arrow.
PressedPlotter
RIGHT / LEFTX carriage right / left, 60 steps/s
DOWN / UPY carriage down / up
PEN UP/DOWNthe pen goes down / up
arrow at the endERROR is lit

Lesson 1 paste (Cmd+I)

Paste into the Apple ][ machine (the DEMO button). It places everything: the mechanics, the paper, the panel, the chips and the LEDs.

# Lesson 1 - the plotter and the panel: X and Y axes, the head with the black pen, arrows and PEN UP/DOWN (no computer).# Paste: Cmd+I into the Apple ][ machine (the DEMO button). Power VCC/GND and reset RST are the machine's.# ---------- 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 ttmount(tt, ay.car)mpen k0{color=black}(DOWN=LPEN)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=GND, H=GND)# ---------- 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=GND, D2=GND, CL2=GND)# ---------- POWER and ERROR LEDs ----------led{color=green}(VCC)led{color=red}(ERROR)

¿No te sale? Algo no funciona →