This is an idea / a project.
Haven't yet even thought if it is possible with Picaxe, but still I tell what I've been thinking today...
Very often, when reading a sensitive sensor with ADC, one gets quite many "wrong readings", too.
Normal way to smoothen things is to take average of, lets say, of 50 readings.
Anyhow, if electrical disturbance is great, one gets (only) SOME readings, which differ A LOT from average readings. Therefore result from "average of 50" is not "good enough".
There IS a little better way, called "median averaging". Procedure is done like this:
1. Take some readings an stuff them to a STRING
2. Use "bubble sort" to arrange readings to ascending order
3. Take normal average of "most" readings in the middle (= drop the lowest and highest readings...)
This is a effective way of "losing" those "certainly wrong" readings, caused by electrical disturbance.
I've done this a few times in the past, but with a pc-program. Pc-Basics can handle strings... Picaxe-basic does not?
Ofcourse, sorting can be done many ways, and bubble-sort is ineffective, but the code is quite straightforward and simple... If someone knows a way in Picaxe, maybe using peek and poke to memory, to "simulate" strings, this could work.
Things to consider:
-does ineffective sort-code take "too long" (depends on application, ofcourse)
-If string-handling is done by peek/poke, it should be done into RAM, in the long run EEPROM does not like it...?
Haven't yet even thought if it is possible with Picaxe, but still I tell what I've been thinking today...
Very often, when reading a sensitive sensor with ADC, one gets quite many "wrong readings", too.
Normal way to smoothen things is to take average of, lets say, of 50 readings.
Anyhow, if electrical disturbance is great, one gets (only) SOME readings, which differ A LOT from average readings. Therefore result from "average of 50" is not "good enough".
There IS a little better way, called "median averaging". Procedure is done like this:
1. Take some readings an stuff them to a STRING
2. Use "bubble sort" to arrange readings to ascending order
3. Take normal average of "most" readings in the middle (= drop the lowest and highest readings...)
This is a effective way of "losing" those "certainly wrong" readings, caused by electrical disturbance.
I've done this a few times in the past, but with a pc-program. Pc-Basics can handle strings... Picaxe-basic does not?
Ofcourse, sorting can be done many ways, and bubble-sort is ineffective, but the code is quite straightforward and simple... If someone knows a way in Picaxe, maybe using peek and poke to memory, to "simulate" strings, this could work.
Things to consider:
-does ineffective sort-code take "too long" (depends on application, ofcourse)
-If string-handling is done by peek/poke, it should be done into RAM, in the long run EEPROM does not like it...?