BasicMicro - Forums

www.basicmicro.com
It is currently Sun May 20, 2012 10:57 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: datalogger with Atom 40
PostPosted: Fri Aug 29, 2008 1:43 am 
Dear friends,
I want to log values from 8 channels, and all the values, logged in 1 second of sampling rate, must be saved into an array of floating type.
The question is: can I save all the 600 samples for each channel and for these 600 values can I operate with mathematical functions such as average, ....?
What is the function to averaging 600 samples in ATOM 40?
:shock:
Regards


Top
  
 
 Post subject: Re: datalogger with Atom 40
PostPosted: Fri Aug 29, 2008 10:44 am 
Offline
Master

Joined: Sun Aug 17, 2008 5:26 pm
Posts: 798
Location: CA bay Area
Hi. The answer is: yes, with limitations. Since a floating value uses 4 bytes, and your collecting 600 samples from each of eight channels, you will need to store 19,200 bytes. There isn't enough storage for all this on the Atom40. However, you could use an offboard EEPROM, like the AT25256-10PC-2.7. This will hold 32kbytes of data. It talks to the processor using SPI, which can be done on the Atom using the SHIFTIN/SHIFTOUT commands. Read the manual on this, I believe they give an example.

As for averaging: collect the 600 samples, add them all up and divide the result by 600. Simple. Yes? No?
You could keep a running average and use an array to track trends. This may save you from having to store all 600 samples. Create a variable to store the average, say, Avg_Var. Collect the first sample and store it in Avg_Var. After this, you collect a sample, add it to Avg_Var, divide by two, and store the result back to Avg_Var. At certain set points, say every 50th sample, you store the latest Avg_Var to an array, maybe storing the first sample as array(0), giving you a starting point for the trends. At the end you have 13 values in the array: the first, #1 (array(0)), sample# 50 (array(1)), number 100 (array(2)), etc., up to the last sample, number 600 (array(12). If the array is all you keep, you no longer need large storage, so can stay inside the Atom40 and leave off the EEPROM. If you MUST have all 600 samples, you need the EEPROM. The Atom40's internal EEPROM now determines the array size, thus the number of samples you can keep for later comparison.

So, it can be done, but you're limited by the available storage on the Atom40.

Later!
kenjj


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO