Post a new topicPost a reply Page 1 of 1   [ 6 posts ]
Author Message
 Post subject: Clock frequency configuration for waspmotes
PostPosted: Thu Mar 29, 2012 1:56 am 

Joined: Wed Oct 05, 2011 12:05 am
Posts: 60
Hi,

I was reading the Atmega1281 datasheet and came across clock configuration for the MCU. Apparently, the CKSEL3:0 fuses are used to configure the clock sources that operate the chip. From what I understand, it is not possible to modify these as they are fused. Is this correct?

The Waspmote system clock operates at 8 MHz (125 ns clock cycle period) and is not prescaled. Also, all the other internal clocks such as the ADC, I/O and the CPU are synchronised to this system clock and can be prescaled if desired. Is my understanding correct?

I just need to do some ADC capturing based and I want to make sure that my timing references are calculated correctly.

Regards...


Top
 Profile  
 
 Post subject: Re: Clock frequency configuration for waspmotes
PostPosted: Thu Mar 29, 2012 1:36 pm 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7508
Dear Cryptoman,

First, take into account that a single sample of the ADC does not take one clock cycle, but more.

Also, you should wonder if your really need to sample at very high speeds. Most of the parameters in the nature does not vary in a quick way, so the normal thing is to sample one time each 15 minutes.

We did some tests and find out that Waspmote can sample rather fast, but the problem is how to handle such a big amount of data. I mean the limitating speed is grabbing the data read by the ADC.

We did a script that sample data with the ADC, stores the samples in a vector and writes the vector in the SD (the EEPROM would be filled to fast, and the XBee or USB just can handle really high speed). With this script, the max sample rate was around 4 KHz. The limiting time was, as we said, the SD writting time. Probably tou can discard most of the samples you get (oversampling) so you can get better rates.

If you need time references you can use the millis() or microseconds() functions. You can take the time before and after executing one function and you get the execution time by substrating.

Best regards


Top
 Profile  
 
 Post subject: Re: Clock frequency configuration for waspmotes
PostPosted: Thu Mar 29, 2012 2:26 pm 

Joined: Wed Oct 05, 2011 12:05 am
Posts: 60
Hi Libelium,

Thank you for the informative message. You have literally written what I was planning to do in my mind: i.e. sample ADC and write the results to the SD card. You are absolutely right in the ADC latencies in practice. Also, RS232 transfer does become the brick wall as one needs to sample at high rates (such as what I am interested in). Transfer speeds are simply too slow and cannot keep up. I was hoping that the internal SD card storage would be faster than the RS232 and according to what you are saying, according to my calculations, it is about twice as fast.

In the context of typical Waspmote applications even the 1 Hz sampling rate is more than enough. I totlly agree. However, I was trying to find new ways to make use of this wonderfully flexible Waspmote platform in my new projects. Currently, I am experimenting with a concept for a new project where I need a sample rate of about 20 KHz.

In one of my previous posts, (viewtopic.php?f=14&t=7753) I mentioned my current sampling rate to be at 2 kHz. That works well for most applications. According to the information you provided, the best I can do is to double this figure to 4 kHz, which is an improvement but still it's a long way off my ideal target of 20 kHz. Therefore, I think I will need to scratch my head for a bit longer to come up with a practical alternative :) (I actually have one alternative that may work in mind but I will provide an update if I manage to get it working. I am sure most waspmote fans will be interested in the results !)

In the meantime, doubling the sampling frequency will be worth doing as it will provide a more accurate information on the signal I am trying to capture.

Once again thank you for your prompt and extremely useful response.

Regards...


Top
 Profile  
 
 Post subject: Re: Clock frequency configuration for waspmotes
PostPosted: Tue Apr 03, 2012 4:25 pm 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7508
Hello Cryptoman,

Your comments are very kind.

In particular, our experiment was to read 1024 samples from an analog pin (with the ADC), storing the samples in an int's vector, then transform them to chars, and finally write them in the SD card. The sampling rate was 4+ KHz.

Probably there are other ways to improve the overall speed by taking different size vectors or transforming the data other way. Or coding in low-level language, more effective, writing code for the AVR micro-controller directly.

Please keep us and the Community aware of your progress with Waspmote.

Best regards


Top
 Profile  
 
 Post subject: Re: Clock frequency configuration for waspmotes
PostPosted: Fri Apr 06, 2012 3:48 am 

Joined: Wed Oct 05, 2011 12:05 am
Posts: 60
According to my observations, achieving 4+ kHz of sampling speed is very good for Waspmote. I could not manage to go beyond 3.5 kHz of sampling speed.

I even attempted to configure two Waspmotes so that one could sample the signal while the other was dumping data to the SD card and then the roles would be switched. This culd potentially give ma a good buffer for acceptable data dump latencies. In my tests, I also configured a third Arduino board as the clock generator to keep the two Waspmotes in sync while performing the sampling. However, the limitation with this approach is the slow writing speeds to the SD card. The sampling speed is pretty satisfactory (I could get ADC sampling speeds between 8 - 10 kHz). However, when I tried to dump the samples over the serial port or to write them to the SD card, the bandwidth dramatically drops.

I think having an external SDRAM on waspmotes with 1-2 MBytes would make the platform very versatile for sampling and data capturing at high speeds. Then the data storage speed would not be a problem at all. I will be exploring this external SDRAM option when I have some time to spare.

I managed to sort out my problem using another Arduino platform which allows me to sample at 20 kHz, which is what I needed. With this alternative, I was also able to push the UART transmission up to 921 kbaud, which really helped. It's a shame that we cannot push the waspmote speeds above 38.4 kbaud. That would also reduce the latency in transferring data out of the MCU.


Top
 Profile  
 
 Post subject: Re: Clock frequency configuration for waspmotes
PostPosted: Wed Apr 11, 2012 4:24 pm 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7508
Thank you very much for sharing your experiments.

Yes, the external SRAM is a very good point, we will insert that in the "wish list" of our clients.

Best !!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 6 posts ]


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

Search for:
cron


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Libelium theme based on 610nm Style by Daniel St. Jules of http://www.gamexe.net


© Libelium Comunicaciones Distribuidas S.L. | Terms of use