Hello,
anyone conceived an averaging function, say: do 10 readings, average them, write 1 set of data, back to start?
Cheers,
Steffen
Hello,
anyone conceived an averaging function, say: do 10 readings, average them, write 1 set of data, back to start?
Cheers,
Steffen
Hi Steffen,
I’m not sure whether I got your question right, but as far as I understand you mainly just want to compute the average of a set of given values. I also assume that you do not want to use floating point math, so I am going to use 16 and 32 bit variables in this example:
while (1) {
// Compute average.
int32_t acc = 0;
for (i=0; i<16; i++)
acc += get_some_16_bit_reading();
int16_t avg = acc >> 4;
// Write 1 data set.
write_whatever(avg, ...);
}
Of course, instead of using 16 values and the corresponding bit-shift at the end of the code, you could also you some other value and just divide. Using powers of 2, however, allows for using an easy and fast bit-shift.
Is this what you wanted?
By now the logomatic stores every reading, just follows all the if statements once the timer is down to 0.
I want to store the average of say 16 readings every 16th reading. So it would do the first bit 15 times, then at 16 it does the last reading, averages, writes onto the SD card.
so I would have to change the write routine and every of the read routines, having troubles to find which variable is actually passed from where to where. I.e. where does it do the ADC bit, where does it put the readings for the 8 inputs into which string and when finally the string is written onto the SD card.
Ok, so you’re talking about the Logomatic. In that case you’ll probably have to adapt the firmware to your needs and (unfortunately?) also follow all the reading and writing stuff. Sorry that I couldn’t be of any help…
maybe I just put a big bracket around the reading part, run it 16 times, then write and then i = 0 and do it again.
Is there any debugger, same as, say, WinAVR?