Lesson 3. The raster scan: the screen dot by dot
In picturesAfter this lesson the circuit draws on a 64 × 64 screen by itself — dot by dot, row by row, like the beam of an old TV. What to draw is decided by a little logic of the coordinates: today it is stripes and a chessboard.
3.1. The idea: the beam runs along the rows
A 64 × 64 screen is 4096 dots. The circuit visits them all in order:
- the column counter
Xcounts 0…63 on every clock; - when it reaches 63, its carry
COallows one step of the row counterY; - on every clock the screen gets the address
(x, y)and the bitD0— whether this dot is lit.
That is how the real arcade machines of the 1970s drew — Pong, Breakout, Space Race: they had no processor, only raster counters and logic for "what is under the beam right now".
When to write. The counters switch on the clock rising edge, the screen writes on the falling edge (CLK through NOT) — by then the address has settled.
3.2. Building
The same project. Delete the lesson 2 setup (clock, switches, CNT6 on the canvas, lamps, display); keep Power/Ground. The CNT6 chip stays in the library.
The idea. A 64 × 64 screen is 4096 dots. To draw a picture the circuit visits them all in order, like the beam of a TV: the column counter X counts 0…63 on every clock, and when it reaches 63 its carry CO allows one step of the row counter Y. On every clock the screen gets the address (x, y) and the bit D0 — whether this dot is lit.
The dot bit is any logic of x and y. In this lesson it is simple patterns, in the next one a fractal.
When to write. The counters switch on the clock rising edge. The screen writes on the falling edge (CLK through NOT) — by then the address has settled.
Step 1. The screen
Place a Dot display and set it up in ⚙:
| Screen setting (⚙) | Value |
|---|---|
| Layout | Dots |
| Height, dots | 64 |
| Width, dots | 64 |
| Port width | 1 dot |
Step 2. Canvas: clock, two counters, pattern, screen
| Part | Pin | Label |
|---|---|---|
| Clock | out | CLK |
| Input | out | RST |
| NOT | I0 O0 | CLK nCLK |
| CNT6 (column X) | CLK EN RST Q0 Q1 Q2 Q3 Q4 Q5 CO | CLK VCC RST x0 x1 x2 x3 x4 x5 cx |
| CNT6 (row Y) | CLK EN RST Q0 Q1 Q2 Q3 Q4 Q5 CO | CLK cx RST y0 y1 y2 y3 y4 y5 cy |
| XOR (pattern) | I0 I1 O0 | x3 y3 pix |
| Dot display | X0 X1 X2 X3 X4 X5 Y0 Y1 Y2 Y3 Y4 Y5 D0 WE CLK CLR | x0 x1 x2 x3 x4 x5 y0 y1 y2 y3 y4 y5 pix VCC nCLK GND |
The Clock at 60Hz: a frame takes over a minute, but you can see the scan running. Then switch to a fast one.
Try the patterns
Feed different labels into the screen D0 — double-click the label at the D0 pin, new name:
| On the screen D0 | On the screen |
|---|---|
| VCC | the whole screen lights up — filled dot by dot |
| x0 | vertical stripes every other dot |
| x3 | vertical stripes 8 wide |
| y3 | horizontal stripes 8 wide |
| pix = XOR(x3, y3) | a chessboard of 8 × 8 squares |
Bit 3 of a coordinate changes every 8 dots — hence stripes 8 wide. XOR of two such stripes gives a chessboard.
3.3. Check
| № | What to do | What you see |
|---|---|---|
| 1 | RST = 1, wait one clock, RST = 0 | the scan starts at dot (0, 0) — top left |
| 2 | clock at 60Hz | the screen fills row by row, a frame ≈ 70 seconds |
| 3 | click the clock body — 4kHz or faster | a frame takes a second or two |
| 4 | move the screen D0 to VCC, x0, x3, y3 in turn | the patterns from the table above |
| 5 | put D0 back on pix | a chessboard |
If the pattern is shifted or "crawls", check that the screen CLK is on nCLK, not CLK. If only one row is drawn, check the row counter EN: it must be on cx.
Lesson 3 paste (Cmd+I)
Needs CNT6, NOT, XOR. Delete the lesson 2 setup, keep the power. The paste places the Dot display already set up.
# Lesson 3 — the raster scan: X and Y counters write every dot of the 64 x 64 screen.clock{rt=60}(CLK)input(RST)NOT(CLK, nCLK)CNT6(CLK=CLK, EN=VCC, RST=RST, Q0=x0, Q1=x1, Q2=x2, Q3=x3, Q4=x4, Q5=x5, CO=cx)CNT6(CLK=CLK, EN=cx, RST=RST, Q0=y0, Q1=y1, Q2=y2, Q3=y3, Q4=y4, Q5=y5, CO=cy)XOR(x3, y3, pix)dotdisplay SCR{layout=dots, w=64, h=64}(X0=x0, X1=x1, X2=x2, X3=x3, X4=x4, X5=x5, Y0=y0, Y1=y1, Y2=y2, Y3=y3, Y4=y4, Y5=y5, D0=pix, WE=VCC, CLK=nCLK, CLR=GND)¿No te sale? Algo no funciona →