PDA

View Full Version : can't solve this voltage measurement problem



Christopher4187
- 11th October 2009, 15:45
I have a 16F688 that is measuring voltage from a battery (and battery charger from a forklift battery) that closes a relay when it reaches a voltage. Everything works OK (there are some additional functions) but there is way too much noise on the input to the PIC pin from the battery charger.

The input comes into the PIC through a voltage divider, .1uf cap and a half-wave rectifier. I've tried many things but I cannot solve this problem. The AC ripple on the DC is about 5VAC and I have little experience with solving AC ripple problems. The chargers are old and giving me huge headaches!!!

What else can I do to solve this problem?

Jerson
- 11th October 2009, 17:00
You haven't mentioned the frequency of the ripple. Is it AC mains? If it is, 0.1uF is too small a capacitor to smooth that ripple. I would say, a safe starting value should be in the 10s of uF. You also mention having a half wave rectifier prior to the measurement, so, you should be able to smooth it real good if you increase that capacitor.

Can you post a schematic? It might help understand the problem better.

aratti
- 11th October 2009, 17:06
The AC ripple on the DC is about 5VAC and I have little experience with solving AC ripple problems.
Christopher4187 the attached ripple chart could help you in choosing the right capacitor for your specific problem. (Mind the chart is for 60 Hz, for a different frequency you have to adjust it.).

Al.

Christopher4187
- 11th October 2009, 17:20
Jerson,

I've attached a quick drawing of the circuit. The problem is, I don't have the piece of equipment with me but if I remember correctly, the frequency is 500Hz but it is very erratic. Not only that, not all pieces of equipment have this problem because some are new chargers and some are old. It's not AC mains, it's the output of the battery charger.

Jerson
- 11th October 2009, 17:39
Try something like this

Christopher4187
- 11th October 2009, 18:27
Thanks Jerson. I realized I drew it wrong because I had the diode on the input to the voltage divider. If not, my measurement would be WAYYYY off!!! I'll try the increased cap size. I didn't put it at the input to the voltage divider because the size would have to be much bigger. How important is it to have the cap before the voltage divider instead of after?

Charles Linquis
- 11th October 2009, 18:44
It also wouldn't hurt to take an average. Since 60 Hz has a period of 16.66 milliseconds, and an A/D conversion takes about 30uSecs, you could average 16 samples (a full cycle) something like this:




ADCAvg = 0 ; Clear the variable
For X = 1 to 16
ADCIN,x, ADCresult
ADCAvg = ADCAvg + ADCresult
Pauseus 1000
Next X
ADCAvg = ADCAvg >> 4 ; divide by 16



This should do a pretty good job of smoothing the result.

Christopher4187
- 11th October 2009, 18:46
I've tried all kinds of software routines but nothing seemed to help. I think the AC ripple is not a normal sine wave, maybe that's why.

Melanie
- 11th October 2009, 20:38
Put a 1uF Electrolytic... or even a 10uF... across the 0.1 Capacitor.

It's a Battery Charging circuit - you don't need instantaneous results. If your filters time period is a few hundred mS then goodbye to any 500Hz noise! Make sure you haven't got any noise on your 5v line - that could be throwing +VRef as well.

flithecut
- 13th October 2009, 01:25
I accept: it is hurt to take an average. Since 60 Hz has a period of 16.66 milliseconds, and an A/D conversion takes about 30uSecs.

Christopher4187
- 26th October 2009, 16:26
Would this work or can I get rid of the .1uF cap? What type of cap (material) should I use?

Also, should I put a 1uF cap in the input to the PIC (it's also my vref voltage)? As Melanie said, this could be causing me problems too.

Pic_User
- 26th October 2009, 18:47
Would this work or can I get rid of the .1uF cap? What type of cap (material) should I use?

Also, should I put a 1uF cap in the input to the PIC (it's also my vref voltage)? As Melanie said, this could be causing me problems too.

Hi Christopher,

That first circuit you attached would send 50 Volts to the PIC!

This is more like a voltage divider.
<IMG SRC=" http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3761&stc=1&d=1256582713">

-Adam-

Christopher4187
- 7th November 2009, 23:13
I've decided to put the 10uF cap after the voltage divider so the voltage should not be higher than 5V. Can someone just check and see if this capacitor would be sufficient for my issue please?

It's digikey number 445-2863-ND

Thanks in advance!

timmers
- 8th November 2009, 20:10
You're all close, but not quite on the mark. Putting the diode in will rectify the noise, and all you will be measuring is peak noise.

PIC_USER was close, but if you removed D1, C2, R3 and R4 then you will be creating a potential divider with a low pass filter, and be measuring the average voltage. I would however add a zener diode where R3 is to prevent any overvoltage problems, say a 5v6.

Values of R1 / R2 would depend on how high you wish to make the impedance, but to get a decent RC timeconstant I would be looking around 68k for the top and 5k6 for the bottom, works out as around 3.8volts into the A2D pin from 50v.
This would filter off most of the noise above 15hz with a 1uF capacitor.

Other option is to A2D the full bandwidth and do some averaging in software and calculate the RMS value. But thats not easy and is heavy on register resources.

Hope this helps.
Timmers.