Lesson 1. The plotter and the panel
In picturesAfter 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.
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, RIGHT | X axis STEP | X axis DIR |
|---|---|---|
| both up | 0 — stands | does not matter |
| RIGHT | CKL clock | 1 — right |
| LEFT | CKL clock | 0 — 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 before | D = QN | Q after the press |
|---|---|---|
| 0 (up) | 1 | 1 (down) |
| 1 (down) | 0 | 0 (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.
| Part | Pin / action | Label / where |
|---|---|---|
| Linear axis — X axis | length (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 axis | length (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 — black | colour (Alt/⌘+click) DOWN mount | black LPEN on d0 (hole d0 of the table) |
| Paper | size (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.
| Part | Pin / action | Label / where |
|---|---|---|
| Clock 60Hz | output | CKL |
| Button «LEFT» | output | LEFT |
| Button «RIGHT» | output | RIGHT |
| Button «UP» | output | UP |
| Button «DOWN» | output | DOWN |
| Button «PEN UP/DOWN» | output | PENB |
Step 4. Chips
| Part | Pin / action | Label / where |
|---|---|---|
| TI CD4071B | A B J C D K E F L G H | LEFT RIGHT LR UP DOWN UD XSTALL YSTALL ERROR GND GND |
| TI CD4081B | A B C D E F L G H M | GND GND GND GND CKL LR LXS CKL UD LYS |
| TI CD4013B | S1 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.
| Part | Pin / action | Label / where |
|---|---|---|
| LED, green | input | VCC |
| LED, red | input | ERROR |
1.6. Check
- Turbo mode, switch the power on. The machine boots as usual; the plotter works next to it. The green
POWERis lit. - Hold RIGHT — the X carriage moves right, 60 steps a second; LEFT — back. DOWN and UP — the Y carriage.
- PEN UP/DOWN — the pen goes down; steer it over the paper with the arrows — it draws black. Once more — it goes up.
- Drive a carriage to the end stop and keep holding the arrow — the red
ERRORis lit: the motor steps but the carriage stands. The LED stays on until you move away with the other arrow.
| Pressed | Plotter |
|---|---|
| RIGHT / LEFT | X carriage right / left, 60 steps/s |
| DOWN / UP | Y carriage down / up |
| PEN UP/DOWN | the pen goes down / up |
| arrow at the end | ERROR 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)Stuck? Something doesn't work →