This is in PicBasic, but it works very well: For K= 1 TO 32 ADCIN 0, VOLTAGE1 volt=volt+voltage1 PAUSE 1 Next VOLT=volt/32 Regards, Anand Dhuru ----- Original Message ----- From: "stanton54" To: Sent: Wednesday, January 22, 2003 09:14 AM Subject: Re: [PIC]: averaging a/d input > Hard-code a queue. Example with 4 values: > adc4 = adc3; > adc3 = adc2; > adc2 = adc1; > adc1 = read_adc(); > adc_avg = (adc1+adc2+adc3+adc4) >> 2; > Use a power of 2 so you can shift instead > of dividing. > > Bob Japundza wrote: > > > > I am wondering what the best method is to average an > > a/d input in C. > > > > I have an a/d tied to a fuel level sender, and am > > trying to smooth the resultant value so that any quick > > fluctuations in fuel level are dampened out (tilting > > the tank, bumps, etc.) I've thought of a push/pop > > stack scheme to average but am afraid that would > > consume too much memory. I've also thought of > > sampling the a/d once a second and taking an average > > over ten seconds... > > > > Any suggestions? > > > > Thanks in advance, > > Bob > > > > __________________________________________________ > > Do you Yahoo!? > > Yahoo! Mail Plus - Powerful. Affordable. Sign up now. > > http://mailplus.yahoo.com > > > > -- > > http://www.piclist.com hint: To leave the PICList > > mailto:piclist-unsubscribe-request@mitvma.mit.edu > > -- > http://www.piclist.com hint: To leave the PICList > mailto:piclist-unsubscribe-request@mitvma.mit.edu -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads