Edward Cooper wrote: > that subject isn't very informative! My problem is that > I'm using the PWM output to control the rate of charge > of some batteries and I'm monitoring the current into the > batteries by measuring the voltage across a 1/2 Ohm resistor > is series with the batts, the problem is the PWM output > is controlling the current by high speed switching and > is interfering greatly with the numbers on the A2D input, > I've tried basically filtering it out using diodes and > caps but it doesn't work well and I have to use a long > median average routine from many samples to get half > decent numbers for the current flow. ...proper grounding and shielding again... Why not use STM VIPer or similar switch mode power supply regulators. Adjust them to a slightly lower voltage than needed. Let PIC measure - output voltage, - consumed current using extra transformer in series with the main transformer Let PIC regulate output by changing opto feedback It's not easy to beat VIPer(SWITCHING FREQUENCY UP TO 200KHZ) with plain PIC PWM system, especially in safety considerations when working from mains. CAREFULLY FOLLOW LAYOUT CONSIDERATIONS. As example from VIPer50 datasheet: -------------------------------------- LAYOUT CONSIDERATIONS Some simple rules insure a correct running of switching power supplies. They may be classified into two categories: - To minimise power loops: the way the switched power current must be carefully analysed and the corresponding paths must present the smallest inner loop area as possible. This avoids radiated EMC noises, conducted EMC noises by magnetic coupling, and provides a better efficiency by eliminating parasitic inductances, especially on secondary side. - To use different tracks for low level signals and power ones. The interferences due to a mixing of signal and power may result in instabilities and/or anomalous behaviour of the device in case of violent power surge (Input overvoltages,output short circuits...). In case of VIPer, these rules apply as shown on figure 22. The loops C1-T1-U1, C5-D2-T1, C7-D1-T1 must be minimised. C6 must be as close as possible from T1. The signal components C2, ISO1, C3 and C4 are using a dedicated track to be connected directly to the source of the device. --------------------------------------- Good Luck. Mike. -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body