Lesson 1. The screen and car A: a lift that goes by its buttons

In pictures

After this lesson the house has one car: you press buttons on its panel — it moves, opens its doors at the right floors, rings a chime and decides by itself where to go next: first all the floors in one direction, then it turns around. The screen shows where the car is, whether its doors are open, which buttons are pressed and where it is going.


1.1. The idea: the car is a machine with memory

The car remembers four things:

  • where it is — the position, 5 bits: the floor (3 bits) and the step between floors (2 bits);
  • where it goes — the direction, 1 bit;
  • whether the doors are open — a timer, 3 bits;
  • which buttons are pressed — 8 latches.

Once a cycle (Clock 2Hz, half a second) the machine looks at all of this and decides: stand, open the doors, go up or down. The car passes a floor in 4 cycles — 2 seconds, and keeps its doors open for 2 seconds too.

positionp4…p0 · 5 bitsdirectiondir · 1 bitdoor timert2…t0 · 3 bitsbuttonsAK0…AK7 · 8 latchesdecisionstay · doors · up · downnew stateon the CLK edgeagain every cycle; the buttons are set by a finger, not by the clock
The car is a machine with memory. Once a cycle it looks at where the car is, where it goes, whether the doors are open and which buttons are pressed, decides what to do and on the CLK edge stores the new position, direction and timer. The buttons are latches: a press sets them at once, open doors clear them.
801000fl. 3901001100101011010111201100fl. 41301101140111015011111610000fl. 51710001181001019100112010100fl. 6positionp4 p3 p2p1 p0p4 p3 p2 — the floor (+1 on the screen), p1 p0 — the step between floorsatF = NOR(p0, p1) = 1 only when the step is 00 — the car is exactly at a floor
The position is one 5-bit number: floor × 4 + step. The top three bits are the floor, the bottom two are how many cycles the car has travelled from it. The counter adds 1 going up or subtracts 1 going down; a floor takes 4 cycles.
stopped, doors closedgoing up to the 5that the 5th, doors open
Shaft A on the screen: a frame with door leaves — the car stands with its doors closed; a bar — the car is moving; an empty frame — the doors are open. The dot on the right is a pressed button in the car, the digit is the floor, the arrow is the direction.

1.2. The idea: one way while there is somewhere to go

The rule of real lifts: keep going one way and stop at every pressed floor on the way; you may turn around only when no pressed buttons are left ahead. For that the car needs two facts:

  • UPR — a pressed button above the car;
  • DNR — a pressed button below.

"Above" and "below" come from OR chains — a thermometer: for a car at the 4th floor "above" is 5, 6, 7, 8 and "below" is 1, 2, 3. The decision at a floor:

  • up: UPR AND (going up OR NOT DNR);
  • down: DNR AND (going down OR NOT UPR).
floorya: car belowb: car abovebutton80107010●60105010410030012001●1001UPR = 17 is above the carDNR = 12 is below the car
The thermometer. The car is at the 4th: y3 is lit. One OR chain lights a — "the car is below this floor" — at the 5th–8th, the other lights b, "the car is above this floor", at the 1st–3rd. UP = OR(button AND a), DOWN = OR(button AND b): 7 and 2 are pressed — there is work both above and below.
goingabovebelowdecisionup1—on upup01turn downdown—1on downdown10turn upany00stand, "down"
The decision at a floor when the doors are closed and there is nothing to do here. The main rule of lifts: keep going one way while there is work there, and only then turn around. No work at all — the car stands idle.

1.3. The idea: a button is a latch, not a flip-flop

A button is pressed for a fraction of a second, and a cycle is half a second: a flip-flop that stores only on the edge would miss the press. So the button sets a latch at once. Three things clear it: the doors opened at this floor, the Cancel button (it clears all the car buttons at once) and reset. Pressed the wrong floor — Cancel, then the right one.

CLKbuttonflip-floplatchmissedkept
A button is pressed for a fraction of a second — between CLK edges. A flip-flop looks at its input only at the edge and would miss the press. The SRLatch is set at once and holds 1 until it is cleared: the doors open at this floor, Cancel, or reset.
heret043210OPENthe doors are open for 4 cycles — 2 seconds
The door timer: on the "here" cycle it gets 4, then it goes down by 1 every cycle (three FAs add 111). While it is not 0 the doors are open (OPEN = OR of its three bits), the car stands and the button of this floor goes out.

1.4. Building

A new project. You need the gates NOT, NAND, NOR, AND, OR, XOR: already in the library from another kit of the series — take them; want to build from scratch — lesson 0; straight to the point — paste lesson 0 (Cmd+I).

Step 1. Chip SRLatch — latch: S stores 1, R stores 0

If SRLatch is already in the library (from another kit of the series), skip this step.

PartLegLabel
Input portoutputR
Input portoutputS
Output portinputQ
Output portinputnQ
NORI0
I1
O0
R
nQ
Q
NORI0
I1
O0
S
Q
nQ

Ctrl+G → name SRLatch. Legs: inputs R, S; outputs Q, nQ.

Step 2. Chip DLatch — data latch

If DLatch is already in the library (from another kit of the series), skip this step.

PartLegLabel
Input portoutputD
Input portoutputEN
Output portinputQ
Output portinputnQ
NOTI0
O0
D
nD
ANDI0
I1
O0
D
EN
setD
ANDI0
I1
O0
nD
EN
rstD
SRLatchS
R
Q
nQ
setD
rstD
Q
nQ

Ctrl+G → name DLatch. Legs: inputs D, EN; outputs Q, nQ.

Step 3. Chip DFF — flip-flop: stores D on the CLK edge

If DFF is already in the library (from another kit of the series), skip this step.

PartLegLabel
Input portoutputD
Input portoutputCLK
Output portinputQ
Output portinputnQ
NOTI0
O0
CLK
nCLK
DLatchD
EN
Q
D
nCLK
mid
DLatchD
EN
Q
nQ
mid
CLK
Q
nQ

