This project implements a simple residual current monitoring system using the PIC16F877A microcontroller. It monitors the analog input voltage (0–5 V) representing current sensed from a measurement circuit and activates an LED indicator when the value exceeds a threshold.
This version uses a potentiometer in simulation to adjust the sensed level for easy testing and calibration.
- Single-channel current level measurement using ADC (AN0)
- Adjustable trigger threshold in firmware
- Visual alert through an LED on RB0
- Runs in Proteus simulation environment
- Clean and beginner-friendly embedded C code (XC8 + MPLAB X)
-
The input voltage (0–5 V) is applied to the AN0 pin of PIC16F877A. In real use, this would come from a current transformer and conditioning circuit.
-
The ADC continuously samples this voltage.
-
If the reading exceeds a predefined 10-bit threshold value:
- The LED on RB0 is turned on.
-
Below the threshold:
- The LED remains off.
Threshold value can be tuned inside the firmware code.
-
Potentiometer:
- Left → +5 V
- Right → GND
- Middle (wiper) → RA0/AN0 (Pin 2)
-
LED output:
- RB0 (Pin 33) → 330 Ω resistor → LED → GND
-
Power:
- Pin 11 (VDD) and Pin 32 → +5 V
- Pin 12 (VSS) and Pin 31 → GND
-
Clock:
- No crystal required in schematic
- Set clock frequency to 4 MHz in PIC properties
Located in:
firmware/main.c
Written in XC8 for PIC16F877A.
Key snippet:
unsigned int v = adc_read_ch0();
if(v > THRESHOLD_ADC)
RB0 = 1;
else
RB0 = 0;Adjust this constant to change sensitivity:
#define THRESHOLD_ADC 512 // Half-scale of ADC (≈2.5V)Residual-Current-Monitor-PIC/
├─ firmware/
│ └─ main.c
├─ proteus/
│ └─ schematic.pdsprj (to be added)
└─ README.md
Planned improvements include:
- Dual-channel measurement (Live vs Neutral)
- Leakage detection by comparing two ADC channels
- Relay trip output for protection
- UART or LCD display of readings
- Proper calibration using real CT sensors
- PCB design for hardware deployment
- Safety isolation for mains operation
This project is intended for learning and simulation purposes only. It is not a certified Residual Current Device and must not be used for real mains protection without proper electrical safety design and compliance to standards.