Atmega8 based Voltmeter Ampmeter v2

This is V2 update of Atmega8 Volt-Ammeter. This new version features the following upgrades,

  • Low power consumption
  • Better Amperes display resolution while using low value drop resistor.
  • Much smaller PCB size, only 5cm x 5cm. Still no SMD components.
  • Easy calibration, only one voltage adjust and one ampere adjust preset, no voltage out detection.
 Atmega8 based Voltmeter Ammeter v2 used Component List:
1x Atmega8L/Atmega8A Pre-Programmed microcontroller (PDIP)
1x 1×16 LCD with Green/Blue Backlight
1x Custom PCB (5cm x 5xm)
1x LM7805 5V Voltage Regulator
2x 22uF 50V Electrolytic polarized capacitor
1x 100kpF Ceramic Capacitor
2x 10K Multiturn Trimmer Potentiometer in 3268 package
1x 10K 1/4watt Metal Film Resistor +-5% (brown, black, orange, golden)
2x 1K 1/4watt Metal Film Resistor +-5% (brown, black, red, golden)
1x 0.1~0.5Ohm / 3W Power Resistor
1x 1×16 and 1x 1×6 female pin header for LCD and ISP
  Voltmeter Ammeter v2 Technical Specifications:
Voltage Supply: 6V – 30V
Current Consumption: ~ 30mA with LCD backlight
Voltage Input: 6-30V
Voltage Resolution: 50mV
Current Input: 0-5A
Current Resolution: 100mA

Schematics diagram

Board Top

Board Bottom

Assembled PCB

Voltage supplied by my 12Volt benchtop PSU(The resistor at output terminal is disconnected)

The 10Ohm resistance is connected and is burning :P. Voltage dropped to 8.75~8.80V and hence Amperes would be 0.875~0.88Amps and it is displayed here as 0.90Amps. It’s perfect as the meter is having 100mA resolution.

 

Callibration and usage:

  • Connect a 5V DC supply to the voltage input. And short pin 1 and pin 3 of the LM7805 regulator.
  • Now tune the rightmost preset to show 5.00V on the LCD.
  • Now connect any real power supply of say 12volts. Connect a load at output, say a auto lamp, Measure current with multimeter, or calculate Amperes, and then tune the 2nd rightmost preset to show that reading of Amperes on LCD.

Software is written in WinAVR and Peter’s LCD library is used.The code below,

#include <avr/io.h>
#include "lcd.h"
#include <util/delay.h>
void InitADC()
{
ADMUX=(1<<REFS0);                         // For Aref=AVcc;
ADCSRA=(1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0); //Prescalar div factor =128
}
uint16_t ReadADC(uint8_t ch)
{
ch=ch&0b00000111;
ADMUX|=ch;
ADCSRA|=(1<<ADSC);
while(!(ADCSRA & (1<<ADIF)));
ADCSRA|=(1<<ADIF);
return(ADC);
}
void print(uint16_t parameter)
{
parameter%=10000;
lcd_putc((parameter/1000)+48);
parameter%=1000;
lcd_putc((parameter/100)+48);
parameter%=100;
lcd_puts(".");
lcd_putc((parameter/10)+48);
lcd_putc((parameter%10)+48);
}
void main()
{
int adc;
while(1)
{
lcd_init(LCD_DISP_ON);
lcd_clrscr();
lcd_gotoxy(0,0);
lcd_puts("Volts");
lcd_gotoxy(8,0);
lcd_puts("Amperes");
lcd_gotoxy(0,1);
InitADC();
adc=ReadADC(0);
print(adc*5);
lcd_puts("V");
InitADC();
adc=ReadADC(1);
lcd_gotoxy(8,1);
print(adc*10);
lcd_puts("A");
_delay_ms(100);
}
}

Downloads:

Eagle filesProject Package

You may also like...