Ctrl+G → name DFF. Legs: inputs D, CLK; outputs Q, nQ.

Step 4. Chip FA — full adder

If FA is already in the library (from another kit of the series), skip this step.

PartLegLabel
Input portoutputA
Input portoutputB
Input portoutputCI
Output portinputS
Output portinputCO
XORI0
I1
O0
A
B
p
XORI0
I1
O0
p
CI
S
ANDI0
I1
O0
A
B
g
ANDI0
I1
O0
p
CI
pc
ORI0
I1
O0
g
pc
CO

Ctrl+G → name FA. Legs: inputs A, B, CI; outputs S, CO.

Step 5. Chip MUX2 — one of two

If MUX2 is already in the library (from another kit of the series), skip this step.

PartLegLabel
Input portoutputA
Input portoutputB
Input portoutputS
Output portinputY
NOTI0
O0
S
nS
NANDI0
I1
O0
A
nS
na
NANDI0
I1
O0
B
S
nb
NANDI0
I1
O0
na
nb
Y

Ctrl+G → name MUX2. Legs: inputs A, B, S; outputs Y.

Step 6. Chip AND3 — AND with 3 inputs

If AND3 is already in the library (from another kit of the series), skip this step.

PartLegLabel
Input portoutputA
Input portoutputB
Input portoutputC
Output portinputY
ANDI0
I1
O0
A
B
ab
ANDI0
I1
O0
ab
C
Y

Ctrl+G → name AND3. Legs: inputs A, B, C; outputs Y.

Step 7. Chip OR3 — OR with 3 inputs

If OR3 is already in the library (from another kit of the series), skip this step.

PartLegLabel
Input portoutputA
Input portoutputB
Input portoutputC
Output portinputY
ORI0
I1
O0
A
B
ab
ORI0
I1
O0
ab
C
Y

Ctrl+G → name OR3. Legs: inputs A, B, C; outputs Y.

Step 8. Chip OR4 — OR with 4 inputs

If OR4 is already in the library (from another kit of the series), skip this step.

PartLegLabel
Input portoutputA
Input portoutputB
Input portoutputC
Input portoutputD
Output portinputY
ORI0
I1
O0
A
B
ab
ORI0
I1
O0
C
D
cd
ORI0
I1
O0
ab
cd
Y

Ctrl+G → name OR4. Legs: inputs A, B, C, D; outputs Y.

Step 9. Chip OR8 — OR with 8 inputs

If OR8 is already in the library (from another kit of the series), skip this step.

PartLegLabel
Input portoutputA
Input portoutputB
Input portoutputC
Input portoutputD
Input portoutputE
Input portoutputF
Input portoutputG
Input portoutputH
Output portinputY
OR4A
B
C
D
Y
A
B
C
D
lo
OR4A
B
C
D
Y
E
F
G
H
hi
ORI0
I1
O0
lo
hi
Y

Ctrl+G → name OR8. Legs: inputs A, B, C, D, E, F, G, H; outputs Y.

Step 10. Chip DEC8 — decoder 3 → 8: exactly one of eight wires is lit

If DEC8 is already in the library (from another kit of the series), skip this step.

PartLegLabel
Input portoutputI0
Input portoutputI1
Input portoutputI2
Output portinputY0
Output portinputY1
Output portinputY2
Output portinputY3
Output portinputY4
Output portinputY5
Output portinputY6
Output portinputY7
NOTI0
O0
I0
n0
NOTI0
O0
I1
n1
NOTI0
O0
I2
n2
AND3A
B
C
Y
n2
n1
n0
Y0
AND3A
B
C
Y
n2
n1
I0
Y1
AND3A
B
C
Y
n2
I1
n0
Y2
AND3A
B
C
Y
n2
I1
I0
Y3
AND3A
B
C
Y
I2
n1
n0
Y4
AND3A
B
C
Y
I2
n1
I0
Y5
AND3A
B
C
Y
I2
I1
n0
Y6
AND3A
B
C
Y
I2
I1
I0
Y7

Ctrl+G → name DEC8. Legs: inputs I0, I1, I2; outputs Y0, Y1, Y2, Y3, Y4, Y5, Y6, Y7.

Step 11. The screen: the picture and 152 legs

Segment LCD from the palette, ⚙ → ⬆ → project/lift/screen/lift-screen.png (88 × 130 dots). Turn on Ghost. Marking: S, click a blob (the wand), Enter, the name, Enter — a leg appears on the body, a label with its name next to it. Each segment is one blob, one click. The shaft letters, floor numbers and walls are the background — do not mark them.

Mark the whole screen at once, all three shafts: the legs of shafts B and C, the ▶ and the call squares are not connected yet and stay dark — their wires come in lessons 2–4. Digit segments: a is the top, then clockwise, g is the middle.

