Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC Volt & Amp Meterattin6

Status
Not open for further replies.

chevymn1964

Full Member level 2
Joined
Apr 1, 2006
Messages
120
Helped
2
Reputation
4
Reaction score
0
Trophy points
1,296
Location
Santa Rosa, Ca.
Activity points
2,551
pic voltage meter

Hello Everyone,
Im looking for any suggestions for a PIC Controlled DVM to read Voltage (0-30vdc) & Current (0-10A).... I have on hand some PIC16F84's and some TLC0831 ADC's I need some help on code (assembly) any ideas or links out there???
 

pic current meter

take a look at application note AN557 from microchip...it should help a lot !
 

pic volt meter

I have designed and built my own using a PIC18F4520 runnig at 20Mhz ans it's for 4 chanels 2 x volts 0-50V and 0-10A 0.02mv +/- readings

I ma in the process of laying out PCB for it has it has got to be right becasue of nosie which would affect the readings

But i have donw it in Proton Plus (basic)

wizpic
 
pic amp meter

hi
for reduce nois you can a simple low pass filter in input &use capacitor near power pin of micro
 

pic ampmeter

Hey everyone.... Well, I got the project working somewhat. I have the PIC reading the two ADC's and displaying the reading as Vdc on the top line and Adc on the lower line... But, the problem I'm having is displaying the reading with 10ths Right now it displays Vdc=5.0 I would like to display Vdc=5.00 I dont know much about Binary to BCD conversion and how to display it.... Anyone have any Assembly code I could look at to figure it out??? Thanks
 

pic volt amp meter

Hey Everyone... I found a routine for Binary to BCD and I cant figure out how to get the 1's 10's 100's to be displayed any ideas???? Right now I have it displaying 1's and 10's....

;*******************************************************************
; Binary to BCD Converter
;
; Input: Two bytes of RAM; L_Byte, H_Byte
; Output: Three bytes of RAM; R0, R1, R2
;
; Usage: Put value into L_Byte and H_Byte, call B2_BCD, result in
; R2 is LSD and R1 is MSD: Four digits (nibbles) in 2 bytes
; Lower 4 bits of LSD are least sig. digit, upper 4 are 2nd
; digit.
;*******************************************************************
B2_BCD
bcf STATUS,0 ;Clear carry bit
movlw .16
movwf count ;Set counter to 16
clrf R0
clrf R1
clrf R2
loop16
rlf L_Byte
rlf H_Byte
rlf R2
rlf R1
rlf R0
decfsz count
goto adjDEC
RETLW 0
adjDEC
movlw R2
movwf FSR
call adjBCD
movlw R1
movwf FSR
call adjBCD
movlw R0
movwf FSR
call adjBCD
goto loop16
adjBCD
movlw 3
addwf 0,W
movwf B2temp
btfsc B2temp,3 ;Test if result > 7
movwf 0
movlw 30
addwf 0,w
movwf B2temp
btfsc B2temp,7 ;Test if result > 7
movwf 0 ;Save as MSD
RETLW 0
 

volt meter pic

Hey Everyone! Well, Im having fun trying to figure out how to get 4 digits from and 8 bit ACD. Im wondering if it is even possible? What I am doing is I want to use some old parts I have laying around ( PIC 16F84 and ADC0831 ) and make an LCD Volt and Amp Meter. So far I figured out how to read the two ADC's and display the voltages on the LCD. The problem is that it only displays 1.0 for 1v and 10.0 for 10volt ect ect I would like to make it more pricession such as 1.00v and 10.00 volts or better....
 

volt amp meter lcd

I'm Not sure that you can get 4 digit reading using 8Bit you might be able to but it would not be pricession as you would like it to be 10bit would be a little bit better.

I get 4difit's with mine and i can even get 5digits with my routine but as i said it's in basic

have fun

wizpic
 

voltage meter pic

Hello all! Well I decided to go with another PIC.... I have a PIC16F677 sitting around and noticed that it has Analog PORTS built in so here I am.... The problem is I cant figure out how to configure the ports for digital or analog use? I went over the data sheet for the 16f677 but no luck.... It only shows an example of how to config for digital I/O use only.... Does anyone have an example that I could go by???
 

pic ac current meter

Hey WizPic, would you mind letting me know how you took the current measurements??? Or a schematic??? Right now I have a 16F676 Reading 2 ADC's and displaying the results V=xx.xxxVdc and C=xx.xxA ( voltage ) on an 16 x 2 LCD I was thinking of using an op amp to measure the voltage drop across a shunt resistor???
 

ampmeter pic

Here you go the volatge mesurement dvides the input voltage and the current mesurement times the voltage which goes across the shunt resistor but you may have to paly a round with the values fisrt befor you connect it up to the pic

I done this one some time ago and can't remember what teh voltage was

the current part shuod be ok though but it gives youa basic idea

wizpic
 
  • Like
Reactions: Pyae Sone

    Pyae Sone

    Points: 2
    Helpful Answer Positive Rating
    V

    Points: 2
    Helpful Answer Positive Rating
