Lesson 1. The line and its lamps

In this lesson a small factory appears on the canvas: a source gives out parts, five machines work on them one after another, and a sink collects the finished ones. Above each machine there is a lamp: it lights while the machine works. The release comes from a clock, one part a second, and the line comes alive at once.


1.1. Idea: the factory on one base

The whole factory stands on a base — a rectangle that collects the legs of every part on it and brings them out to its edge. You don't have to hunt for the machines' and lamps' legs among the belts: they all sit around the edge of the base, each one says whose it is (m1.BUSY, D1.In), and the label hangs outside. Inside — only the mechanics and the panel; outside — the electronics.

M1M2M3M4M5m1.BUSYB1m2.BUSYB2m3.BUSYB3m4.BUSYB4m5.BUSYB5src.RELEASECKinside — the mechanics and lamps; outside — the labels on the legs at the edge of the base
Lesson 1: the factory on a base. The legs of the machines and the source come out at the edge of the base, the labels are outside; a lamp lights while its machine works (BUSY).

1.2. Idea: a balanced line

Every machine works on a part for exactly 1 second. The source gives out a part once a second. So every machine keeps up exactly with what it is fed — no more, no less. Such a line is called balanced: the capacity of every section equals the demand. It seems you could not do better: nobody stands idle, nobody is snowed under.

While the machines run like clockwork, that is so. In lesson 4 we will give them a die — and see what happens.

CKBUSY1BUSY2BUSY3BUSY4BUSY5part after part: the machines switch on in turn and then work without a break
A balanced line without dice: one part a second in, one second per part at every machine. The lamps light up in a running wave and stay on.

1.3. Idea: a lamp is the BUSY leg

A machine has three legs on top: START, BUSY, READY. BUSY = 1 while the machine works on a part. A lamp is simply connected to BUSY through a label: B1 … B5. Lit — working, dark — waiting for a part.

The 1 Hz clock gives CK. The source releases a part on a rising edge of RELEASE — so RELEASE = CK: every second, a new part.

1.4. Assembly

There are no chips in this lesson. Insert the lesson with Cmd+I (the text is at the end of the lesson). You get:

  • a base with the factory: source → belt → machine 1 → … → machine 5 → a long fast belt → sink;
  • five lamps above the machines;
  • a 1 Hz clock and the VCC, GND power — outside the base.

The last belt is longer than the others and runs twice as fast: in lesson 2 an IR pair will stand on it, and the parts must pass it with a gap between them.

1.5. Check

  1. Switch the power on.
  2. Every second a part comes out of the source and rides to the first machine.
  3. The lamps light up in turn — a «running wave» from left to right — and then stay on: every machine is busy all the time.
  4. The number of finished parts in the sink grows.
What you look atWhat you see
sourcethe released count grows once a second
lamps D1…D5lit in turn and stay on
sinkthe first part — after about 13 seconds

Click the die on one machine (twice — until it is orange): its lamp starts to blink, and the lamps of the machines after it start to go dark. That is the subject of lesson 4.

Lesson 1 insert (Cmd+I)

# Lesson 1 — the line and its lamps. A base with the factory: source -> 5 machines -> sink.# Each machine takes 1 s per part. Release comes straight from a 1 Hz clock: one part a second.# The lamps on the base light while their machine is working (BUSY).power(VCC)ground(GND)base B{w=860, h=400, hideUnused=true}msource src{color=red}(RELEASE=CK)at(src, B, 40, 185)mbelt b0{len=60}(RUN=VCC)mount(b0, src.out)mmachine m1{time=1, cap=3}(BUSY=B1)mount(m1.in, b0.end)mbelt b1{len=60}(RUN=VCC)mount(b1, m1.out)mmachine m2{time=1, cap=3}(BUSY=B2)mount(m2.in, b1.end)mbelt b2{len=60}(RUN=VCC)mount(b2, m2.out)mmachine m3{time=1, cap=3}(BUSY=B3)mount(m3.in, b2.end)mbelt b3{len=60}(RUN=VCC)mount(b3, m3.out)mmachine m4{time=1, cap=3}(BUSY=B4)mount(m4.in, b3.end)mbelt b4{len=60}(RUN=VCC)mount(b4, m4.out)mmachine m5{time=1, cap=3}(BUSY=B5)mount(m5.in, b4.end)# the last belt is longer and fast (160): parts reach the sink with a wide gap — the IR pair of lesson 2 counts each onembelt b5{len=120, spd=160}(RUN=VCC)mount(b5, m5.out)msink skmount(sk.in, b5.end)led d1(B1)at(d1, B, 150, 110)led d2(B2)at(d2, B, 270, 110)led d3(B3)at(d3, B, 390, 110)led d4(B4)at(d4, B, 510, 110)led d5(B5)at(d5, B, 630, 110)clock{rt=1}(CK)

Stuck? Something doesn't work →