On the screenLeg name
shaft A, floor 1 — car frameAC0
shaft A, floor 2 — car frameAC1
shaft A, floor 3 — car frameAC2
shaft A, floor 4 — car frameAC3
shaft A, floor 5 — car frameAC4
shaft A, floor 6 — car frameAC5
shaft A, floor 7 — car frameAC6
shaft A, floor 8 — car frameAC7
shaft A, floor 1 — door leaves (inside the frame)AD0
shaft A, floor 2 — door leaves (inside the frame)AD1
shaft A, floor 3 — door leaves (inside the frame)AD2
shaft A, floor 4 — door leaves (inside the frame)AD3
shaft A, floor 5 — door leaves (inside the frame)AD4
shaft A, floor 6 — door leaves (inside the frame)AD5
shaft A, floor 7 — door leaves (inside the frame)AD6
shaft A, floor 8 — door leaves (inside the frame)AD7
shaft A, bar between floors 1 and 2AM0
shaft A, bar between floors 2 and 3AM1
shaft A, bar between floors 3 and 4AM2
shaft A, bar between floors 4 and 5AM3
shaft A, bar between floors 5 and 6AM4
shaft A, bar between floors 6 and 7AM5
shaft A, bar between floors 7 and 8AM6
shaft A, floor 1 — dot on the right (car button)AK0
shaft A, floor 2 — dot on the right (car button)AK1
shaft A, floor 3 — dot on the right (car button)AK2
shaft A, floor 4 — dot on the right (car button)AK3
shaft A, floor 5 — dot on the right (car button)AK4
shaft A, floor 6 — dot on the right (car button)AK5
shaft A, floor 7 — dot on the right (car button)AK6
shaft A, floor 8 — dot on the right (car button)AK7
shaft A, floor 1 — ▶ on the left (call assigned)AG0
shaft A, floor 2 — ▶ on the left (call assigned)AG1
shaft A, floor 3 — ▶ on the left (call assigned)AG2
shaft A, floor 4 — ▶ on the left (call assigned)AG3
shaft A, floor 5 — ▶ on the left (call assigned)AG4
shaft A, floor 6 — ▶ on the left (call assigned)AG5
shaft A, floor 7 — ▶ on the left (call assigned)AG6
shaft A, floor 8 — ▶ on the left (call assigned)AG7
shaft A, digit above the shaft — segment aAFa
shaft A, digit above the shaft — segment bAFb
shaft A, digit above the shaft — segment cAFc
shaft A, digit above the shaft — segment dAFd
shaft A, digit above the shaft — segment eAFe
shaft A, digit above the shaft — segment fAFf
shaft A, digit above the shaft — segment gAFg
shaft A, arrow ▲AUP
shaft A, arrow ▼ADN
shaft B, floor 1 — car frameBC0
shaft B, floor 2 — car frameBC1
shaft B, floor 3 — car frameBC2
shaft B, floor 4 — car frameBC3
shaft B, floor 5 — car frameBC4
shaft B, floor 6 — car frameBC5
shaft B, floor 7 — car frameBC6
shaft B, floor 8 — car frameBC7
shaft B, floor 1 — door leaves (inside the frame)BD0
shaft B, floor 2 — door leaves (inside the frame)BD1
shaft B, floor 3 — door leaves (inside the frame)BD2
shaft B, floor 4 — door leaves (inside the frame)BD3
shaft B, floor 5 — door leaves (inside the frame)BD4
shaft B, floor 6 — door leaves (inside the frame)BD5
shaft B, floor 7 — door leaves (inside the frame)BD6
shaft B, floor 8 — door leaves (inside the frame)BD7
shaft B, bar between floors 1 and 2BM0
shaft B, bar between floors 2 and 3BM1
shaft B, bar between floors 3 and 4BM2
shaft B, bar between floors 4 and 5BM3
shaft B, bar between floors 5 and 6BM4
shaft B, bar between floors 6 and 7BM5
shaft B, bar between floors 7 and 8BM6
shaft B, floor 1 — dot on the right (car button)BK0
shaft B, floor 2 — dot on the right (car button)BK1
shaft B, floor 3 — dot on the right (car button)BK2
shaft B, floor 4 — dot on the right (car button)BK3
shaft B, floor 5 — dot on the right (car button)BK4
shaft B, floor 6 — dot on the right (car button)BK5
shaft B, floor 7 — dot on the right (car button)BK6
shaft B, floor 8 — dot on the right (car button)BK7
shaft B, floor 1 — ▶ on the left (call assigned)BG0
shaft B, floor 2 — ▶ on the left (call assigned)BG1
shaft B, floor 3 — ▶ on the left (call assigned)BG2
shaft B, floor 4 — ▶ on the left (call assigned)BG3
shaft B, floor 5 — ▶ on the left (call assigned)BG4
shaft B, floor 6 — ▶ on the left (call assigned)BG5
shaft B, floor 7 — ▶ on the left (call assigned)BG6
shaft B, floor 8 — ▶ on the left (call assigned)BG7
shaft B, digit above the shaft — segment aBFa
shaft B, digit above the shaft — segment bBFb
shaft B, digit above the shaft — segment cBFc
shaft B, digit above the shaft — segment dBFd
shaft B, digit above the shaft — segment eBFe
shaft B, digit above the shaft — segment fBFf
shaft B, digit above the shaft — segment gBFg
shaft B, arrow ▲BUP
shaft B, arrow ▼BDN
shaft C, floor 1 — car frameCC0
shaft C, floor 2 — car frameCC1
shaft C, floor 3 — car frameCC2
shaft C, floor 4 — car frameCC3
shaft C, floor 5 — car frameCC4
shaft C, floor 6 — car frameCC5
shaft C, floor 7 — car frameCC6
shaft C, floor 8 — car frameCC7
shaft C, floor 1 — door leaves (inside the frame)CD0
shaft C, floor 2 — door leaves (inside the frame)CD1
shaft C, floor 3 — door leaves (inside the frame)CD2
shaft C, floor 4 — door leaves (inside the frame)CD3
shaft C, floor 5 — door leaves (inside the frame)CD4
shaft C, floor 6 — door leaves (inside the frame)CD5
shaft C, floor 7 — door leaves (inside the frame)CD6
shaft C, floor 8 — door leaves (inside the frame)CD7
shaft C, bar between floors 1 and 2CM0
shaft C, bar between floors 2 and 3CM1
shaft C, bar between floors 3 and 4CM2
shaft C, bar between floors 4 and 5CM3
shaft C, bar between floors 5 and 6CM4
shaft C, bar between floors 6 and 7CM5
shaft C, bar between floors 7 and 8CM6
shaft C, floor 1 — dot on the right (car button)CK0
shaft C, floor 2 — dot on the right (car button)CK1
shaft C, floor 3 — dot on the right (car button)CK2
shaft C, floor 4 — dot on the right (car button)CK3
shaft C, floor 5 — dot on the right (car button)CK4
shaft C, floor 6 — dot on the right (car button)CK5
shaft C, floor 7 — dot on the right (car button)CK6
shaft C, floor 8 — dot on the right (car button)CK7
shaft C, floor 1 — ▶ on the left (call assigned)CG0
shaft C, floor 2 — ▶ on the left (call assigned)CG1
shaft C, floor 3 — ▶ on the left (call assigned)CG2
shaft C, floor 4 — ▶ on the left (call assigned)CG3
shaft C, floor 5 — ▶ on the left (call assigned)CG4
shaft C, floor 6 — ▶ on the left (call assigned)CG5
shaft C, floor 7 — ▶ on the left (call assigned)CG6
shaft C, floor 8 — ▶ on the left (call assigned)CG7
shaft C, digit above the shaft — segment aCFa
shaft C, digit above the shaft — segment bCFb
shaft C, digit above the shaft — segment cCFc
shaft C, digit above the shaft — segment dCFd
shaft C, digit above the shaft — segment eCFe
shaft C, digit above the shaft — segment fCFf
shaft C, digit above the shaft — segment gCFg
shaft C, arrow ▲CUP
shaft C, arrow ▼CDN
floor 1 — square at the number (floor call)H0
floor 2 — square at the number (floor call)H1
floor 3 — square at the number (floor call)H2
floor 4 — square at the number (floor call)H3
floor 5 — square at the number (floor call)H4
floor 6 — square at the number (floor call)H5
floor 7 — square at the number (floor call)H6
floor 8 — square at the number (floor call)H7

