(https://electrosome.com/cart/) (https://electrosome.com)
Voltmeter and Ammeter using PIC Microcontroller Microcontroller B Y L I G O G E O R G E ( H T T P S : / / E L E C T R O S O M E . C O M / A U T H O R / L I J O P P A N S / ) / 2 6 3 C OMMENTS ( H TT TT P S : / / E L E C T R O S O M E . C O M / V O L T M E T E R -A -A M M E T E R -P -P I C / # C O M M E N T S )
Google Hosting Service Custom Domain & Build Your Own Site Start With A Free 30-Day
Voltmeter and Ammeter can be easily made using PIC Microcontroller having ADC (Analog to Digital Converter). I am using PIC16F877A and the result is displayed on an LCD Display. PIC16F877A is enough if you do this project only for testing purposes. I suggest to use PIC with low pin numbers and multiplexed 7 segment display if you wish to use this as your measuring instrument. If you you don’t know the basis of PIC ADC and LCD Interfacing please read the following articles. ADC module in PIC Microcontroller (https://electrosome.com/analog-to-digital-converter-pic/) (https://electrosome.com/analog-to-digital-converter-pic/) LCD Interfacing with PIC Microcontroller (https://electrosome.com/lcd-pic-interfacing/) ADC module of PIC Microcontroller converts the Signals on its analog pin to 10 bit binary data and it has software selectable high and low voltage reference input to some combination of VDD, VSS, RA2 and RA3. The analog input to PIC is limited to VSS and VDD voltages (0 – 5V) of PIC. This circuit is designed to measure measure 0 to 30V. So we will will map map 0 to 30V to 0 to 5V by using a voltage divider. divider. Current through a circuit circuit can be measured by introducing introducing a 1 ohm resistor and measuring measuring the voltage across it. To minimize the path resistance we will use .47 ohm special resistor with fuse (shown in figure) and current is calculated. Voltage and Current Sampling circuit is shown below.
Winstar-LCD Module Manufacturer for for TN/STN/TFT TN/STN/TFT LCM Quality & Customer oriented design »
When the Input voltage is 30V (max) the voltage across 20K ohm resistor becomes 5V which is feedback to the analog pin RA2 of the PIC Microcontroller. (https://electrosome.com/wp-content/uploads/2012/05/11.jpg)The voltage across .47 ohm resistor is also feedback to the analog pin RA3
via
100K
ohm
resistor.
5.1V
Zener
Diode
(https://electrosome.com/zener-diode-voltage-regulator/) is added in parallel to these analog input pins to protect PIC from over voltages. The ADC module of PIC converts analog input to 10 bit digital number. We want to convert this digital
to
corresponding
voltage
in
decimal.
(https://electrosome.com/wpcontent/uploads/2012/05/2.jpg) 0v = 0 0 0 0 5v = 1 1 1 1 Resolution = (Vref+ – Vref-)/(1024-1) (as it is 10 bit ADC) = 5/1023 = 4.887 mV Thus it means that for a change in 4.887mV, the binary output changes by 1. So voltage input to the analog pin of PIC can be calculated as follows… v i V I
= = = =
ADC_Read(2); ADC_Read(3); v*4.89; i*4.89;
// // // //
ADC value of channel ADC value of channel Converting ADC value Converting ADC value
2 (voltage) 3 (current) to mV to mV
By using values V and I we can calculate the Input Voltage and Current across the Load (Connected across Output terminals). Voltage across 20K resistor = V Current through 20K = V/20K Input Voltage = Current through 20K * 120K (Current flowing to PIC can be neglected) Thus, V = (V/20)*120;
Voltage across 0.47 ohm resistor = V Current through Load = Current through 0.47 ohm resistor = V/0.47 Thus,
I = I/0.47; To display the results in LCD Display we need to convert these readings into string, we use the user defined function look() for it. It converts each digit in the reading to corresponding character (see the source code).
Circuit Diagram
(https://electrosome.com/wp-content/uploads/2012/05/voltmeterpic.png) Note: VDD and VSS of the pic microcontroller is not shown in the circuit diagram. VDD should be connected to +5V and VSS to GND.
MikroC Code
// LCD module connections sbit LCD_RS at RB5_bit; sbit LCD_EN at RB7_bit; sbit LCD_D4 at RC4_bit; sbit LCD_D5 at RC5_bit; sbit LCD_D6 at RC6_bit; sbit LCD_D7 at RC7_bit; sbit LCD_RS_Direction at TRISB5_bit; sbit LCD_EN_Direction at TRISB7_bit; sbit LCD_D4_Direction at TRISC4_bit; sbit LCD_D5_Direction at TRISC5_bit; sbit LCD_D6_Direction at TRISC6_bit; sbit LCD_D7_Direction at TRISC7_bit; // End LCD module connections char look(int a) { switch(a) { case 0: return '0'; case 1: return '1'; case 2: return '2'; case 3: return '3'; case 4: return '4'; case 5: return '5'; case 6: return '6'; case 7: return '7'; case 8: return '8'; case 9: return '9'; default: return '.'; } } void main() { unsigned int v,vp,ip,i; char *volt = "00.0"; char *current = "0.00"; CMCON = 0x07; TRISA = 0xFF; ADCON1 = 0x00; Lcd_Init(); Lcd_Cmd(_LCD_CLEAR); Lcd_Cmd(_LCD_CURSOR_OFF);
do { v = ADC_Read(2); i = ADC_Read(3); i = (i*4.89)/0.47; v = ((v*4.89)/20)*120; if(v!=vp || i!=ip ) Lcd_Cmd(_LCD_CLEAR); vp = v; ip = i; volt[0] = look(v/10000); volt[1] = look((v/1000)%10); volt[3] = look((v/100)%10); Lcd_Out(1,1,"Voltage = "); Lcd_Out(1,11,volt); Lcd_Out(1,16,"V"); current[0] = look(i/1000); current[2] = look((i/100)%10); current[3] = look((i/10)%10); Lcd_Out(2,1,"Current = "); Lcd_Out(2,11,current); Lcd_Out(2,16,"A"); Delay_ms(250); } while(1); }
You may also use IntToStr() to convert integer to string
Download Here You can download the hex file, MikroC source code, Proteus files etc here… Voltmeter
and
Ammeter
using
PIC
Microcontroller
(https://electrosome.com/wp-
content/uploads/2012/05/Voltmeter-and-Ammeter-using-PIC-Microcontroller.zip)
Buy Here
(https://electrosome.com/shop/16x2character-lcd-module/)
(https://electrosome.com/shop/pic-16f877amicrocontroller/)
16×2 CHARACTER LCD MODULE (HTTPS://ELECTROSOME.COM/SHOP/16X2CHARACTER-LCD-MODULE/)
PIC 16F877A MICROCONTROLLER (HTTPS://ELECTROSOME.COM/SHOP/PIC16F877A-MICROCONTROLLER/)
From: Rs.150.00 From: Rs.149.00
Rs.200.00 Rs.139.00
(https://electrosome.com/shop/usb-picprogrammer-pickit-2/) USB PIC PROGRAMMER PICKIT 2 (HTTPS://ELECTROSOME.COM/SHOP/USB-PICPROGRAMMER-PICKIT-2/)
Rs.1,170.00 Rs.929.00
Like 3,820 people like this. Be the first of your friends.
electroSome Follow + 716
Related Posts:
+1
Digital Thermometer using PIC Microcontroller and LM35… (https://electrosome.c pic-microcontrollerlm35/)
Using ADC of PIC Microcontroller – MPLAB XC8 (https://electrosome.c pic-microcontrollermplab-xc8/)
Analog to Digital Converter (ADC) in PIC Microcontroller (https://electrosome.c to-digital-converter pic/)
Using Analog Comparator in PIC Microcontroller (https://electrosome.c comparator-pic(https://electrosome. microcontroller/)
Using ADC Module of PIC Microcontroller – Hi Tech C (https://electrosome.c pic-microcontroller-hitech-c/)
Bistable Multivibrator using 555 Timer (https://electrosome.c multivibrator-555timer/)
mp emen ng and XNOR Logic Functions using Diode Bridge (https://electrosome.c xnor-logic-functiondiode-bridgetransistor/)
Arduino Uno (https://electrosome.c uno/)
C A T E G O R I E S : E M B E D D E D ( H T T P S : / / E L E C T R O S O M E . C O M/ C A TE G O R Y / P R O J E C T S / E M B E D D E D - P R O J E CT S / ) , P I C
M I C RO C O N TR O L L E R ( H TT P S : / / E L E C T R O S O M E . C O M / C AT E G O R Y / P R O J E C T S / E M B E D D E D -P R O J E C T S / P I C - M I CR O C O NT R O L L E R P R O J E C T S / ) , P R O J E C T S ( HT T P S : / / E L E C T R O S O M E . C O M / C AT E G O R Y / P R O J E C T S / ) TAGS: E M B E D D E D ( HT T P S : / / E L E C T R O S O M E . C O M / TA G / E M B E D D E D/ ) , M I C RO C O N T RO L L E R
LOVE IT, SHARE IT
( HT T P S : / / E L E C T R O S O M E . C O M / TA G / M I C R O C O NT R O L L E R / ) , M I K R O C ( H T T P S : / / E L E C T R O S O M E . C O M/ T A G / M I K R O C / ), P I C ( HT T P S : / / E L E C T R O S O M E . C O M / TA G / P I C / ) , P R O T E U S ( H TT P S : / / E L E C T R O S O M E . C O M / TA G / P R O T E U S / )
RECENT COMMENTS like this.....
ARAVIND NA ( MAILTO:
[email protected]) on Getting Started with MPLAB XC8 Compiler – LED Blinking (https://electrosome.com/led-pic-microcontroller-mplabxc8/#comment-5971)
sir i delay time error shows while code has been typed....pls help [..]
ARAVIND NA ( MAILTO:
[email protected]) on Getting Started with MPLAB XC8 Compiler – LED Blinking (https://electrosome.com/led-pic-microcontroller-mplabxc8/#comment-5970)
sir, i made this project its working fine but the clock reset [..]
SUNIL (MAILTO:
[email protected]) on Interfacing Real Time Clock (RTC) DS1307 with PIC Microcontroller (https://electrosome.com/rtc-ds1307-pic-
microcontroller/#comment-5969)
hello I want to vary the speed using a potentiometer and I [..]
ASMAA (MAILTO:
[email protected]) on Interfacing Stepper Motor with PIC Microcontroller (https://electrosome.com/stepper-motor-picmicrocontroller/#comment-5968)
you only need 2 eeprom addreses to save all 16 relays . [..]
SENYS (MAILTO:
[email protected]) on Using Internal EEPROM of PIC Microcontroller (https://electrosome.com/internal-eeprom-picmicrocontroller/#comment-5967)
sir..how to find em18 rfid reader module in proteus??
SHAKE (MAILTO:
[email protected]) on Interfacing EM-18 RFID Module with PIC Microcontroller (https://electrosome.com/em-18-rfid-modulepic/#comment-5966)
sir, what is the difference between rf receivers with 4 pins and [..]
PUSHKAR JOG (MAILTO:
[email protected]) on Wireless Transmitter and Receiver using ASK RF Module (https://electrosome.com/wireless-transmitter-andreceiver-using-ask-rf-module/#comment-5965)
Thanks sir! for a very powerful article, I need you are help [..]
PETERMUNIKO RINDWI (MAILTO:
[email protected]) on Interfacing EM-18 RFID Module with PIC Microcontroller (https://electrosome.com/em-18-rfid-modulepic/#comment-5964)
SUBSCRIBE US EMAIL
SUBMIT
DONATE US
RECENT POSTS AUTOMATIC NIGHT LAMP USING LDR (HTTPS://ELECTROSOME.COM/AUTOMATICNIGHT-LAMP/) BY ARUN BHASKAR (HTTPS://ELECTROSOME.COM/AUTHOR/ARUN-BHASKAR/)
TRANSFORMERLESS CAPACITOR DROPPER POWER SUPPLY (HTTPS://ELECTROSOME.COM/CAPACITOR-POWER-SUPPLY/) BY (HTTPS://E LECTROSOME.COM/AUTHOR/LIJOPPANS/)LIGO GEORGE (HTTP://WWW.ELE CTROSOME.COM)
SIMPLE ELECTRONIC PIANO USING 555 TIMER (HTTPS://ELECTROSOME.COM/ELECTRONIC-PIANO-555-TIMER/) BY (HTTPS://E LECTROSOME.COM/AUTHOR/LIJOPPANS/)LIGO GEORGE (HTTP://WWW.ELE CTROSOME.COM)
BISTABLE MULTIVIBRATOR USING 555 TIMER (HTTPS://ELECTROSOME.COM/BISTABLEMULTIVIBRATOR-555-TIMER/) BY (HTTPS://E LECTROSOME.COM/AUTHOR/LIJOPPANS/)LIGO GEORGE (HTTP://WWW.ELE CTROSOME.COM)
USING ADC OF PIC MICROCONTROLLER – MPLAB XC8 (HTTPS://ELECTROSOME.COM/ADC-PIC-MICROCONTROLLER-MPLAB-XC8/) BY (HTTPS://E LECTROSOME.COM/AUTHOR/LIJOPPANS/)LIGO GEORGE (HTTP://WWW.ELE CTROSOME.COM)
MONOSTABLE MULTIVIBRATOR USING TRANSISTORS (HTTPS://ELECTROSOME.COM/MONOSTABLE-MULTIVIBRATOR-TRANSISTORS/) BY (HTTPS://E LECTROSOME.COM/AUTHOR/LIJOPPANS/)LIGO GEORGE (HTTP://WWW.ELE CTROSOME.COM)
GENERATING PWM WITH PIC MICROCONTROLLER – MPLAB XC8 (HTTPS://ELECTROSOME.COM/PWM-PIC-MICROCONTROLLER-MPLAB-XC8/) BY (HTTPS://E LECTROSOME.COM/AUTHOR/LIJOPPANS/)LIGO GEORGE (HTTP://WWW.ELE CTROSOME.COM)
GETTING STARTED WITH DIPTRACE (HTTPS://ELECTROSOME.COM/GETTING-STARTED-WITHDIPTRACE/)
BY FEBIN MATHEW (HTTPS:/ /ELE CTROSOME.COM/AUTHOR/FEBIN/)
PRODUCTS
CARBON MONOXIDE SENSOR MODULE - MQ7 Rs.399.00
Rs.339.00
(HTTPS://ELECTROSOME.COM/SHOP/CARBON-MONOXIDE-SENSOR-MODULE-MQ7/)
4 WAY WIRELESS REMOTE CONTROL Rs.499.00
Rs.489.00
(HTTPS://ELECTROSOME.COM/SHOP/FOUR-WAY-WIRELESS-REMOTE-CONTROL/)
AUDIO AMPLIFIER BOARD 2X15W - TDA7297 Rs.650.00
Rs.599.00
(HTTPS://ELECTROSOME.COM/SHOP/AUDIO-AMPLIFIER-BOARD-TDA7297/)
DC MINI MOTOR 1
Rs.27.00
Rs.30.00
(HTTPS://ELECTROSOME.COM/SHOP/DC-MINI-MOTOR-HOBBY-TOY-1/)
WHITE SCREW MOUNT WHEEL 10X4 Rs.120.00
Rs.109.00
(HTTPS://ELECTROSOME.COM/SHOP/WHITE-SCREW-MOUNT-WHEEL-10X4/)
FLAMMABLE GAS AND SMOKE SENSOR Rs.155.00
Rs.129.00
(HTTPS://ELECTROSOME.COM/SHOP/FLAMMABLE-GAS-SMOKE-SENSOR-MQ2/)
TEMPERATURE HUMIDITY SENSOR - AM2301 Rs.750.00
Rs.659.00
(HTTPS://ELECTROSOME.COM/SHOP/TEMPERATURE-HUMIDITY-SENSOR-AM2301/)
BERG STRIP FEMALE STRAIGHT Rs.7.00
Rs.6.50
(HTTPS://ELECTROSOME.COM/SHOP/BERG-STRIP-FEMALE-STRAIGHT/)
SUBSCRIBE US
SUBMIT
electroSome Like Page
Follow
716
(https://electrosome.com)
DONATE US
Terms and conditions (https://electrosome.com/terms-conditions/) / Privacy Policy (https://electrosome.com/privacy-policy/) / Shipping Policy (https://electrosome.com/shipping-policy/) / Refund Policy (https://electrosome.com/refund-policy/) / About Us (https://electrosome.com/about-us/) electroSome - Discover... Develop... Deliver...