Lesson 6. The visitor counter

In pictures

After this lesson the device is ready: two displays — "inside" (in +1, out −1) and "total in" (only +1) — and a Reset button. Four CD4029, four CD4511, two beams and two CD4011.


6.1. Idea: two displays on the same beams

  • "Inside": the clock is BOTH, the direction is IN. In — +1, out — −1;
  • "Total in": the same clock, the direction is always up, and counting is allowed (CI = 0) only on the way in — CI = OUT.

No new gates are needed for the second display — everything is already in the lesson 5 circuit.

2 beamsE1→R1, E2→R22 × CD4011directionBABB2 × CD4029UD = IN2 × CD4511"inside"2 × CD4029UD = 1, CI = OUT2 × CD4511"total in"BOTHINOUT
The whole device. Beams → two CD4011: the clock BOTH and the direction IN/OUT. The "inside" display counts up when someone comes in and down when someone leaves; "total in" counts only up, and only on the way in. Each digit has its own CD4029 and CD4511.

6.2. Idea: two digits — two counters

Units and tens are two CD4029 with a common clock. The tens count only when the units go over the edge: CO of the units → CI of the tens. Each digit has its own CD4511 and its own display.

6.3. Idea: Reset holds

Reset goes to PE of all counters. While PE is 1 the CD4029 loads 0000 and its clock is blocked: the counter counts nothing. That is why Reset is a button: press and let go. A switch left at 1 keeps the display at 00 whatever happens with the beams.

ResetBOTHdisplay0001020304Reset = 1: clock blocked, display 00Reset = 0: each pass — +1
Reset holds. While it is 1, PE of every CD4029 is 1: they load 0000 and the clock does not get through — people pass but the display stays at 00. Let go — counting starts. That is why Reset is a button, not a switch.

The whole circuit as one drawing — for building with wires:

VCCE1R1VCCE2R2СбросNANDCD4011 №1123NANDCD4011 №1564NANDCD4011 №18910NANDCD4011 №1121311NANDCD4011 №2123NANDCD4011 №2564NANDCD4011 №28910NANDCD4011 №2121311CD4029PE1J14J212J313J43CI5BD9UD10CLOCK15Q16Q211Q314Q42CO7VCCVCCCD4511A7B1C2D6LT3BL4LE5a13b12c11d10e9f15g14LCDединицыabcdefgCD4029PE1J14J212J313J43CI5BD9UD10CLOCK15Q16Q211Q314Q42CO7VCCVCCCD4511A7B1C2D6LT3BL4LE5a13b12c11d10e9f15g14LCDдесяткиabcdefgVCCCD4029PE1J14J212J313J43CI5BD9UD10CLOCK15Q16Q211Q314Q42CO7VCCVCCCD4511A7B1C2D6LT3BL4LE5a13b12c11d10e9f15g14LCDединицыabcdefgVCCCD4029PE1J14J212J313J43CI5BD9UD10CLOCK15Q16Q211Q314Q42CO7VCCVCCCD4511A7B1C2D6LT3BL4LE5a13b12c11d10e9f15g14LCDдесяткиabcdefgBABBRESETXAXBSINSOUTOUTINNBOTHBOTHU0U1U2U3COUT0T1T2T3V0V1V2V3COVW0W1W2W3луч A (улица) · канал 1луч B (зал) · канал 2Табло «внутри» — единицыТабло «внутри» — десяткиТабло «всего» — единицыТабло «всего» — десятки
The device as one drawing — for building with wires. The NANDs are labelled with their CD4011 package and pin numbers; CD4029 and CD4511 with TI pins; a ground sign — to GND, red VCC — to power.

6.4. Build

The lesson 5 project — the direction circuit is in place. The library needs CD4029 and CD4511.

Step 1. The Reset button

Reset goes to PE of all four counters: while it is pressed they load 0000.

PartPinLabel
Button «Reset»outputRESET

Step 2. The "inside" display: two CD4029

The first — units (U0–U3), the second — tens (T0–T3). CLOCK of both — BOTH, the direction UD — IN: in — +1, out — −1. Decade counting (BD = 0). Carry: CO of units → CI of tens — the tens count only when the units go 9 → 0 (or 0 → 9 down).

PartPinLabel
CD4029PE
Q4
J4
J1
CI
Q1
CO
BD
UD
Q2
J2
J3
Q3
CLOCK
RESET
U3
GND
GND
GND
U0
COU
GND
IN
U1
GND
GND
U2
BOTH
CD4029PE
Q4
J4
J1
CI
Q1
CO
BD
UD
Q2
J2
J3
Q3
CLOCK
RESET
T3
GND
GND
COU
T0
COT
GND
IN
T1
GND
GND
T2
BOTH

Step 3. The "total in" display: two more CD4029

The first — units (V0–V3), the second — tens (W0–W3). Only up: UD = VCC. CI of the units — OUT: CI = 0 enables counting, so on the way in (OUT = 0) it counts, on the way out (OUT = 1) it stays. No new gates needed.

