# Digital Voltmeter

#### mikecy

Joined Apr 28, 2010
8
Hi to all.I have to build a project about a digital voltmeter and amper meter and send data to pc.I will have 3 volt input from -12v to 12v and 4 amper meter from -1A to 1A.From a quick research i did i decided to use the 16f877 pic.For the ampers i will use a current sensor.My questions are.How can i measure negative voltage? and what i need for rs232 communication with pc(max232)?
p.s.I will use vb2008
thanks

#### retched

Joined Dec 5, 2009
5,208
the MAX232 is a fine choice for RS232 communications.

Be sure to use a highly rated resistor for your sensing resistor. On a little circuit I built, I used a 50W 1ohm 1% resistor. I think I paid \$4us for it.

You can build a voltmeter, then measure the voltage across the resistor to get the amperage. You can work this into the design fairly easily. Especially if you use a switch to select Volts and Amps.

With the AMPs selection, you are addind the resistor to the mix, and still "reading" volts but displaying AMPS.

#### mikecy

Joined Apr 28, 2010
8
thanks for the answer.but my main concern is how to read the negative volt for example -5 volts?

#### retched

Joined Dec 5, 2009
5,208
You cant measure negative voltages directly with a PIC 877.

#### mikecy

Joined Apr 28, 2010
8
Do you know how can i do that?sorry for all the question but i didn't find anything.And the max232 is neccesary?because i saw a few circuits that connected the pic directly to rs232

#### Markd77

Joined Sep 7, 2009
2,806
Do you know how can i do that?sorry for all the question but i didn't find anything.And the max232 is neccesary?because i saw a few circuits that connected the pic directly to rs232
Without the max232 it might work on some PCs. If you are using the USART for communications, it's output is inverted because the MAX232 inverts the signals, so you would have to use a couple of transistors.
May as well just get the MAX232, they are only cheap.

#### t06afre

Joined May 11, 2009
5,934
I think it is wise to play safe and use a MAX232 type circuit. At least you will know that the signals levels are OK. RS232 can sometimes be quite pesky to debug, so it is wise to eliminate error sources. Also remember to read the data sheet even if you program the PIC in C. Not all RS232 transmission speeds can be achieved. This will depend on PIC osc speed

#### mik3

Joined Feb 4, 2008
4,843
Use a precision rectifier to rectify the measured voltage and then feed it to the PIC. In this way, the voltage to the PIC will be always positive. Also, use a comparator to indicate the PIC if the voltage measured is positive or negative.
It would be good to use an op amp buffer circuit at the front end of the measuring circuit as to minimize the input current of the measuring circuit and achieve measurements which are closer to the actual value. Also, the PIC ADC resolution is 10-bits which gives an accuracy of 4.88mV. If you want to measure voltages less than 4.88mV accurately then you need to use an external ADC chip with higher resolution and send the data to the PIC unless you can find a PIC with a higher resolution.

If it is a school project, then the PIC is adequate because you just want to show it is working.

#### mikecy

Joined Apr 28, 2010
8
thank you all.You have been very helpful.I will give it a try..

#### mikecy

Joined Apr 28, 2010
8
Hi again.I finnaly made it.But the problems keeps going on.this is my code
Rich (BB code):
#include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=19200, xmit=PIN_C6, rcv=PIN_C7)

void main()
{
long int value;
unsigned long int value1;
int8 i;
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);

// TODO: USER CODE!!
while(TRUE){

}