Step 12. Power, clock, reset

Clock — click the body up to 2Hz: a cycle is half a second, the car passes a floor in 4 cycles (2 seconds) and keeps the doors open for 4 cycles. RST is the reset switch; nR is its inverse, it stands in front of every flip-flop.

PartLegLabel
PoweroutputVCC
GroundoutputGND
ClockoutputCLK
Input (switch)outputRST
NOTI0
O0
RST
nR

Step 13. Car A panel

Eight floor buttons and Cancel. Put them in a column to the right of the screen, «8» on top: this is the panel inside car A. Press them with the mouse.

PartLegLabel
Button «1»outputAB0
Button «2»outputAB1
Button «3»outputAB2
Button «4»outputAB3
Button «5»outputAB4
Button «6»outputAB5
Button «7»outputAB6
Button «8»outputAB7
Button «Cancel»outputACAN

Step 14. Where the car is

The position is 5 bits: p4 p3 p2 is the floor (0–7, on the screen 1–8), p1 p0 is the step between floors. atF = 1 when the step is 0: the car stands exactly at a floor. DEC8 lights one wire y0–y7 — the floor of the car.

PartLegLabel
NORI0
I1
O0
p0
p1
atF
NOTI0
O0
atF
natF
DEC8I0
I1
I2
Y0
Y1
Y2
Y3
Y4
Y5
Y6
Y7
p2
p3
p4
y0
y1
y2
y3
y4
y5
y6
y7

Step 15. Doors open

The door timer t2 t1 t0 (step «Door timer»): while it is not 0, the doors are open (OPEN).

PartLegLabel
OR3A
B
C
Y
t0
t1
t2
OPEN
NOTI0
O0
OPEN
ndoor

Step 16. Car at a floor

AC<f> — the car stands at floor f: this is also the frame on the screen. O<f> — the doors are open at floor f: it clears the button of this floor.

PartLegLabel
ANDI0
I1
O0
y0
atF
AC0
ANDI0
I1
O0
AC0
OPEN
O0
ANDI0
I1
O0
y1
atF
AC1
ANDI0
I1
O0
AC1
OPEN
O1
ANDI0
I1
O0
y2
atF
AC2
ANDI0
I1
O0
AC2
OPEN
O2
ANDI0
I1
O0
y3
atF
AC3
ANDI0
I1
O0
AC3
OPEN
O3
ANDI0
I1
O0
y4
atF
AC4
ANDI0
I1
O0
AC4
OPEN
O4
ANDI0
I1
O0
y5
atF
AC5
ANDI0
I1
O0
AC5
OPEN
O5
ANDI0
I1
O0
y6
atF
AC6
ANDI0
I1
O0
AC6
OPEN
O6
ANDI0
I1
O0
y7
atF
AC7
ANDI0
I1
O0
AC7
OPEN
O7

Step 17. Car buttons — latches

A button is pressed for a fraction of a second, and a cycle is half a second: a flip-flop would miss the press. So the button sets a latch SRLatch at once. kr<f> clears the latch: the doors are open at this floor, or Cancel (kc — it clears all eight), or reset. While it is being cleared, a press does not get through: a latch must not get S and R together. The AK<f> output is the dot to the right of the shaft.

PartLegLabel
ORI0
I1
O0
ACAN
RST
kc
ORI0
I1
O0
O0
kc
kr0
NOTI0
O0
kr0
nkr0
ANDI0
I1
O0
AB0
nkr0
ks0
SRLatchS
R
Q
ks0
kr0
AK0
ORI0
I1
O0
O1
kc
kr1
NOTI0
O0
kr1
nkr1
ANDI0
I1
O0
AB1
nkr1
ks1
SRLatchS
R
Q
ks1
kr1
AK1
ORI0
I1
O0
O2
kc
kr2
NOTI0
O0
kr2
nkr2
ANDI0
I1
O0
AB2
nkr2
ks2
SRLatchS
R
Q
ks2
kr2
AK2
ORI0
I1
O0
O3
kc
kr3
NOTI0
O0
kr3
nkr3
ANDI0
I1
O0
AB3
nkr3
ks3
SRLatchS
R
Q
ks3
kr3
AK3
ORI0
I1
O0
O4
kc
kr4
NOTI0
O0
kr4
nkr4
ANDI0
I1
O0
AB4
nkr4
ks4
SRLatchS
R
Q
ks4
kr4
AK4
ORI0
I1
O0
O5
kc
kr5
NOTI0
O0
kr5
nkr5
ANDI0
I1
O0
AB5
nkr5
ks5
SRLatchS
R
Q
ks5
kr5
AK5
ORI0
I1
O0
O6
kc
kr6
NOTI0
O0
kr6
nkr6
ANDI0
I1
O0
AB6
nkr6
ks6
SRLatchS
R
Q
ks6
kr6
AK6
ORI0
I1
O0
O7
kc
kr7
NOTI0
O0
kr7
nkr7
ANDI0
I1
O0
AB7
nkr7
ks7
SRLatchS
R
Q
ks7
kr7
AK7

