Dual 4-bit Decade Ripple Counter IC - 74HC390 Documentation
The 74HC390 is a Dual 4-bit Decade Ripple Counter IC, a versatile component used for counting and frequency division applications in digital circuits. It consists of two separate 4-bit ripple counters, each with a ripple carry output and a clock input. The counters can be used independently or connected in cascade to form a larger counter.
The 74HC390 has a 16-pin DIP package with the following pinout:
| Pin Number | Pin Name | Function |
| --- | --- | --- |
| 1 | RCO1 | Ripple Carry Output 1 |
| 2-5 | Q1-Q4 | Counter 1 Outputs |
| 6 | CP1 | Clock Input 1 |
| 7-10 | Q5-Q8 | Counter 2 Outputs |
| 11 | CP2 | Clock Input 2 |
| 12 | RCO2 | Ripple Carry Output 2 |
| 13-16 | GND, VCC | Power Supply |
Each counter is a 4-bit decade counter, meaning it counts from 0 to 9 (0000 to 1001 in binary) before resetting to 0. The counters can be connected in cascade to form an 8-bit counter, a 12-bit counter, or even larger.
### Example 1: Basic 4-bit Counter using 74HC390 with Arduino
In this example, we'll use one counter to count pulses from a photodiode connected to a clock input. The counter output will be displayed on an LCD display.
```cpp
// Arduino Sketch
#include <LiquidCrystal.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int clockPin = 2; // Connect photodiode to this pin
const int latchPin = 4; // Connect Q1-Q4 to this pin
const int lcd_RS = 7;
const int lcd_EN = 8;
const int lcd_D4 = 9;
const int lcd_D5 = 10;
const int lcd_D6 = 11;
const int lcd_D7 = 12;
void setup() {
pinMode(clockPin, INPUT);
pinMode(latchPin, OUTPUT);
lcd.init();
lcd.backlight();
}
void loop() {
static byte count = 0;
static byte prevCount = 0;
if (digitalRead(clockPin) == HIGH) {
count = (count + 1) % 10; // Increment count (mod 10)
}
if (count != prevCount) {
prevCount = count;
lcd.setCursor(0, 0);
lcd.print("Count: ");
lcd.print(count, DEC);
delay(100);
}
}
```
### Example 2: Cascaded 8-bit Counter using 74HC390 with Raspberry Pi (Python)
In this example, we'll connect two counters in cascade to form an 8-bit counter. The counter output will be displayed on the Raspberry Pi's console.
```python
# Python Script
import RPi.GPIO as GPIO
import time
# Counter 1
CP1 = 17 # Clock input 1
Q1 = 23 # Q1 output
Q2 = 24 # Q2 output
Q3 = 25 # Q3 output
Q4 = 27 # Q4 output
# Counter 2
CP2 = 22 # Clock input 2
Q5 = 5 # Q5 output
Q6 = 6 # Q6 output
Q7 = 13 # Q7 output
Q8 = 19 # Q8 output
GPIO.setup(CP1, GPIO.IN)
GPIO.setup(Q1, GPIO.OUT)
GPIO.setup(Q2, GPIO.OUT)
GPIO.setup(Q3, GPIO.OUT)
GPIO.setup(Q4, GPIO.OUT)
GPIO.setup(CP2, GPIO.IN)
GPIO.setup(Q5, GPIO.OUT)
GPIO.setup(Q6, GPIO.OUT)
GPIO.setup(Q7, GPIO.OUT)
GPIO.setup(Q8, GPIO.OUT)
try:
while True:
if GPIO.input(CP1) == GPIO.HIGH:
count = (count + 1) % 256 # Increment count (mod 256)
print(f'Count: {count:08b}')
time.sleep(0.1)
except KeyboardInterrupt:
GPIO.cleanup()
```
Note: These examples are for illustration purposes only and may require additional circuitry and modifications to work in a real-world application. Ensure you understand the 74HC390's datasheet and the specific requirements of your project before implementing these examples.