PDA

View Full Version : PIC10F220 RC filter first order



thierryneuch
- 7th June 2015, 15:40
I want to make an electronic device that Measures the wind speed in Beaufort. The definition of the Beaufort scale requires the calculation of an average over a period of 10 minutes. We choose to do this using the following principle (average with forgetfulness):http://www.edaboard.com/attachments/118200d1433674021t-filtre-passe-bas2.gif (http://www.edaboard.com/attachments/118200d1433674021-filtre-passe-bas2.gif)

For economical and space reasons, we choose to realize the RC filter by numerical simulation in the microcontroller.
Power supply: 3V analog output voltage proportional to the Beaufort scale with 0 corresponding to 0V Beaufort, 3V corresponding to 9 Beaufort (it will not show values above 9 Beaufort)
Interface to the LCD module: SPI (SPIdatas and SPI clk) Wind speed encoded in 8 bits

I expected to find some help here because I have almost no idea how to program in assembly language.
I have difficulties and problems understanding the management and integration of SPI communication and problems And difficulty as the exact conversion speed => Beaufort and how to use it, and to make a sliding average

The code is highly optimized That's why I come to ask your help :fs: and knowledge. Any ideas is welcome!

Thanks

towlerg
- 7th June 2015, 20:54
I a little surprised that the Beaufort scale is averaged in the way you describe. It was originally defined by the visual effects of wind and therefore instantaneous.

When sailing, the current wind speed and the next 10 minutes are infinitely more interesting that the last 10 mins.

Usually Beaufort is given a upper and lower limits in knots or mph (or quite ridiculously m/sec).

The Beaufort Wiki entry makes no mention of averaging.

Hard to believe that the cost of a R/C filter would be prohibitive.

Sorry if that all sounds negative. How are you measuring wind speed?

George

thierryneuch
- 8th June 2015, 05:31
for the moment Is a simple (last reading + new reading)/2 average good enough

Dave
- 8th June 2015, 13:29
Try this...

FILTER CON 16 'CHANGE THIS VARIABLE TO VARY FILTER RESPONCE
PASVAR VAR WORD 'USED FOR FILTER HISTORY
INVAR VAR WORD 'INPUT VARIABLE
OUTVAR VAR WORD 'FILTERED OUTPUT VARIABLE

' ************************************************** ******************
LOWPASS: 'LOW PASS FILTER (256 = NO FILTER ACTION/ 1 = MAXIMUM FILTER ACTION)
' ************************************************** ******************
PASTVAR = (PASTVAR - (PASTVAR */ FILTER)) + INVAR
OUTVAR = PASTVAR */ FILTER 'FINAL DRIVE OUTPUT COMPUTED
RETURN