I am using UNO. I got four sensors that I need to sample using on board ADC. I want to sample six sensors after every 20 minutes.
I am a beginner so, I do not have good idea to go about this issue. Should I go with interrupt based software? if yes, then can anyone give me some examples or guidelines to follow. Can I read every pin of the ADC individually?
The sensors are really slow analog devices and their output does not exceed 10 Hz.
The on board ADC is 10 bits with sampling frequency of 10k Samples / second. I read about UNO's sampling rate at the following link
Data rate : Sampling rate x Number of channels x ADC resolution = 10k x 6 x 10 = 600kbits/sec.
I do not know what will be ADC switching speed at which the ADC will go through the six channels. Any suggestions here. I meant how much time the microcontroller will take to move from one channel to another. Does the UNO microcontroller has the ability to handle 600kbits? Where would it store it? etc. Any more suggestions and ideas are welcome!
Data rate : Sampling rate x Number of channels x ADC resolution = 10k x 6 x 10 = 600kbits/sec.
You can't sample all the pins at that rate. You can sample ONE pin at that rate. When you switch pins, the ADC needs time to deal with the new input. Typically, one would read the new pin twice, and throw away the first value. That will cut the sample rate by a factor of 12 if you are reading all 6 pins.
Does the UNO microcontroller has the ability to handle 600kbits? Where would it store it?
It can't store that much data anywhere. The only way to get the sample rate quoted is to read one pin and do nothing with the data.
PaulS:
To sample 6 sensors over 20 minutes? No!
Yes.
You can't sample all the pins at that rate. You can sample ONE pin at that rate. When you switch pins, the ADC needs time to deal with the new input. Typically, one would read the new pin twice, and throw away the first value. That will cut the sample rate by a factor of 12 if you are reading all 6 pins.
It can't store that much data anywhere. The only way to get the sample rate quoted is to read one pin and do nothing with the data.
I do want to sample one pin at one time using 10kSamples/ sec then I want to move to the next ADC channel and then next. What is that switching time from one channel to another?
I need to collect the data from all the available channels and send it out every hour. I am confused how should I do this kind of calculations. I know that I am collecting 600kbits / sec but how can I stretch this calculation for every hour mathematically.
I guess I need a microcontroller with bigger RAM. How much bigger RAM should I go with? Should I go with microcontroller available on the MEGA 5650 board?
Should I use a Timer to generate an interrupt every hour to collect the data from each of the six pins> Can you advise how will that work or how should I design it?
Delta_G:
No need for an interrupt for something that slow. Just look at millis. Use the technique from the Blink Without Delay example to see when an hour has passed.
I was hoping to do the interrupt to learn more about microcontroller programming.
Robin2: @Erica1989, please explain what you are trying to achieve without reference to how that might be done.
I cannot conceive of why you mention "10k Samples / second" when you only need to read something every 20 minutes.
...R
As I said in first post that I am a beginner and do not know much about embedded programming. So, 600kbits is a good number if I read all the sensors in one second. But I want to read the sensors every 20 minutes. So. 20 minutes is equal to 1200 seconds
so, now the data rate will be equal to 6 x 10,000 x 1200 = 72Mbits /sec. That can not be right!
I want to sample six sensors ( every 20 minutes) , four temperature sensors and two light sensors.
I want to sample all of them within same second.
I am sorry for asking such basic questions. I will appreciate help.
This is what I am thinking. I need to sample six sensors after every 20 minutes.
So, what does it mean that 10bits + 10bits + 10bits + 10bits + 10bits + 10bits = 60 bits every 20 minutes.
Is it good idea to program the timer to trigger the interrupt every 20 minutes?
So, the data rate would be 0.05 bits /sec. I am so confused. I am also confused about taking into account the switching time of the ADC among all six sensors. Please help!
Delta_G:
That makes a lot more sense than thinking that reading once every 20 minutes would equal the maximum sample rate. Since Arduino doesn't have a 10bit type the analogRead values are going to come in as ints with the top 6 bits 0s. So really you're getting 12 bytes every 20 minutes.
That's already been answered at least once.
Why are you so worried about the sample rate? The arduino can take 10,000 analog readings in one second. If you're only taking 6 every 20 minutes I don't think the switching time is going to have much effect on you will it? You'll be able to get your 6 readings in under a millisecond or maybe 2 and then do nothing for 20 minutes. Is that not fast enough?
PS: Don't bump your own thread without adding some extra information of some kind. That's pretty frowned on around here. If folks aren't responding fast enough for you then maybe it's because your question really isn't making much sense.
The issue is not about whether the microcontroller is fast or not. Its about my understanding. I can not understand how to calculate the data rate. I am very new to embedded world. how much is the data rate if I sample six sensor individually after every 20 minutes? Can you help me to calculate it? Its simple math but I can not do it.
Delta_G:
You're actually sampling each sensor once per every 20 minutes. So the sampling rate of your sensors is 5 / hour. Divide by 60 to get 0.0833 samples / minute. Divide by 60 again and that's 0.0013889 samples per second.
When you say sampling rate you have to say what you mean. Do you mean how fast the uc is producing bits of data? That's one rate. How often you read the sensor? That's another rate.
Either way, you calculate it as samples (of whatever you want the rate of) divided by time.
I am interested in both rates
a) how fast the microcontroller is producing bits of data and
b) how often the data is read from the sensor.
Am I correct to say that for case a) number of channels x resolution x sampling rate
6 x 10 x 10k = 600kbits /sec
Am I correct to say that for case b) number of channels x resolution x sampling rate
(6 x 10) / 3600 secs = 0.016 samples secs
So, now what data rate should I consider to design the software.
I am confused that If I choose case a then ATMEAG328P might not support it because it does not have big enough RAM. It has 512 KBytes of RAM and 256KBytes of EEPROM.
But then when I look at the problem from the case b perspective then it looks like the RAM can support this data rate and this ATMEAG328P can pull it off. I do not know what is correct way to go.
I am confused that If I choose case a then ATMEAG328P might not support it because it does not have big enough RAM. It has 512 KBytes of RAM and 256KBytes of EEPROM.
Those numbers are way off. I think you are misreading something.
'328P has 2K bytes of SRAM (2048 bytes) and 1K bytes of EEPROM (1024 bytes).