Step 18. The thermometer: what is below, what is above

a<f> = 1 if the car is below floor f; b<f> = 1 if it is above. These are OR chains from the lit y: for a car at the 4th floor a5, a6, a7 and b0…b2 are lit. For the 1st and 8th floor y0 and y7 themselves are enough.

PartLegLabel
ORI0
I1
O0
y0
y1
a2
ORI0
I1
O0
a2
y2
a3
ORI0
I1
O0
a3
y3
a4
ORI0
I1
O0
a4
y4
a5
ORI0
I1
O0
a5
y5
a6
ORI0
I1
O0
a6
y6
a7
ORI0
I1
O0
y7
y6
b5
ORI0
I1
O0
b5
y5
b4
ORI0
I1
O0
b4
y4
b3
ORI0
I1
O0
b3
y3
b2
ORI0
I1
O0
b2
y2
b1
ORI0
I1
O0
b1
y1
b0

Step 19. Work above? Below?

UPR — a pressed button above the car: the OR of «button f AND the car is below f». DNR — the same downwards.

PartLegLabel
ANDI0
I1
O0
AK1
y0
ru1
ANDI0
I1
O0
AK2
a2
ru2
ANDI0
I1
O0
AK3
a3
ru3
ANDI0
I1
O0
AK4
a4
ru4
ANDI0
I1
O0
AK5
a5
ru5
ANDI0
I1
O0
AK6
a6
ru6
ANDI0
I1
O0
AK7
a7
ru7
OR8A
B
C
D
E
F
G
H
Y
ru1
ru2
ru3
ru4
ru5
ru6
ru7
GND
UPR
ANDI0
I1
O0
AK0
b0
rd0
ANDI0
I1
O0
AK1
b1
rd1
ANDI0
I1
O0
AK2
b2
rd2
ANDI0
I1
O0
AK3
b3
rd3
ANDI0
I1
O0
AK4
b4
rd4
ANDI0
I1
O0
AK5
b5
rd5
ANDI0
I1
O0
AK6
y7
rd6
OR8A
B
C
D
E
F
G
H
Y
rd0
rd1
rd2
rd3
rd4
rd5
rd6
GND
DNR

Step 20. The button of this floor

hK — the button of the floor where the car is, is pressed. gOK — «going down or nothing above»: it is used in the decision and in lesson 2.

PartLegLabel
ANDI0
I1
O0
AK0
y0
hk0
ANDI0
I1
O0
AK1
y1
hk1
ANDI0
I1
O0
AK2
y2
hk2
ANDI0
I1
O0
AK3
y3
hk3
ANDI0
I1
O0
AK4
y4
hk4
ANDI0
I1
O0
AK5
y5
hk5
ANDI0
I1
O0
AK6
y6
hk6
ANDI0
I1
O0
AK7
y7
hk7
OR8A
B
C
D
E
F
G
H
Y
hk0
hk1
hk2
hk3
hk4
hk5
hk6
hk7
hK
NOTI0
O0
dir
ndir
NOTI0
O0
UPR
nUPR
ORI0
I1
O0
ndir
nUPR
gOK

Step 21. Here: stop

here — we stand at a floor, the doors are closed, the button of this floor is pressed: open the doors. It also rings the chime (the last step).

PartLegLabel
AND3A
B
C
Y
atF
ndoor
hK
here

Step 22. Decision: up or down

At a floor (doors closed, nothing to do here) the car decides: up if there is work above and (we go up or nothing below); down — the other way round. Keep going one way while there is work there, and only then turn around.

PartLegLabel
NOTI0
O0
DNR
nDNR
ORI0
I1
O0
dir
nDNR
uOK
ANDI0
I1
O0
UPR
uOK
mvUp
ANDI0
I1
O0
DNR
gOK
mvDn
NOTI0
O0
here
nhere
AND3A
B
C
Y
atF
ndoor
nhere
decide

Step 23. Direction

At a floor the direction is decided again (mvUp; no work — «down»), on the way and with open doors it is kept. Flip-flop dir: 1 means up.

PartLegLabel
MUX2A
B
S
Y
dir
mvUp
decide
dirN
ANDI0
I1
O0
dirN
nR
dirD
DFFD
CLK
Q
dirD
CLK
dir

Step 24. Moving

go — move on this cycle: between floors always (a lift does not stop mid-shaft), at a floor if we decided to go.

PartLegLabel
ORI0
I1
O0
mvUp
mvDn
mv
ANDI0
I1
O0
decide
mv
go1
ORI0
I1
O0
natF
go1
go

Step 25. Position counter

Five FA add +1 (up) or 11111 (that is −1: down) to the position — or 0 when standing. AND with nR — reset to the 1st floor.

