Hi Edward, This is my approach. Start a clock counter with the first pulse. Start a second counter, which counts 5 pulses. For each pulse counted do these tasks: 1. -Add the clock counter value to a register (2 bytes). 2. -Refresh the clock counter After 5 pulses you will have 4 intervals. When the fifth pulse is done, you have time to compute some operations: 1. -Add the clock counter value to a register 2. -Refresh the clock counters and pulse counter 3. -Divide the clock counter saved by 4 (this will take 6 cycles) 4. -Save the two bytes result on epprom. Continue the loop until what you want. How about that? Regards, Dennis Crawley P.s.: 0 to 4 degrees in the morning, over Buenos Aires. ----- Original Message ----- From: "Edward Cooper" To: Sent: Monday, July 14, 2003 3:00 PM Subject: [PIC]: Averaging values > Hi I'm looking for a little help here. > > I've built a device that records pulses, it saves the gap between the > pulses in milliseconds into a 16 bit register (so 65.5 secs max gap) > Now the actual gap will never be that big. > > I want to recall these values from eeprom at a later date and display > 30 second averages, ie 00-30secs = 12.1secs, 30-60secs = 9.2secs. > > I need to store the data as the interval between gaps as it needs to be > downloaded to a PC later. What I really need help/ideas with is how to > process this data into 30sec of gap averages, I'm finding it really > confusing. > > Below is a little drawing of what I'm trying to do: > > .. [ [ [ [ [... > .. GAP6 [ GAP7 [ GAP8 [ GAP9 [ GAP10 [... > ..7 SECS[12 SECS [14 SECS [ 11 SECS[ 9 SECS[... > > 0-30secs ][ 30 - 60 SECONDS AVERAGE ][ 60-90secs > > Now the issue is that the gap 7 and 10 need to be taken into account > for the proportion they are inside the 30 second average (30-60). I'm > sure there is a simple way to do this, however the only way I have > found involves the following > 14211 x 14211/30000 > > now 14211/30000 gives 0 not the 0.4737 i need > > Sorry I should probably just come back to this its too hot here, and > I'm sure this is going to make little sense. > > Ed > > -- > http://www.piclist.com#nomail Going offline? Don't AutoReply us! > email listserv@mitvma.mit.edu with SET PICList DIGEST in the body > > > -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu