700W Pure Sine Inverter with LCD — Arduino Uno simulation

Arduino Uno based 700W pure sine wave inverter with 20x4 I2C LCD, battery monitoring, temperature sensing, and menu system.

An interactive Arduino Uno circuit simulation you can run free in your browser on Velxio, by knlkmr2004.

Components

Sketch code

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// --- I2C LCD Setup ---
// Set the LCD address to 0x27 (or 0x3F) for a 20 chars and 4 line display
LiquidCrystal_I2C lcd(0x27, 20, 4); 

// Variables for non-blocking screen updates
unsigned long lastDisplayUpdate = 0;
const int displayInterval = 500; // Update screen every 500 milliseconds

// --- Pin Definitions ---
const int ZCD_PIN = 2;       // Zero-Crossing Detector (Hardware Interrupt 0)
const int V_BAT_PIN = A0;    // Battery Voltage Monitor (Voltage Divider)

// H-Bridge Gate Driver Pins
const int Q1_TOP_LEFT = 9;   // Timer 1
const int Q3_BOT_LEFT = 10;  // Timer 1
const int Q2_TOP_RIGHT = 11; // Timer 2
const int Q4_BOT_RIGHT = 12; // Standard Digital

// --- System Variables ---
volatile bool zeroCrossDetected = false;
volatile unsigned long zeroCrossTime = 0;

// Voltage Divider Calibration for 12V System (30k & 10k resistors)
// Math: (5.0V / 1023) * 4 = 0.01955
const float ADC_MULTIPLIER = 0.01955; 

// Full charge for a standard 12V system
const float MAX_CHARGE_VOLTAGE = 14.4; 

// Boost Duty Cycle (0 to 255) - START VERY LOW!
int boostDutyCycle = 20; 
bool isCharging = true;

void setup() {
  Serial.begin(115200);
  
  // Initialize the LCD
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("ACTIVE BOOST CHARGER");
  lcd.setCursor(0, 1);
  lcd.print("System Booting...");
  delay(2000); 
  lcd.clear();
  
  // Set output pins
  pinMode(Q1_TOP_LEFT, OUTPUT);
  pinMode(Q3_BOT_LEFT, OUTPUT);
  pinMode(Q2_TOP_RIGHT, OUTPUT);
  pinMode(Q4_BOT_RIGHT, OUTPUT);
  pinMode(ZCD_PIN, INPUT_PULLUP);

  // Ensure all MOSFETs are completely OFF at startup
  shutdownBridge();

  // Speed up Timer 1 and Timer 2 for high-frequency PWM (~31kHz)
  TCCR1B = (TCCR1B & 0b11111000) | 0x01; 
  TCCR2B = (TCCR2B & 0b11111000) | 0x01;

  // Attach Interrupt for the ZCD (Triggers when AC wave crosses 0V)
  attachInterrupt(digitalPinToInterrupt(ZCD_PIN), zcdISR, RISING);
}

void loop() {
  unsigned long currentMillis = millis();
  
  // 1. Monitor Battery Voltage
  float batteryVoltage = analogRead(V_BAT_PIN) * ADC_MULTIPLIER;
  
  // 2. LCD Screen Updates (Non-Blocking)
  if (currentMillis - lastDisplayUpdate >= displayInterval) {
    lastDisplayUpdate = currentMillis;
    
    // Line 1: Title
    lcd.setCursor(0, 0);
    lcd.print("SYS: 12V BATTERY    ");
    
    // Line 2: Live Voltage
    lcd.setCursor(0, 1);
    lcd.print("V_BAT: ");
    lcd.print(batteryVoltage, 2); 
    lcd.print(" V      ");       
    
    // Line 3: Charging Status
    lcd.setCursor(0, 2);
    if (isCharging) {
      lcd.print("STATUS: CHARGING   ");
    } else {
      lcd.print("STATUS: FULL/FLOAT ");
    }
    
    // Line 4: PWM Duty Cycle Info
    lcd.setCursor(0, 3);
    lcd.print("BOOST PWM: ");
    lcd.print(boostDutyCycle);
    lcd.print("       ");
  }

  // 3. Overcharge Protection
  if (batteryVoltage >= MAX_CHARGE_VOLTAGE) {
    shutdownBridge();
    isCharging = false;
    boostDutyCycle = 0; 
    ret

More projects by knlkmr2004