You can read 12-bit result via a script but there's no big point in doing that. Even though theoretical resolution is better the resulting value won't be stable due to how the measurement works. The better approach is to do over-sampling by averaging the resulting values over a specific period of time.
17.05.2016, 08:10 (This post was last modified: 17.05.2016, 08:13 by gjniewenhuijse.)
(17.05.2016, 08:02)admin Wrote: You can read 12-bit result via a script but there's no big point in doing that. Even though theoretical resolution is better the resulting value won't be stable due to how the measurement works. The better approach is to do over-sampling by averaging the resulting values over a specific period of time.
Oke, but i like to have my values with 0,1 precision.
With a arduino and the same type sensor i can do this (theoretical ), but connected to the LM4 it gives strange results: see attached picture.
(17.05.2016, 08:02)admin Wrote: You can read 12-bit result via a script but there's no big point in doing that. Even though theoretical resolution is better the resulting value won't be stable due to how the measurement works. The better approach is to do over-sampling by averaging the resulting values over a specific period of time.
Oke, but i like to have my values with 0,1 precision.
With a arduino and the same type sensor i can do this, but connected to the LM4 it gives strange results: see attached picture.
You can add an event-based script which repeat this value with custom precision or you can use custom values for visualisation if this is only for visualisation purposes.
You don't need to change the precision, reading "temperature" property will read the 12-bit value, by default LM uses 10-bit value ("temperature10" property).
(17.05.2016, 08:45)admin Wrote: You don't need to change the precision, reading "temperature" property will read the 12-bit value, by default LM uses 10-bit value ("temperature10" property).
17.05.2016, 11:43 (This post was last modified: 17.05.2016, 11:46 by gjniewenhuijse.)
something like this?
resident script every 60 seconds:
Code:
1234567891011
-- better to save the last 5 readings and avg them and then write to busrequire('ow')
require('user.nit_measurements')
-- second argument temperature10 (10-bit value)-- third argument will force a new conversionreadValue = ow.readfile('28.690E0A070000', 'temperature', true)
-- measure last 5 readingsmValue = measValue (5, readValue)
log (round(mValue,1))
Here's a function you can use to calculate the average, this version will keep last count values and will returnt the average for every insert:
Code:
12345678910111213141516171819
functionavg(store, count, value)
localsum = 0-- add new value as first (newest) store elementtable.insert(store, 1, value)
-- remove old elements, until store size is correctwhile #store > countdotable.remove(store)
end-- calucate value sumfor_, valueinipairs(store) dosum = sum + valueend-- get average valuereturnsum / #storeend