PIC is sampling at 20 KSPS a ADC signal (i.e volage i/p) in continous mode.
In every 200ms cycle, PIC is storing the maximum value and passing it on I2C bus.
but sometime PIC is not able to capture a peak of Analog voltage i/p succesfully.
i am using a simple compare method of the read value with store value.
Can you suggest some sophisticative method to store the maximum value in every 200ms.
Example:
Code:
if ( AD.values.present.words[0] > AD.values.maximum[0])
// if the A-D value is bigger than the current maximum value
{AD.values.maximum[0] = AD.values.present.words[0];}
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
Posted: Wed Jul 18, 2007 8:50 am
That looks pretty foolproof to me. If you are really stuck you should look at the list file and see what the compiler is telling the PIC to do. Maybe you can spot an error.
It may help if you tell us your compiler version. Someone may know of a bug. _________________ The search for better is endless. Instead simply find very good and get the job done.
tom_hanks
Joined: 04 Apr 2007 Posts: 20
Posted: Wed Jul 18, 2007 9:02 am
thank you for reply..
can u suggest some other method..
Joined: 15 Nov 2005 Posts: 161 Location: Glasgow, UK
Posted: Wed Jul 18, 2007 11:30 am
Hi
Assuming your not dropping samples (your code is always waiting for the conversion to finish) then your code will return the peak value that the converter saw. But this may not be the actual peak voltage if you have not band limited the signal (low pass filtered).
Another way is to have an analogue peak detector, and read and reset that at regular intervals.
HTH
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum