Hi Roman. The load is not inductive, but the sense resistor has been placed incircuit so that it is always measuring load current. Using a pair of RC filters as Olin has suggested between the amplified sense signal and the PIC's A/D provides me with a good waveform for averaging because I am not in fact reading hard on and hard off PWM signals, but the rising and falling slopes of the exponential waveform segments. Rgs Ian. -----Original Message----- From: pic microcontroller discussion list [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Roman Black Sent: Wednesday, 5 March 2003 6:18 pm To: PICLIST@MITVMA.MIT.EDU Subject: Re: [PIC]: PWM output current sensing Hi Ian, are you measuring PWM current in an inductive load (that has flyback diode)?? If so you *can't* average your on/off pwm current, you need to put the sense resistor in circuit with the inductor+diode so it always measures load current (which remains constant within a few percent). OR you can measure the current during PWM on, this will be close to the load average current and you can maybe deduct a few percent for flyback period current droop etc. -Roman Ian McLean wrote: > > I tried a simple passive RC filter on the A/D input in simulation - this > changes the square wave to a triangular wave (as I remember it should from > analog electronics). I guess this would in itself improve the averages > because of the rising and falling slopes of the triangular wave being hit > more times than the low (or high) state. I only need to sample the current > about once a second. > -----Original Message----- > > An interesting observation arose for me just now whilst cutting the > > code on an f877 to do the A/D for current sensing from a device being > > controlled from a PWM voltage source. > > > > My PWM is at 5kHz. I discovered that the current readings were not > > averages, -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details. -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.