# 2 khz sampling rate per channel-Beginner to arduino

I am a intern in a huge company and they gave me a task to solve. i am a beginner to micro controller, the task they gave me might be really easy to people in the forum. the task they gave me was to take analog date from a EMG sensor at a sampling rate of 2 khz per channel. there is 32 channels in total. is there a arduino that does this and if so can you explain how? i am a need of help

an Arduino can make between 8000 and 9000 analog samples per second @ 10 bit. And then there is no time left to send them to a PC or to process them.

32 channels @ 2KHz => 64000 samples per second, that is imho well beyond the Arduino line of hardware.

But as Arduino is low cost esp if you build it yourself you could give every (two) channel(s) an Arduino
is that an option?

[update]
In this mail I meant specific the UNO 16 Mhz

@aquafresh How many bits per sample do you need?

There are faster Arduinos. The Due and the (much less expensive) Teensy 3.1 are 32 bit Cortex ARM processor based running at 84MHz and 72MHz, with 12 bit ADCs. They are 3.3V boards, so level shifters must be used to connect to 5V peripherals. Handily, SD cards and I2C use 3.3V. For running LCD screens and other 5V stuff, resistive voltage dividers can be used to get signals back to the Teensy 3 or Due, and a CMOS buffer like the 4050 can be used to convert 3.3V logic coming out to 5V logic.

\$20 for the Teensy 3.1: http://www.pjrc.com/teensy/index.html

\$50 for the Arduino Due: http://arduino.cc/en/Main/ArduinoBoardDue

None has the number of analog inputs you need. However, they all use analog multiplexers to run multiple analog inputs to one single ADC. The Teensy 3.1 and the Due can do analog sampling much faster than 16MHz 8 bit Arduinos. So you could just add an analog multiplexer with at least 32 inputs on it, or two with 16 inputs each.

74HC4067 is a 2 to 6V analog multiplexer, 16 channel with !Enable pin. http://tronixstuff.com/2013/08/05/part-review-74hc4067-16-channel-analog-multiplexerdemultiplexer/

If you want 10 bits of data, you need better than the 10 bit ADC in a garden variety Arduino. Noise, quantization errors, distortion, etc. cause the lowest bit or two to become meaningless noise. There is something called ENOB or Effective Number Of Bits, where when you discount the bits that are merely noise, you end up with, for instance, 8.5 ENOB from a 10 bit ADC. Stock Arduino boards do nothing to reduce the noise, no RC decoupling network to supply power to the ADC section as recommended by Atmel.

So you'll need at least 12 bits of ADC, anyway. The above ARM based boards can do that, and can do the conversion much faster.

http://www.analog.com/static/imported-files/tutorials/MT-003.pdf

http://www.analog.com/library/analogdialogue/archives/47-02/RAQ_90.html

I'd like to ask for a clarification: Do you mean that 32 channels must be sampled, 2000 times per second each (500uS per channel)?

Or do you mean that conversions must happen 2000 times per second, in which case each channel is sampled 2000/32 or 62.5 times per second (16mS per channel)?

Is the data sent back continuously to a computer somewhere, or is it collected and stored, say on an SD card?

The Teensy 3.1 (not the 3.0) has 21 analog inputs, and is 5V logic tolerant. At just under \$20, I'd probably just use two of these to get the required number of analog inputs.

Oh, and if you use two Teensy 3.1 to get the required number of analog inputs, you don't have to worry about external multiplexer resistance, distortion, and voltage ranges.

at a sampling rate of 2 khz per channel.

is what the original post said.

That would be a conversion rate of 64,000 samples per second. I don't think an 8 bit Arduino is going to be able to do that.

robtillaart: @aquafresh How many bits per sample do you need?

how can i determine the bits, i might be able to give you an answer. Like i said i am very new to this.

What is the range of the sensors, and the desired resolution?

polymorph: What is the range of the sensors, and the desired resolution?

The range of the sensor would be from -+3V and the resolution does not have to be great but "okay". It has to be wireless so i was planing to use two micro-controller one that will get the data from each sensor and send it to the other one that will receive that data (which is connected to the computer). i was looking into the mux shield 2 from sparkfun to connect all sensors to the micro controller but do not know if this will work. this is why i need help to know how to go about this. if there is another micro-controller that i can use it will be fine as long as it is 2khz sampling rate per channel. money is not an issue as long as the micro controller is small this is why i would like to go with the arduino. thank you for all the help

The range of the sensor would be from -+3V and the resolution does not have to be great but "okay".

No, you need to give a number - "okay" could mean anything. 2 bits? 12 bits? what?

You mention negative voltages - is the sensor output differential or single ended?

However, this is an unusable speed.

The analogRead command will not work correctly if a pin has been previously set to an output, so if this is the case, set it back to an input before using analogRead. Similarly if the pin has been set to HIGH as an output, the pullup resistor will be set, when switched back to an input. The Atmega datasheet also cautions against switching analog pins in close temporal proximity to making A/D readings (analogRead) on other analog pins. This can cause electrical noise and introduce jitter in the analog system. It may be desirable, after manipulating analog pins (in digital mode), to add a short delay before using analogRead() to read other analog pins.

I reiterate my recommendation to use two Teensy 3.1 boards. A standard Arduino just isn't fast enough. A MUX board won't help.

polymorph: There are faster Arduinos. The Due and the (much less expensive) Teensy 3.1 are 32 bit Cortex ARM processor based running at 84MHz and 72MHz, with 12 bit ADCs. They are 3.3V boards, so level shifters must be used to connect to 5V peripherals. Handily, SD cards and I2C use 3.3V. For running LCD screens and other 5V stuff, resistive voltage dividers can be used to get signals back to the Teensy 3 or Due, and a CMOS buffer like the 4050 can be used to convert 3.3V logic coming out to 5V logic.

\$20 for the Teensy 3.1: http://www.pjrc.com/teensy/index.html

\$50 for the Arduino Due: http://arduino.cc/en/Main/ArduinoBoardDue

None has the number of analog inputs you need. However, they all use analog multiplexers to run multiple analog inputs to one single ADC. The Teensy 3.1 and the Due can do analog sampling much faster than 16MHz 8 bit Arduinos. So you could just add an analog multiplexer with at least 32 inputs on it, or two with 16 inputs each.

74HC4067 is a 2 to 6V analog multiplexer, 16 channel with !Enable pin. http://tronixstuff.com/2013/08/05/part-review-74hc4067-16-channel-analog-multiplexerdemultiplexer/

If you want 10 bits of data, you need better than the 10 bit ADC in a garden variety Arduino. Noise, quantization errors, distortion, etc. cause the lowest bit or two to become meaningless noise. There is something called ENOB or Effective Number Of Bits, where when you discount the bits that are merely noise, you end up with, for instance, 8.5 ENOB from a 10 bit ADC. Stock Arduino boards do nothing to reduce the noise, no RC decoupling network to supply power to the ADC section as recommended by Atmel.

So you'll need at least 12 bits of ADC, anyway. The above ARM based boards can do that, and can do the conversion much faster.

http://www.analog.com/static/imported-files/tutorials/MT-003.pdf

http://www.analog.com/library/analogdialogue/archives/47-02/RAQ_90.html

I'd like to ask for a clarification: Do you mean that 32 channels must be sampled, 2000 times per second each (500uS per channel)?

Or do you mean that conversions must happen 2000 times per second, in which case each channel is sampled 2000/32 or 62.5 times per second (16mS per channel)?

Is the data sent back continuously to a computer somewhere, or is it collected and stored, say on an SD card?

The Teensy 3.1 (not the 3.0) has 21 analog inputs, and is 5V logic tolerant. At just under \$20, I'd probably just use two of these to get the required number of analog inputs.

i like your idea of using two Teensy 3.1, but how will i synchronize them together? Is there a tutorial link that you can post so i can have an idea of how to use it for my application (also making it wireless)? thanks a lot for your ideas and time

To get them in sync you could use a small external timer and have it connected to a digital pin on each of the teensy boards which is set up to use that pin as an external interrupt :)