80 Responses

  1. Udo says:

    Hello,
    I have found the error in Maim.c. The new hex file can I send.
    Who has interest. ([email protected])

  2. Udo says:

    ‘ 04.08.2013
    ‘ Atmega 8
    ‘ Display mit 2×16
    ‘BASCOM Compiler

    ‘——————————————————————————
    $regfile “m8def.dat” ‘Definiert den Atmega 8
    $crystal = 8000000 ‘ Taktfrequenz 1 Mhz
    Config Lcd = 16 * 2 ‘LCD Display in Art und Größe
    Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.3 , Db6 = Portd.2 , Db7 = Portd.1 , E = Portd.5 , Wr = Portd.6 , Rs = Portd.7
    Dim Mess_volt As Word
    Dim Mess_amper As Word
    Dim Volt As Single , V As String * 10
    Dim Amper As Single , A As String * 10
    Dim Watt As Single , W As String * 10
    Const Adc_multi = 0.0146484375 ‘0,0146484375 = 15 Volt max Messwert bei 5 Volt Referenz / 1024
    Config Adc = Single , Prescaler = Auto , Reference = Avcc
    Start Adc
    Cls
    Do
    Mess_volt = Getadc(0)
    Volt = Mess_volt * Adc_multi
    Volt = Volt * 80
    Volt = Volt / 50
    Mess_amper = Getadc(1)
    Amper = Mess_amper * Adc_multi
    Amper = Amper * 80
    Amper = Amper / 50
    Watt = 0
    Watt = Watt + Volt
    Watt = Watt * Amper
    V = Fusing(volt , “#.##”)
    A = Fusing(amper , “#.##”)
    W = Fusing(watt , “#.##”)
    Locate 1 , 1 : Lcd “Volt ” ; V
    Locate 2 , 1 : Lcd “Amper ” ; A
    Wait 1
    Locate 2 , 1 : Lcd “Watt ” ; W
    Wait 1
    Loop

  3. THUSHARA says:

    Hi Friend

    I can do all the electronics except pic programming
    pl. tel me if I copy your main.hex text to programmer software and compile
    is it all about the this pic programming, what is the suitable software for this programming pl help me on this

    thank you

    • Henri says:

      Hay Thushara
      Have you found the circuit (Atmega8 based voltmeter ammeter v2) also created and operates at you …. !!!! I have also made but I get that but not in operation, and the light definitely on the software, the circuit I’ve checked several times and it is 100% fit, like some more information, and if that works, it is possible my the good software by sending through my mael Address.
      Mvg ……… Henri

  4. Henri says:

    Hey…….
    I made the Volt and ammeter ATmega8 programmed and yet it does not work, ask – is the hex file corekt or has another cause like some more information if it is possible to send me the correct hex file
    Mvg ..

    • Arnab says:

      Thanks Henri, I apologize that I’m not the author/creator of this project, and original author is currently busy.

      But from where did you got the hex file ? Is it from the Downloads section in this tutorial ?

      • Henri says:

        Hay Arnab
        I made the circuit as on the blog, and that’s not a problem.
        I’m looking for the software (Hex file) that works, the software does not work on the blog. If I have a good HEX file and it works well, then I will confirm that with pictures.
        Thanks for the replay
        Mvg … Henri

    • Arup Basak says:

      Hi Henri,
      Make sure your atmega8 is tuned for internal 8Mhz oscillator.
      Simply burn this fuse settings. “-U lfuse:w:0xe4:m -U hfuse:w:0xd9:m ”
      Thanks and regards,
      Arup

      • Henri says:

        Hi Arup
        THE Lfuse and Hfuse and Xtal frequency are all set correctly, the PCB layout is also correct and I program with the programmer and the programming software PonyProg, any many other circuits that I have to work flawlessly already, so I think is wrong with Hex file uploads to the site. We are sorry for this project if it can not work. Do you sometimes have the correct working hex file and please please pass it forward.
        Thanks and regards,

  5. Henri says:

    Hey ,
    yes that’s right, I made it out of that download setion and that does not work, the question is whether it is possible to send the working hex file
    Thanks and regards,

Leave a Reply

Your email address will not be published. Required fields are marked *

Useful one ? Share it !