PartLegLabel
NOTI0
O0
dirN
ndirN
ANDI0
I1
O0
go
ndirN
dn
FAA
B
CI
S
CO
p0
go
GND
q0
c0
FAA
B
CI
S
CO
p1
dn
c0
q1
c1
FAA
B
CI
S
CO
p2
dn
c1
q2
c2
FAA
B
CI
S
CO
p3
dn
c2
q3
c3
FAA
B
CI
S
CO
p4
dn
c3
q4
c4
ANDI0
I1
O0
q0
nR
pd0
DFFD
CLK
Q
pd0
CLK
p0
ANDI0
I1
O0
q1
nR
pd1
DFFD
CLK
Q
pd1
CLK
p1
ANDI0
I1
O0
q2
nR
pd2
DFFD
CLK
Q
pd2
CLK
p2
ANDI0
I1
O0
q3
nR
pd3
DFFD
CLK
Q
pd3
CLK
p3
ANDI0
I1
O0
q4
nR
pd4
DFFD
CLK
Q
pd4
CLK
p4

Step 26. Door timer

Opened (here) — 4 (100), open — minus 1 (three FA add 111), closed — 0. The doors stay open for 4 cycles — 2 seconds.

PartLegLabel
FAA
B
CI
S
CO
t0
VCC
GND
u0
e0
FAA
B
CI
S
CO
t1
VCC
e0
u1
e1
FAA
B
CI
S
CO
t2
VCC
e1
u2
e2
ANDI0
I1
O0
u0
OPEN
v0
ANDI0
I1
O0
u1
OPEN
v1
ANDI0
I1
O0
u2
OPEN
v2a
ORI0
I1
O0
v2a
here
v2
ANDI0
I1
O0
v0
nR
td0
DFFD
CLK
Q
td0
CLK
t0
ANDI0
I1
O0
v1
nR
td1
DFFD
CLK
Q
td1
CLK
t1
ANDI0
I1
O0
v2
nR
td2
DFFD
CLK
Q
td2
CLK
t2

Step 27. Arrows

An arrow is lit while there is work or the car is moving: ▲ — direction up, ▼ — down.

PartLegLabel
OR8A
B
C
D
E
F
G
H
Y
AK0
AK1
AK2
AK3
AK4
AK5
AK6
AK7
rAny
ORI0
I1
O0
rAny
natF
busy
ANDI0
I1
O0
dir
busy
AUP
ANDI0
I1
O0
ndir
busy
ADN

Step 28. The screen: door leaves, bar, digit

AD<f> — the door leaves: the car is at floor f and the doors are closed. AM<f> — the car is on the way between floors f and f+1. The floor digit comes from the one lit y: a segment is lit on the floors where it is needed (a — on 2, 3, 5, 6, 7, 8 …), so each segment is one OR.

PartLegLabel
ANDI0
I1
O0
AC0
ndoor
AD0
ANDI0
I1
O0
AC1
ndoor
AD1
ANDI0
I1
O0
AC2
ndoor
AD2
ANDI0
I1
O0
AC3
ndoor
AD3
ANDI0
I1
O0
AC4
ndoor
AD4
ANDI0
I1
O0
AC5
ndoor
AD5
ANDI0
I1
O0
AC6
ndoor
AD6
ANDI0
I1
O0
AC7
ndoor
AD7
ANDI0
I1
O0
y0
natF
AM0
ANDI0
I1
O0
y1
natF
AM1
ANDI0
I1
O0
y2
natF
AM2
ANDI0
I1
O0
y3
natF
AM3
ANDI0
I1
O0
y4
natF
AM4
ANDI0
I1
O0
y5
natF
AM5
ANDI0
I1
O0
y6
natF
AM6
OR8A
B
C
D
E
F
G
H
Y
y1
y2
y4
y5
y6
y7
GND
GND
AFa
OR8A
B
C
D
E
F
G
H
Y
y0
y1
y2
y3
y6
y7
GND
GND
AFb
OR8A
B
C
D
E
F
G
H
Y
y0
y2
y3
y4
y5
y6
y7
GND
AFc
OR8A
B
C
D
E
F
G
H
Y
y1
y2
y4
y5
y7
GND
GND
GND
AFd
OR3A
B
C
Y
y1
y5
y7
AFe
OR4A
B
C
D
Y
y3
y4
y5
y7
AFf
OR8A
B
C
D
E
F
G
H
Y
y1
y2
y3
y4
y5
y7
GND
GND
AFg

Step 29. Chime

Speaker from the palette: click the icon on the left — «buzzer» mode, the grille — tone 880. It rings while the doors are opening (here).

PartLegLabel
Speaker (buzzer, 880)SPKRhere

1.5. Check

Do not fold the board — in lesson 2 the floor call buttons are added to it.

  1. RST on and off. On the screen in shaft A: the car is at the 1st floor — a frame with door leaves (doors closed), digit 1 above the shaft, no arrows.
  2. Press 5. A dot lights to the right of the shaft at the 5th floor, ▲ above the shaft. The car moves: the frame goes out, a bar is lit between floors, the digit grows 1 → 2 → 3 → 4. After 8 seconds the car is at the 5th: the chime rings, the frame is empty (doors open), the dot goes out, ▲ goes out. 2 seconds later the leaves appear — the doors closed.
  3. Press 7, 8 and 3. The car goes up: opens its doors at the 7th, then at the 8th, then ▼ — and goes down to the 3rd. It would not go to the 3rd on the way up: first all the work in one direction, then the turn.
  4. Press 6, then Cancel, then 5. The dot at 6 goes out, the car goes to the 5th.
  5. Press 1 and, while the car moves, — Cancel. The car reaches the nearest floor and stops without opening its doors: a lift does not stop mid-shaft.
  6. The car stands with closed doors — press the button of its floor: the doors open at once. While the doors are open, the button of this floor does not light.
What you seeWhat it is
frame with door leavesthe car stands at a floor, doors closed
empty framethe car stands at a floor, doors open
bar between floorsthe car is moving
dot right of the shaftthat floor's button is pressed in the car
digit above the shaftthe car floor (on the way — the lower one)
▲ / ▼where it goes while there is work
shafts B, C, ▶, squaresdark — we connect them in lessons 2–4

