Escolar Documentos
Profissional Documentos
Cultura Documentos
com/cart/)
(https://electrosome.com)
VoltmeterandAmmeterusingPICMicrocontroller
B Y L I G O G E O RG E (HTTP S : / / E L E CTRO S O ME . CO M/ A UTHO R/ L I JO P PA NS / ) / 2 6 3 CO MME NTS
(HTTP S : / / E L E CTRO S O ME . CO M/ V O LTME TE RA MME TE RP I C/ # CO MME NTS )
GoogleHostingService
CustomDomain&BuildYourOwnSiteStartWithAFree30Day
Trial.
VoltmeterandAmmetercanbeeasilymadeusingPICMicrocontrollerhavingADC(AnalogtoDigital
Converter).IamusingPIC16F877AandtheresultisdisplayedonanLCDDisplay.PIC16F877Ais
enoughifyoudothisprojectonlyfortestingpurposes.IsuggesttousePICwithlowpinnumbers
andmultiplexed7segmentdisplayifyouwishtousethisasyourmeasuringinstrument.
IfyoudontknowthebasisofPICADCandLCDInterfacingpleasereadthefollowingarticles.
ADCmoduleinPICMicrocontroller(https://electrosome.com/analogtodigitalconverterpic/)
LCDInterfacingwithPICMicrocontroller(https://electrosome.com/lcdpicinterfacing/)
ADCmoduleofPICMicrocontrollerconvertstheSignalsonitsanalogpinto10bitbinarydataandit
has software selectable high and low voltage reference input to some combination of VDD, VSS,
RA2andRA3.TheanaloginputtoPICislimitedtoVSSandVDDvoltages(05V)ofPIC.
Thiscircuitisdesignedtomeasure0to30V.Sowewillmap0to30Vto0to5Vbyusingavoltage
divider.Currentthroughacircuitcanbemeasuredbyintroducinga1ohmresistorandmeasuring
thevoltageacrossit.Tominimizethepathresistancewewilluse.47ohmspecialresistorwithfuse
(showninfigure)andcurrentiscalculated.VoltageandCurrentSamplingcircuitisshownbelow.
WinstarLCDModule
ManufacturerforTN/STN/TFTLCMQuality&
Customerorienteddesign
When the Input voltage is 30V (max) the voltage across 20K ohm resistor becomes 5V which is
feedbacktotheanalogpinRA2ofthePICMicrocontroller.
(https://electrosome.com/wpcontent/uploads/2012/05/11.jpg)The
voltageacross.47ohmresistorisalsofeedbacktotheanalogpin
RA3
via
100K
ohm
resistor.
5.1V
Zener
Diode
(https://electrosome.com/zenerdiodevoltageregulator/) 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/wp
content/uploads/2012/05/2.jpg)
0v=0000
5v=1111
Resolution=(Vref+Vref)/(10241)(asitis10bitADC)
=5/1023
=4.887mV
Thusitmeansthatforachangein4.887mV,thebinaryoutputchangesby1.
SovoltageinputtotheanalogpinofPICcanbecalculatedasfollows
v=ADC_Read(2);//ADCvalueofchannel2(voltage)
i=ADC_Read(3);//ADCvalueofchannel3(current)
V=v*4.89;//ConvertingADCvaluetomV
I=i*4.89;//ConvertingADCvaluetomV
ByusingvaluesVandIwecancalculatetheInputVoltageandCurrentacrosstheLoad(Connected
acrossOutputterminals).
Voltageacross20Kresistor=V
Currentthrough20K=V/20K
InputVoltage=Currentthrough20K*120K(CurrentflowingtoPICcanbeneglected)
Thus,
V=(V/20)*120;
Voltageacross0.47ohmresistor=V
CurrentthroughLoad=Currentthrough0.47ohmresistor=V/0.47
Thus,
I=I/0.47
TodisplaytheresultsinLCDDisplayweneedtoconvertthesereadingsintostring,weusetheuser
definedfunctionlook()forit.Itconvertseachdigitinthereadingtocorrespondingcharacter(seethe
sourcecode).
CircuitDiagram
(https://electrosome.com/wpcontent/uploads/2012/05/voltmeterpic.png)
Note:VDDandVSSofthepicmicrocontrollerisnotshowninthecircuitdiagram.VDDshouldbe
connectedto+5VandVSStoGND.
MikroCCode
//LCDmoduleconnections
sbitLCD_RSatRB5_bit;
sbitLCD_ENatRB7_bit;
sbitLCD_D4atRC4_bit;
sbitLCD_D5atRC5_bit;
sbitLCD_D6atRC6_bit;
sbitLCD_D7atRC7_bit;
sbitLCD_RS_DirectionatTRISB5_bit;
sbitLCD_EN_DirectionatTRISB7_bit;
sbitLCD_D4_DirectionatTRISC4_bit;
sbitLCD_D5_DirectionatTRISC5_bit;
sbitLCD_D6_DirectionatTRISC6_bit;
sbitLCD_D7_DirectionatTRISC7_bit;
//EndLCDmoduleconnections
charlook(inta)
{
switch(a)
{
case0:
return'0';
case1:
return'1';
case2:
return'2';
case3:
return'3';
case4:
return'4';
case5:
return'5';
case6:
return'6';
case7:
return'7';
case8:
return'8';
case9:
return'9';
default:
return'.';
}
}
voidmain()
{
unsignedintv,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);
}
YoumayalsouseIntToStr()toconvertintegertostring
DownloadHere
Youcandownloadthehexfile,MikroCsourcecode,Proteusfilesetchere
Voltmeter
and
Ammeter
using
PIC
Microcontroller
(https://electrosome.com/wp
content/uploads/2012/05/VoltmeterandAmmeterusingPICMicrocontroller.zip)
BuyHere
(https://electrosome.com/shop/16x2
characterlcdmodule/)
(https://electrosome.com/shop/pic16f877a
microcontroller/)
162CHARACTERLCDMODULE
(HTTPS://ELECTROSOME.COM/SHOP/16X2
CHARACTERLCDMODULE/)
PIC16F877AMICROCONTROLLER
(HTTPS://ELECTROSOME.COM/SHOP/PIC
16F877AMICROCONTROLLER/)
From:Rs.150.00From:Rs.149.00
Rs.200.00Rs.139.00
(https://electrosome.com/shop/usbpic
programmerpickit2/)
USBPICPROGRAMMERPICKIT2
(HTTPS://ELECTROSOME.COM/SHOP/USBPIC
PROGRAMMERPICKIT2/)
Rs.1,170.00Rs.929.00
Like 3,820peoplelikethis.Bethefirstofyourfriends.
electroSome
Follow
+ 716
RelatedPosts:
+1
DigitalThermometer
usingPIC
AnalogtoDigital
UsingAnalog
UsingADCModuleof
Microcontrollerand
Converter(ADC)in
ComparatorinPIC
PICMicrocontroller
LM35
PICMicrocontroller
Microcontroller
HiTechC
(https://electrosome.com/thermometer
(https://electrosome.com/analog
(https://electrosome.com/analog
(https://electrosome.com/adc
picmicrocontroller
todigitalconverter
comparatorpic
picmicrocontrollerhi
(https://electrosome.com/analog
lm35/)
pic/)
microcontroller/)
techc/)
comparatorpic
ImplementingXOR
andXNORLogic
UsingADCofPIC
Functionsusing
Microcontroller
BistableMultivibrator
DiodeBridge
MPLABXC8
using555Timer
(https://electrosome.com/xor
(https://electrosome.com/adc
(https://electrosome.com/bistable
xnorlogicfunction
ArduinoUno
picmicrocontroller
multivibrator555
diodebridge
(https://electrosome.com/ardui
mplabxc8/)
timer/)
transistor/)
uno/)
LOVEIT,SHAREIT
RECENTCOMMENTS
likethis.....
ARAVINDNA(MAILTO:ARAVIND.NA11@GMAIL.COM)
onGettingStartedwithMPLABXC8CompilerLEDBlinking(https://electrosome.com/ledpicmicrocontrollermplab
xc8/#comment5971)
siridelaytimeerrorshowswhilecodehasbeentyped....plshelp[..]
ARAVINDNA(MAILTO:ARAVIND.NA11@GMAIL.COM)
onGettingStartedwithMPLABXC8CompilerLEDBlinking(https://electrosome.com/ledpicmicrocontrollermplab
xc8/#comment5970)
sir,imadethisprojectitsworkingfinebuttheclockreset[..]
SUNIL(MAILTO:SUNILBAGHEL1989@GMAIL.COM)
onInterfacingRealTimeClock(RTC)DS1307withPICMicrocontroller(https://electrosome.com/rtcds1307pic
microcontroller/#comment5969)
helloIwanttovarythespeedusingapotentiometerandI[..]
ASMAA(MAILTO:SWAYEH.ASMA@GMAIL.COM)
onInterfacingStepperMotorwithPICMicrocontroller(https://electrosome.com/steppermotorpic
microcontroller/#comment5968)
youonlyneed2eepromaddresestosaveall16relays.[..]
SENYS(MAILTO:ALWYDAXAS@GMAIL.COM)
onUsingInternalEEPROMofPICMicrocontroller(https://electrosome.com/internaleeprompic
microcontroller/#comment5967)
sir..howtofindem18rfidreadermoduleinproteus??
SHAKE(MAILTO:SHEIKHRUR96@GMAIL.COM)
onInterfacingEM18RFIDModulewithPICMicrocontroller(https://electrosome.com/em18rfidmodule
pic/#comment5966)
sir,whatisthedifferencebetweenrfreceiverswith4pinsand[..]
PUSHKARJOG(MAILTO:PUSHKARJOG2001@GMAIL.COM)
onWirelessTransmitterandReceiverusingASKRFModule(https://electrosome.com/wirelesstransmitterand
receiverusingaskrfmodule/#comment5965)
Thankssir!foraverypowerfularticle,Ineedyouarehelp[..]
PETERMUNIKORINDWI(MAILTO:PETERMUNIKO@GMAIL.COM)
onInterfacingEM18RFIDModulewithPICMicrocontroller(https://electrosome.com/em18rfidmodule
pic/#comment5964)
SUBSCRIBEUS
EMAIL
SUBMIT
DONATEUS
RECENTPOSTS
AUTOMATICNIGHTLAMPUSINGLDR(HTTPS://ELECTROSOME.COM/AUTOMATIC
NIGHTLAMP/)
BYARUNBHASKAR(HTTPS://ELECTROSOME.COM/AUTHOR/ARUNBHASKAR/)
TRANSFORMERLESSCAPACITORDROPPERPOWERSUPPLY
(HTTPS://ELECTROSOME.COM/CAPACITORPOWERSUPPLY/)
BY(HTTPS://ELECTROSOME.COM/AUTHOR/LIJOPPANS/)LIGOGEORGE(HTTP://WWW.ELECTROSOME.COM)
SIMPLEELECTRONICPIANOUSING555TIMER
(HTTPS://ELECTROSOME.COM/ELECTRONICPIANO555TIMER/)
BY(HTTPS://ELECTROSOME.COM/AUTHOR/LIJOPPANS/)LIGOGEORGE(HTTP://WWW.ELECTROSOME.COM)
BISTABLEMULTIVIBRATORUSING555TIMER(HTTPS://ELECTROSOME.COM/BISTABLE
MULTIVIBRATOR555TIMER/)
BY(HTTPS://ELECTROSOME.COM/AUTHOR/LIJOPPANS/)LIGOGEORGE(HTTP://WWW.ELECTROSOME.COM)
USINGADCOFPICMICROCONTROLLERMPLABXC8
(HTTPS://ELECTROSOME.COM/ADCPICMICROCONTROLLERMPLABXC8/)
BY(HTTPS://ELECTROSOME.COM/AUTHOR/LIJOPPANS/)LIGOGEORGE(HTTP://WWW.ELECTROSOME.COM)
MONOSTABLEMULTIVIBRATORUSINGTRANSISTORS
(HTTPS://ELECTROSOME.COM/MONOSTABLEMULTIVIBRATORTRANSISTORS/)
BY(HTTPS://ELECTROSOME.COM/AUTHOR/LIJOPPANS/)LIGOGEORGE(HTTP://WWW.ELECTROSOME.COM)
GENERATINGPWMWITHPICMICROCONTROLLERMPLABXC8
(HTTPS://ELECTROSOME.COM/PWMPICMICROCONTROLLERMPLABXC8/)
BY(HTTPS://ELECTROSOME.COM/AUTHOR/LIJOPPANS/)LIGOGEORGE(HTTP://WWW.ELECTROSOME.COM)
GETTINGSTARTEDWITHDIPTRACE(HTTPS://ELECTROSOME.COM/GETTINGSTARTEDWITH
DIPTRACE/)
BYFEBINMATHEW(HTTPS://ELECTROSOME.COM/AUTHOR/FEBIN/)
PRODUCTS
CARBONMONOXIDESENSORMODULEMQ7
Rs.399.00 Rs.339.00
(HTTPS://ELECTROSOME.COM/SHOP/CARBONMONOXIDESENSORMODULEMQ7/)
4WAYWIRELESSREMOTECONTROL
Rs.499.00 Rs.489.00
(HTTPS://ELECTROSOME.COM/SHOP/FOURWAYWIRELESSREMOTECONTROL/)
AUDIOAMPLIFIERBOARD2X15WTDA7297
Rs.650.00 Rs.599.00
(HTTPS://ELECTROSOME.COM/SHOP/AUDIOAMPLIFIERBOARDTDA7297/)
DCMINIMOTOR1
Rs.30.00 Rs.27.00
(HTTPS://ELECTROSOME.COM/SHOP/DCMINIMOTORHOBBYTOY1/)
WHITESCREWMOUNTWHEEL10X4
Rs.120.00 Rs.109.00
(HTTPS://ELECTROSOME.COM/SHOP/WHITESCREWMOUNTWHEEL10X4/)
FLAMMABLEGASANDSMOKESENSOR
Rs.155.00 Rs.129.00
(HTTPS://ELECTROSOME.COM/SHOP/FLAMMABLEGASSMOKESENSORMQ2/)
TEMPERATUREHUMIDITYSENSORAM2301
Rs.750.00 Rs.659.00
(HTTPS://ELECTROSOME.COM/SHOP/TEMPERATUREHUMIDITYSENSORAM2301/)
BERGSTRIPFEMALESTRAIGHT
Rs.7.00 Rs.6.50
(HTTPS://ELECTROSOME.COM/SHOP/BERGSTRIPFEMALESTRAIGHT/)
SUBSCRIBEUS
SUBMIT
electroSome
LikePage
Follow
716
(https://electrosome.com)
DONATEUS
Termsandconditions(https://electrosome.com/termsconditions/) /PrivacyPolicy(https://electrosome.com/privacypolicy/) /
ShippingPolicy(https://electrosome.com/shippingpolicy/) /RefundPolicy(https://electrosome.com/refundpolicy/) /
AboutUs(https://electrosome.com/aboutus/)
electroSomeDiscover...Develop...Deliver...