lcd volt amp meter

Hey Everyone! Yet another question.... I never really messed around with math with a uC.... I want to take the ADC readings stored in H_Byte_2, L_Byte_2 & H_Byte_3, L_Byte_3 and subtract to get the voltage drop across my shunt resistor and then divide that from the resistance of the shunt (.150 Ohms) to get the Current in AMPS..... Is that even possible???? Thanks!
 

current meter pic

do u want to do it using pic....instead use a less expensive ic like icl7106/7107....
this can measure from 0 to 200 milli volts....wat is the use rt.....use a resistor divider to read large voltage......measure voltage across a .1Ω resistor to get current flowing through the ckt....i am suggesting this because a 10 bit adc changes every 5 milli volt...hence for a 0-30v the sensitivity will be 30milli V ....it means the reading changes every 30 milli volt....if its 8 bit then .11 V....
 

volts and amps glcd

Yes, I would like to us a PIC because I want to display it on a LCD with high and low limits... So far, I have the PIC measuring the voltage across the shunt resistor with 2 ADC ports and subtracting the two adc results... Now I need to figure out how to divide that number by .15 ohms to get the current.... C=V/R.... Any PIC Math Wiss's out there willing to help???
 

pic16* amper meter

OK
Here you go

v1---/\/\/\/\---v2
3.35v............3.15v

The different between v1 and v2 is 200mv
Lets say you using the PIC VCC for reference "5V"
10 bit ad 5/1024 =0.0048828125
Each step is equal with 0.0048828125 volt
So if you read 512 from you AD registers, that will be 512*0.0048828125=2.5V
Floating point math would be to hard on you, so scale it up and round it.
Make each step to be 488 instead of the 0.0048828125.
Then again if you read 512 form your AD register's multiply it with 488.
512*488=249856 uV, the error is ~0.5%, isted of 250000 uV


On your ADCH0 you will get 686 in the AD registers, and for ADCH1 you get 645
the different is 686-645=41, now multiply this 41 with 488 and you get 20008.
That is very close to the real value of 20000 uV.
Now divide this 20008 uV with the upscaled resistor value of 15, it is 100 times more than the actual resistance.
So 20008/15=1333.86, now divide it by 1000 or move you decimal point 3 digit to the left, and you get 1.333 A
If you AD register different is 1 then, ((1*488)/15)/1000 or move decimal 3 times to the left. equal 0.032 Amp, in the real life the current is 0.032552083 Amp.
As you can see, the resolution is 32mA
Now if you need higher precision, and you maximum current is low, then you can use different voltage divider on the ADCH1 to make it 10*more than ADCH0.
This way you can get 3.2mA resolution.

There is many free examples of 16,24,32 bit math asm code out there, find them and use them.

If I'm wrong about this or you did not get it, "SORRY"
I'm just a human :D

Csaba
 

ampere meter with pic

Okay Thanks for your help Csaba... I will search the web for the math routines. That is where I am having the most trouble with learning. It would be great to see some assembly examples of code for the process that you describe... It makes since of how to do it but, I have no idea of writing the code for math functions.....
 

voltage meter with pic

Try this code it's a 64bit maths routine and gives very close results i was given it but never tried has i use basic but i have been told that it works well when included
'ADC must ge set to right Justify

ADmain ;main loop for ADC
clrf OutBuff
clrf OutBuff1
clrf cnt
movlw 0x40 ;set counter to 64
movwf cnt
st
decf cnt
bsf ADCON0,GO ;start A/D
l3
btfsc ADCON0,GO ;A/D conversion done
goto l3
bsf STATUS,RP0 ;select bank 1
movfw ADRESL
bcf STATUS,RP0 ;select bank 0
addwf OutBuff1
btfsc STATUS,C
incf OutBuff
movfw ADRESH
addwf OutBuff

movf cnt
btfss STATUS,Z
goto st
return

try it and let us know

If you tell me what your pin configuration are for ADIN put nas LCD i will send you hex file to try on your curcuit and see if that's close enough for you



wizpic
 
epe volt amper meter

use c compilers like ccs c ..htpic and many more .....u can do a lot of complex calculations easily
 

amper+volt meter lcd

That code is not a 64bit math, what is a loop to sample the AD input 64 times and add their value together.
As the end result will be a much more accurate representative of the real measurement . It used to get higher resolution of from a low resolution AD.
For example:
You are reading a not so stable signal, your AD reading will jump betwen 200 and 205 and 210 and 195, 10 times a second. You will see the last digit rolling as crazy .
If you sample the AD reading 10 times and display their final value on the end you will get the average value of the signal.
200+205+210+195+......../10=202.1
This way you are also gain one extra bit !:idea:

Csaba :arrow:
 
pic16 ампер метер

Ok, thanks everyone for all the help... I think I am making some progress and the only thing I need to figure out is how to divide the subtracted result from the adc's by the value of the shunt resistor of .15ohms to get the actual current ( C=V/R )..... all of the division examples that I have found on the web seems complex and I cant figure it out.....
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top