Hi J,That looks right now !
Dorset air pressure 1025mb.
mb = Pa / 100
There is formula for height based on air pressure.
I will look for it.
Hi e,hi C,
You need a ring buffer for your averaging.
Be aware of the size of a 10 reading Sum, does not exceed the LONG or SINGLE type.
E
You can specify oversampling / filtering in control register 0XF4.Hi,
I've looked at the settings, and I think I have the best to suit me, but I'm getting readings that vary XXXXX0 to 1 ish.
How can I make an average of 10 readings, by adding the new reading on each LOOP, dividing by 10, subtracting one reading, and so on?
C.
Hi J,You can specify oversampling / filtering in control register 0XF4.
It can reduce noise in pressure to about 0.2 Pa ~ about 2cm in height.
Do you need absolute height or change in height?
I found a formula for height vs. pressure and temperature:
h = 29.26 × T × ln ( P0 / P )
T is temperature in kelvins, P0 pressure at ground level.
For example at T=22 C ( 295.15 K )
h~8636 × ln (P0 / P )
and 12 Pa change is about 1m.
Hi E,hi C,
This is demo play Basic of the buffer, use the Sim and PORTA.0 ADC to vary the test value.
I have used two Proc' to make it easier to follow.
NOTE: the latency [ delay] in getting the final Average result;
For a 10 long array its 10 readings.!
Ask if you have problem.
E
'sum all 10 values of the ring bfr
For x = 0 To 9
sum = sum + mybfr(x)
Next x
average = sum / 10
Hi J,You have as buffer index and buffer value the same variable = pr ( word ) and pressure = pr ( single ).
Does'nt compiler give error messages?
In the basic program ( msg#486 ) the buffer size is 9, should be 10, index 0- 9eric
I hope this doesn't pull the thread OT, but I do not quite see what you are doing in Post #486:
View attachment 110718
The first value (68) is easy to get. With some crazy assumptions, I get the next value. But I cannot get the third value. Does it ever settle to 682?
My first impression from your code was a simple moving average (FIR):
But there seems more to it than that. My main reference for the math is this: http://www.analog.com/media/en/training-seminars/design-handbooks/MixedSignal_Sect6.pdf Specifically, I am referencing Figure 6.8 in that link:Code:'sum all 10 values of the ring bfr For x = 0 To 9 sum = sum + mybfr(x) Next x average = sum / 10
View attachment 110719
Can you explain, perhaps by a worked example, how you get the highlighted value? Also, why it doesn't seem to settle on 682?
Regards, John
Hi J2,eric
I hope this doesn't pull the thread OT, but I do not quite see what you are doing in Post #486:
View attachment 110718
The first value (68) is easy to get. With some crazy assumptions, I get the next value. But I cannot get the third value. Does it ever settle to 682?
My first impression from your code was a simple moving average (FIR):
But there seems more to it than that. My main reference for the math is this: http://www.analog.com/media/en/training-seminars/design-handbooks/MixedSignal_Sect6.pdf Specifically, I am referencing Figure 6.8 in that link:Code:'sum all 10 values of the ring bfr For x = 0 To 9 sum = sum + mybfr(x) Next x average = sum / 10
View attachment 110719
Can you explain, perhaps by a worked example, how you get the highlighted value? Also, why it doesn't seem to settle on 682?
Regards, John
It is normal, that they jump a bit.Hi J2,
I'm guessing that when E, simulated these numbers, he set the INPUT and watched the result. On the PCB the INPUT is changing all of the time, so I assume that eventually, the result would show 682 using the SIM, but not on the PCB.
The D/S strongly suggests that 'Burst READ' is used. This is to avoid READs of different columns happening as one of them rolls over, so between 09 and 10 could READ 19. or 190 with a different column.
Is this a possible reason that the READings jump about a bit?
C.