Lesson 1 paste (Cmd+I)

You need the gates NOT, NAND, NOR, AND, OR, XOR (lesson 0 or its paste) and the parts of steps 1–10 (SRLatch … DEC8) — they are at the start of the paste; if they are already in the library, delete their chip blocks. The screen (Segment LCD) and the chime tone are done by hand, steps 11 and 29.

# Lesson 1 — the screen and car A: position, car buttons and Cancel, doors, up / down / here.# Paste: Cmd+I into a project with the gates. Segment LCD and Clock 2Hz — by hand. # ---------- parts (if already in the library, delete their blocks) ---------- chip SRLatch {  portIn(R)  portIn(S)  portOut(Q)  portOut(nQ)  NOR(R, nQ, Q)  NOR(S, Q, nQ)}chip DLatch {  portIn(D)  portIn(EN)  portOut(Q)  portOut(nQ)  NOT(D, nD)  AND(D, EN, setD)  AND(nD, EN, rstD)  SRLatch(S=setD, R=rstD, Q=Q, nQ=nQ)}chip DFF {  portIn(D)  portIn(CLK)  portOut(Q)  portOut(nQ)  NOT(CLK, nCLK)  DLatch(D=D, EN=nCLK, Q=mid)  DLatch(D=mid, EN=CLK, Q=Q, nQ=nQ)}chip FA {  portIn(A)  portIn(B)  portIn(CI)  portOut(S)  portOut(CO)  XOR(A, B, p)  XOR(p, CI, S)  AND(A, B, g)  AND(p, CI, pc)  OR(g, pc, CO)}chip MUX2 {  portIn(A)  portIn(B)  portIn(S)  portOut(Y)  NOT(S, nS)  NAND(A, nS, na)  NAND(B, S, nb)  NAND(na, nb, Y)}chip AND3 {  portIn(A)  portIn(B)  portIn(C)  portOut(Y)  AND(A, B, ab)  AND(ab, C, Y)}chip OR3 {  portIn(A)  portIn(B)  portIn(C)  portOut(Y)  OR(A, B, ab)  OR(ab, C, Y)}chip OR4 {  portIn(A)  portIn(B)  portIn(C)  portIn(D)  portOut(Y)  OR(A, B, ab)  OR(C, D, cd)  OR(ab, cd, Y)}chip OR8 {  portIn(A)  portIn(B)  portIn(C)  portIn(D)  portIn(E)  portIn(F)  portIn(G)  portIn(H)  portOut(Y)  OR4(A=A, B=B, C=C, D=D, Y=lo)  OR4(A=E, B=F, C=G, D=H, Y=hi)  OR(lo, hi, Y)}chip DEC8 {  portIn(I0)  portIn(I1)  portIn(I2)  portOut(Y0)  portOut(Y1)  portOut(Y2)  portOut(Y3)  portOut(Y4)  portOut(Y5)  portOut(Y6)  portOut(Y7)  NOT(I0, n0)  NOT(I1, n1)  NOT(I2, n2)  AND3(A=n2, B=n1, C=n0, Y=Y0)  AND3(A=n2, B=n1, C=I0, Y=Y1)  AND3(A=n2, B=I1, C=n0, Y=Y2)  AND3(A=n2, B=I1, C=I0, Y=Y3)  AND3(A=I2, B=n1, C=n0, Y=Y4)  AND3(A=I2, B=n1, C=I0, Y=Y5)  AND3(A=I2, B=I1, C=n0, Y=Y6)  AND3(A=I2, B=I1, C=I0, Y=Y7)} power(VCC)ground(GND)clock(CLK)input(RST)NOT(RST, nR)button{label="1"}(AB0)button{label="2"}(AB1)button{label="3"}(AB2)button{label="4"}(AB3)button{label="5"}(AB4)button{label="6"}(AB5)button{label="7"}(AB6)button{label="8"}(AB7)button{label="Cancel"}(ACAN)NOR(p0, p1, atF)NOT(atF, natF)DEC8(I0=p2, I1=p3, I2=p4, Y0=y0, Y1=y1, Y2=y2, Y3=y3, Y4=y4, Y5=y5, Y6=y6, Y7=y7)OR3(A=t0, B=t1, C=t2, Y=OPEN)NOT(OPEN, ndoor)AND(y0, atF, AC0)AND(AC0, OPEN, O0)AND(y1, atF, AC1)AND(AC1, OPEN, O1)AND(y2, atF, AC2)AND(AC2, OPEN, O2)AND(y3, atF, AC3)AND(AC3, OPEN, O3)AND(y4, atF, AC4)AND(AC4, OPEN, O4)AND(y5, atF, AC5)AND(AC5, OPEN, O5)AND(y6, atF, AC6)AND(AC6, OPEN, O6)AND(y7, atF, AC7)AND(AC7, OPEN, O7)OR(ACAN, RST, kc)OR(O0, kc, kr0)NOT(kr0, nkr0)AND(AB0, nkr0, ks0)SRLatch(S=ks0, R=kr0, Q=AK0)OR(O1, kc, kr1)NOT(kr1, nkr1)AND(AB1, nkr1, ks1)SRLatch(S=ks1, R=kr1, Q=AK1)OR(O2, kc, kr2)NOT(kr2, nkr2)AND(AB2, nkr2, ks2)SRLatch(S=ks2, R=kr2, Q=AK2)OR(O3, kc, kr3)NOT(kr3, nkr3)AND(AB3, nkr3, ks3)SRLatch(S=ks3, R=kr3, Q=AK3)OR(O4, kc, kr4)NOT(kr4, nkr4)AND(AB4, nkr4, ks4)SRLatch(S=ks4, R=kr4, Q=AK4)OR(O5, kc, kr5)NOT(kr5, nkr5)AND(AB5, nkr5, ks5)SRLatch(S=ks5, R=kr5, Q=AK5)OR(O6, kc, kr6)NOT(kr6, nkr6)AND(AB6, nkr6, ks6)SRLatch(S=ks6, R=kr6, Q=AK6)OR(O7, kc, kr7)NOT(kr7, nkr7)AND(AB7, nkr7, ks7)SRLatch(S=ks7, R=kr7, Q=AK7)OR(y0, y1, a2)OR(a2, y2, a3)OR(a3, y3, a4)OR(a4, y4, a5)OR(a5, y5, a6)OR(a6, y6, a7)OR(y7, y6, b5)OR(b5, y5, b4)OR(b4, y4, b3)OR(b3, y3, b2)OR(b2, y2, b1)OR(b1, y1, b0)AND(AK1, y0, ru1)AND(AK2, a2, ru2)AND(AK3, a3, ru3)AND(AK4, a4, ru4)AND(AK5, a5, ru5)AND(AK6, a6, ru6)AND(AK7, a7, ru7)OR8(A=ru1, B=ru2, C=ru3, D=ru4, E=ru5, F=ru6, G=ru7, H=GND, Y=UPR)AND(AK0, b0, rd0)AND(AK1, b1, rd1)AND(AK2, b2, rd2)AND(AK3, b3, rd3)AND(AK4, b4, rd4)AND(AK5, b5, rd5)AND(AK6, y7, rd6)OR8(A=rd0, B=rd1, C=rd2, D=rd3, E=rd4, F=rd5, G=rd6, H=GND, Y=DNR)AND(AK0, y0, hk0)AND(AK1, y1, hk1)AND(AK2, y2, hk2)AND(AK3, y3, hk3)AND(AK4, y4, hk4)AND(AK5, y5, hk5)AND(AK6, y6, hk6)AND(AK7, y7, hk7)OR8(A=hk0, B=hk1, C=hk2, D=hk3, E=hk4, F=hk5, G=hk6, H=hk7, Y=hK)NOT(dir, ndir)NOT(UPR, nUPR)OR(ndir, nUPR, gOK)AND3(A=atF, B=ndoor, C=hK, Y=here)NOT(DNR, nDNR)OR(dir, nDNR, uOK)AND(UPR, uOK, mvUp)AND(DNR, gOK, mvDn)NOT(here, nhere)AND3(A=atF, B=ndoor, C=nhere, Y=decide)MUX2(A=dir, B=mvUp, S=decide, Y=dirN)AND(dirN, nR, dirD)DFF(D=dirD, CLK=CLK, Q=dir)OR(mvUp, mvDn, mv)AND(decide, mv, go1)OR(natF, go1, go)NOT(dirN, ndirN)AND(go, ndirN, dn)FA(A=p0, B=go, CI=GND, S=q0, CO=c0)FA(A=p1, B=dn, CI=c0, S=q1, CO=c1)FA(A=p2, B=dn, CI=c1, S=q2, CO=c2)FA(A=p3, B=dn, CI=c2, S=q3, CO=c3)FA(A=p4, B=dn, CI=c3, S=q4, CO=c4)AND(q0, nR, pd0)DFF(D=pd0, CLK=CLK, Q=p0)AND(q1, nR, pd1)DFF(D=pd1, CLK=CLK, Q=p1)AND(q2, nR, pd2)DFF(D=pd2, CLK=CLK, Q=p2)AND(q3, nR, pd3)DFF(D=pd3, CLK=CLK, Q=p3)AND(q4, nR, pd4)DFF(D=pd4, CLK=CLK, Q=p4)FA(A=t0, B=VCC, CI=GND, S=u0, CO=e0)FA(A=t1, B=VCC, CI=e0, S=u1, CO=e1)FA(A=t2, B=VCC, CI=e1, S=u2, CO=e2)AND(u0, OPEN, v0)AND(u1, OPEN, v1)AND(u2, OPEN, v2a)OR(v2a, here, v2)AND(v0, nR, td0)DFF(D=td0, CLK=CLK, Q=t0)AND(v1, nR, td1)DFF(D=td1, CLK=CLK, Q=t1)AND(v2, nR, td2)DFF(D=td2, CLK=CLK, Q=t2)OR8(A=AK0, B=AK1, C=AK2, D=AK3, E=AK4, F=AK5, G=AK6, H=AK7, Y=rAny)OR(rAny, natF, busy)AND(dir, busy, AUP)AND(ndir, busy, ADN)AND(AC0, ndoor, AD0)AND(AC1, ndoor, AD1)AND(AC2, ndoor, AD2)AND(AC3, ndoor, AD3)AND(AC4, ndoor, AD4)AND(AC5, ndoor, AD5)AND(AC6, ndoor, AD6)AND(AC7, ndoor, AD7)AND(y0, natF, AM0)AND(y1, natF, AM1)AND(y2, natF, AM2)AND(y3, natF, AM3)AND(y4, natF, AM4)AND(y5, natF, AM5)AND(y6, natF, AM6)OR8(A=y1, B=y2, C=y4, D=y5, E=y6, F=y7, G=GND, H=GND, Y=AFa)OR8(A=y0, B=y1, C=y2, D=y3, E=y6, F=y7, G=GND, H=GND, Y=AFb)OR8(A=y0, B=y2, C=y3, D=y4, E=y5, F=y6, G=y7, H=GND, Y=AFc)OR8(A=y1, B=y2, C=y4, D=y5, E=y7, F=GND, G=GND, H=GND, Y=AFd)OR3(A=y1, B=y5, C=y7, Y=AFe)OR4(A=y3, B=y4, C=y5, D=y7, Y=AFf)OR8(A=y1, B=y2, C=y3, D=y4, E=y5, F=y7, G=GND, H=GND, Y=AFg)speaker{mode="buzz", tone=880}(here)

¿No te sale? Algo no funciona →