Increasing the sample rate of the arduino

Hi,

I am having trouble to increase the ADC sample rate of the Arduino for an accurate reading on the serial monitor. Can someone please help me on that?

So what are you currently doing?

analogRead() does 8k samples per second why do you need more?

Mark

i trying to have an accurate reading for my infrared sensor sensing vibrations. so far i am not getting more than 200 samples a sec.

Post your code so we can see why its so slow, but printing to the serial monitor slows things down a hell of a lot.

M.....

I am using a shield called Ard-LTC1867. is there any other ways for me to gather the readings without slowing the process? The codes below is what i am currently using right now.

#include <SPI.h>

/*************************************************************************
Title: ARD-LTC186X Library Example Arduino Sketch
Authors: Nathan D. Holmes maverick@drgw.net
File: $Id: $
License: GNU General Public License v3

LICENSE:
Copyright (C) 2014 Nathan D. Holmes & Michael D. Petersen

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

*************************************************************************/

#include <Wire.h>
#include <Ard1863.h>

#define IR_LED_PIN 2

Ard186x ard186xboard1;

byte confChan=0;

int i = 1;

void setup() {

pinMode(IR_LED_PIN, OUTPUT);
byte retval = 0;

// initialize serial communications at 9600 bps:
Serial.begin(9600);

// Wire.begin();
SPI.begin();
ard186xboard1.begin(DEVICE_LTC1867, ARD186X_EEP_ADDR_ZZ);
ard186xboard1.ltc186xReadBipolarAndChangeChannel(LTC186X_CHAN_SINGLE_0P, 1);

Serial.print(“eeprom mac = [”);
Serial.print(ard186xboard1.eui48Get());
Serial.print("]\n");

Serial.print(" write 42 to eeprom[0] “);
retval = ard186xboard1.eepromWrite(0, 42, true);
Serial.print(” retval=");
Serial.print(retval);
Serial.print("\n");

Serial.print(“read eeprom[0] “);
Serial.print(ard186xboard1.eepromRead(0, true));
Serial.print(”\n”);
}

void loop() {
// print the results to the serial monitor:
byte retval = 0;

digitalWrite(IR_LED_PIN, HIGH);
delay(1);
Serial.println(ard186xboard1.ltc186xRead());
}

Get rid of the Serial.print !

Mark

if i get rid of the serial print how will i get the readings?

I dont know I am not familiar with those library’s but the other people will help you.

You could always try to set your serial.begin to a higher Bps so its not that slow.

You may be able to take several hundred readings and save them in an array before pausing to print.

But, you do have limited memory and printing will slow things down.

Sample for 1 or a few seconds without reading out then stop sampling and read out.

I hit the same thing reading a pulse tach.

how many samples do i get a 200000 baud rate?

  Serial.begin(9600);

Any good reason for such a slow rate?

i've changed it to
serial.begin(250000);
but im not sure how many samples im getting per second now. anyone knows how to calculate this?

how many samples do i get a 200000 baud rate?

well how did you work out that your are getting 200 samples a second?

You cant set it that fast to print to the serial monitor see Serial.begin() - Arduino Reference

115200 is your fastest you can go.

Figure on ten bits per character printed.
Do the arithmetic.

Undermentioned:
115200 is your fastest you can go.

No it is not. It changed with IDE 1.6.7 and you can set 250000 now.

This is an example of a sloppy question, you should be asking how fast can you sample and send out data from an Arduino, not just sample.

If I wanted to time it I would set a pin high at the start of say 2000 samples and low at the end and then measure the pulse width on an oscilloscope. Or you can use the millis timer, make a note of the reading at the start and again at the end of 2000 samples and subtract the two for the time it took.

I am using a shield that has ADC 16 bits which provides a value of up to 65535 instead of 1023. And on the serial monitor i have the selection of 250000 baud.

Capture.PNG

Kentuckyfc:
I am using a shield that has ADC 16 bits which provides a value of up to 65535 instead of 1023. And on the serial monitor i have the selection of 250000 baud.

and it took sixteen replies to elicit that key item of information?

AWOL:
and it took sixteen replies to elicit that key item of information?

so according to this how should i calculate the number of samples per sec?

Perform as many conversions as you can in ten seconds.
Count them and divide the total by ten.

It isn’t rocket surgery.