A fully functional, hardware-implemented juice vending machine designed and built from scratch using pure TTL discrete logic ICs (74-series). This project contains no microcontroller, no microprocessor, and no programmable logic devices (such as FPGAs, CPLDs, or EEPROMs). All state, timing, arithmetic, validation, and display decoding are driven entirely by a hardwired network of 50+ discrete logic integrated circuits.
- What This Project Does
- System Schematic
- Technical Specifications
- System Architecture
- Deep-Dive Logic Implementations
- Simulation & Validation
- License
In modern system design, complex state control and arithmetic are offloaded to microcontrollers. This project steps back to classical hardware engineering:
- Designing a multi-state machine entirely out of logic gates.
- Managing stock and inventory using discrete D Flip-Flops.
- Calculating dynamic transaction variables (accumulated money, price comparisons, discounts, and change) using hardwired full-adder arrays and magnitude comparators.
- Converting binary numbers to Binary Coded Decimal (BCD) for real-time output on dual 7-segment displays.
Below is the complete engineering schematic of the vending machine's digital logic design, built and simulated in CircuitMaker:
| Feature / Metric | Specification | Engineering Implementation |
|---|---|---|
| Product Selection | 6 Unique Combinations | 3 Flavors (Apple, Orange, Kiwi) Γ 2 Sizes (Large, Small) |
| Inventory Storage | 6-bit Discrete Latches | 6 Γ D Flip-Flops (74LS74) for per-item out-of-stock storage |
| Cash Input Channels | 4 Currency Inputs | Pushbuttons representing 1 AED, 2 AED, 5 AED, and 10 AED |
| Input Capacity Cap | 15 AED Maximum | Hardwired 4-bit binary comparator block |
| Arithmetic Precision | 8-bit Two's Complement | 5 Γ 4-bit Binary Full Adders (74LS283) + 74LS86 XOR gates |
| Conditional Coupon | 2 AED Automatic Discount | Triggers when the transaction purchase total exceeds 10 AED |
| Display Subsystem | Dual BCD 7-Segment Displays | Real-time transaction change display using dual BCD decoders (74LS248) |
| User Controls | Global Reset & Buy Button | Edge-triggered debounce logic with discrete sequential flags |
The entire machine operates as a hardware-level data path managed by combinational pricing networks and sequential control logic. The block diagram below illustrates how signals propagate through the system:
graph TD
%% Inputs
SubGraph_Inputs["User Interface / Inputs"]
Selection["Flavor & Size Switches"] -->|Comb. Logic| PriceGen[Price Generation Logic]
CashInput["Cash Input Buttons: 1, 2, 5, 10 AED"] -->|Shift Reg / Register| CashReg[Cash Accumulator Register]
BuyBtn[Buy Button] -->|Edge Trigger| Sequencer["Timing & Sequencing Control"]
ResetBtn[Global Reset] -->|Asynchronous| Inventory["Stock Storage: 7474 D Flip-Flops"]
%% Price and Validation
PriceGen -->|Selected Price| CompEnough[7485 Magnitude Comparator]
CashReg -->|Total Cash| CompEnough
CompEnough -->|Cash >= Price| Sequencer
CompEnough -->|Cash < Price| LedNotEnough["Not Enough $ LED"]
%% Arithmetic & Discount
CashReg -->|Total Cash| ALU["Arithmetic & Change ALU: 74283 & 7486"]
PriceGen -->|Selected Price| ALU
CashReg -->|Spend Check| CompDiscount[7485 Coupon Comparator]
CompDiscount -->|Spend > 10 AED| ALU
%% BCD Conversion & Displays
ALU -->|Binary Change| ChangeComp[7485 BCD Comparator]
ChangeComp -->|Change >= 10| BCDSub["Sub-10 Arithmetic Block"]
BCDSub -->|Units: 0-9| Dec1["BCD Decoder 1: 74LS248"]
ChangeComp -->|Tens Digit: 1| Dec2["BCD Decoder 2: 74LS248"]
Dec1 --> Disp1["7-Segment Display: Units"]
Dec2 --> Disp2["7-Segment Display: Tens"]
%% Dispensing & Inventory
Sequencer -->|Decrement Stock| Inventory
Inventory -->|Stock Status LEDs| LedDispense["Vended LED / Item LEDs"]
classDef inputs fill:#1a1a2e,stroke:#3b5360,stroke-width:2px,color:#fff;
classDef logic fill:#0f3460,stroke:#16c79a,stroke-width:2px,color:#fff;
classDef outputs fill:#162447,stroke:#e94560,stroke-width:2px,color:#fff;
class Selection,CashInput,BuyBtn,ResetBtn inputs;
class PriceGen,CashReg,Sequencer,CompEnough,ALU,CompDiscount,ChangeComp,BCDSub,Inventory logic;
class LedNotEnough,Dec1,Dec2,Disp1,Disp2,LedDispense outputs;
- Hardware: Implemented using six 74LS74 D-Type Flip-Flops (one for each product flavor and size).
- Operation:
- The flip-flops act as 1-bit stock registers where a logical high (
1) represents "in stock" and logical low (0) represents "out of stock". - When an item is vended, a clock pulse derived from the sequential control sequencer triggers the selected flip-flop, latching a
0to indicate out-of-stock. - The status is output directly to individual product LEDs on the front panel.
- The flip-flops act as 1-bit stock registers where a logical high (
- Hardware: Built using a cascaded array of 4-bit bidirectional registers.
- Operation:
- Pushbuttons on the user interface capture bill insertion.
- An edge-triggered debounce network filters mechanical button noise.
- Once validated, the corresponding value (1, 2, 5, or 10) is added to the total accumulated cash register.
- An over-capacity comparator blocks input if the total exceeds 15 AED.
- Hardware: Implemented using 74LS283 4-bit Binary Adders and 74LS86 Quad XOR gates configured for subtraction.
-
Operation:
- Performs 8-bit Two's Complement subtraction:
$\text{Change} = \text{Total Cash} - \text{Price}$ . - A parallel magnitude comparator (
74LS85) constantly checks if $\text{Total Cash} \ge \text{Selected Price}$. - Discount Logic: If the selected purchase exceeds 10 AED, a separate comparator routes the subtraction path through a discount offset, automatically subtracting 2 AED from the final price.
- Performs 8-bit Two's Complement subtraction:
- Hardware: Custom logic gates combined with dual 74LS248 BCD-to-7-segment decoders.
-
Operation:
- Converts binary change values (0β15) to BCD.
- A threshold comparator checks if
$\text{Change} \ge 10$ . If true, it subtracts 10 from the units digit and outputs a1to the tens-digit 7-segment display. - Otherwise, the tens digit remains blank, and the unit digit is routed directly to the unit display.
The design has been validated for logical correctness in CircuitMaker under multiple simulated use cases:
- Underpayment Block: Selecting an item and pressing buy with insufficient funds correctly activates the Not Enough Money LED without dispensing.
- Dynamic Stock Depletion: Buying the last available juice correctly transitions the storage flip-flop, lighting up the Out of Stock LED and blocking future selections.
- Discount Calculations: Buying a combo costing 12 AED with a 10 AED and 5 AED bill correctly displays 5 AED change (applying the 2 AED coupon discount).
This repository is licensed under the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication.