PartPinLabel
CD4029PE
Q4
J4
J1
CI
Q1
CO
BD
UD
Q2
J2
J3
Q3
CLOCK
RESET
V3
GND
GND
OUT
V0
COV
GND
VCC
V1
GND
GND
V2
BOTH
CD4029PE
Q4
J4
J1
CI
Q1
CO
BD
UD
Q2
J2
J3
Q3
CLOCK
RESET
W3
GND
GND
COV
W0
COW
GND
VCC
W1
GND
GND
W2
BOTH

Step 4. Four CD4511 decoders

PartPinLabel
CD4511B
C
LT
BL
LE
D
A
e
d
c
b
a
g
f
U1
U2
VCC
VCC
GND
U3
U0
Ue
Ud
Uc
Ub
Ua
Ug
Uf
CD4511B
C
LT
BL
LE
D
A
e
d
c
b
a
g
f
T1
T2
VCC
VCC
GND
T3
T0
Te
Td
Tc
Tb
Ta
Tg
Tf
CD4511B
C
LT
BL
LE
D
A
e
d
c
b
a
g
f
V1
V2
VCC
VCC
GND
V3
V0
Ve
Vd
Vc
Vb
Va
Vg
Vf
CD4511B
C
LT
BL
LE
D
A
e
d
c
b
a
g
f
W1
W2
VCC
VCC
GND
W3
W0
We
Wd
Wc
Wb
Wa
Wg
Wf

Step 5. Four displays

Copy the display from lesson 4 (legs a–g are already named) three more times (Cmd+C, Cmd+V) — if you do not have it, build it as in lesson 4. Place them in pairs: tens on the left, units on the right; on top — "inside", below — "total in". Labels on the legs:

PartPinLabel
Segment LCD "inside" — tensa
b
c
d
e
f
g
Ta
Tb
Tc
Td
Te
Tf
Tg
Segment LCD "inside" — unitsa
b
c
d
e
f
g
Ua
Ub
Uc
Ud
Ue
Uf
Ug
Segment LCD "total" — tensa
b
c
d
e
f
g
Wa
Wb
Wc
Wd
We
Wf
Wg
Segment LCD "total" — unitsa
b
c
d
e
f
g
Va
Vb
Vc
Vd
Ve
Vf
Vg

6.5. Check

The "inside" display — how many people are in the shop now; "total in" — how many came in since the last reset.

  1. Press Reset — both displays show 00. Reset is a button: while it is pressed (or a switch is at 1) the counters hold 00 and do not count.
  2. Walk a person in (as in lesson 5): Alt/⌘ + click on A, on B — both displays 01; clear A, clear B.
  3. Once more — 02 / 02.
  4. Walk a person out: B, A, clear B, clear A — "inside" 01, "total" 02.
  5. Stand on one beam and leave — nothing changes.
What happenedInsideTotal
Reset0000
in0101
in0202
out0102
stood on beam A0102

"Inside" does not stop below zero: 00 − 1 = 99 — that is how the CD4029 counts. In the morning the shop opens with Reset.


Lesson 6 paste (Cmd+I)

On top of lesson 5. You need CD4029 and CD4511. The paste does not place the displays — four copies of the lesson 4 display ("Four displays" step).

# Lesson 6 — the visitor counter: "inside" (+1 / -1) and "total in" (only +1) displays on the lesson 5 circuit.# Paste: Cmd+I on top of lesson 5 (CD4029 and CD4511 needed). The displays are placed by hand. button{label="Reset"}(RESET)CD4029(PE=RESET, Q4=U3, J4=GND, J1=GND, CI=GND, Q1=U0, CO=COU, BD=GND, UD=IN, Q2=U1, J2=GND, J3=GND, Q3=U2, CLOCK=BOTH)CD4029(PE=RESET, Q4=T3, J4=GND, J1=GND, CI=COU, Q1=T0, CO=COT, BD=GND, UD=IN, Q2=T1, J2=GND, J3=GND, Q3=T2, CLOCK=BOTH)CD4029(PE=RESET, Q4=V3, J4=GND, J1=GND, CI=OUT, Q1=V0, CO=COV, BD=GND, UD=VCC, Q2=V1, J2=GND, J3=GND, Q3=V2, CLOCK=BOTH)CD4029(PE=RESET, Q4=W3, J4=GND, J1=GND, CI=COV, Q1=W0, CO=COW, BD=GND, UD=VCC, Q2=W1, J2=GND, J3=GND, Q3=W2, CLOCK=BOTH)CD4511(B=U1, C=U2, LT=VCC, BL=VCC, LE=GND, D=U3, A=U0, e=Ue, d=Ud, c=Uc, b=Ub, a=Ua, g=Ug, f=Uf)CD4511(B=T1, C=T2, LT=VCC, BL=VCC, LE=GND, D=T3, A=T0, e=Te, d=Td, c=Tc, b=Tb, a=Ta, g=Tg, f=Tf)CD4511(B=V1, C=V2, LT=VCC, BL=VCC, LE=GND, D=V3, A=V0, e=Ve, d=Vd, c=Vc, b=Vb, a=Va, g=Vg, f=Vf)CD4511(B=W1, C=W2, LT=VCC, BL=VCC, LE=GND, D=W3, A=W0, e=We, d=Wd, c=Wc, b=Wb, a=Wa, g=Wg, f=Wf)

Stuck? Something doesn't work →