I'm using Arduino Uno with a load cell.I wired it with an INA125 and i managed to make it work. My problem is the sample rate...I can get around 55 samples per second...Is there any way to get more samples per second?Something around 100-150 samples? Btw I'm controling it via a graphical interface I have made in proccesing 2.0, just to have a graphical Start/Stop logic and to write values to an Excel file.
Your sample rate is limited by the time it takes to output or print each sample.
Increase the data transfer rate (baud rate if using serial).
I have put the buad rate at max (115200). Still same number of samples...
Then follow the forum guidelines and post your code.
The ADC can be put in free run mode and generates an interrupt at conversion completion, also the ADC clock timing can be altered, read the data sheet.
www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf
Sounds like your problem is in your code loop. not the ADC sample rate. But without you code, there is no way to help.
Others have found an analogRead() statement in a for loop can approach 10Ksps. Using the PlainADC library, you can get controlled rate and sample size up to 130Ksps.
If you want something really fast then try the Teensy 3.2. The simple loop test, 10 bit, approaches 1Msps and synced dual ADCs, 12 bit, with structured array save will get 62.5Ksps.
The Arduino is more than capable of giving the sample rate that you want. Even with the analogRead() function (slowest prescaler of 128), I can get a reading back in about 112 usec.
My guess is that the lack of speed that you are seeing is coming from your serial comm. You are obviously not displaying the data "real time" with these sampling rates (too fast for people to read), so you need to collect a buffer of readings, switch buffers and send the first buffer to the computer, all the while taking your ADC reading at the sample rate you want.
DO NOT use blocking functions like delay(). Technically, analogRead() blocks, but it is quick enough that it shouldn't make any difference for what you want to do.
thank you all for answers...i was away for a while...
I still search my problem and I guess it deals with proccesing. In serial port of arduino SDK I get greata number os samples...then samples goes to procceign 2.0 and been saving to an excel file....I feel that somewhere is the problem and not dealing with arduino capabilities!!!!
Have a look at #1 in this thread for different sampling rates of the ADC and also #11 for accuracy at different rates, basically all bar the two fasted rates are pretty similar to the default ADC speed.
the Arduino code:
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(13, 12, 2, 3, 5, 4);
float sensorValueLEG1;
float sensorValueLEG2 = 0;
float sensorVals[] = {0,0};
void setup() {
// initialize serial communication at 115200 bits per second:
Serial.begin(115200);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.clear();
}
void loop() {
// set the cursor to column 0, line 1
lcd.setCursor(0, 1);
float sensorValueLEG1 = analogRead(A1);
float sensorValueLEG2 = analogRead(A0);
sensorValueLEG1 = mapfloat(sensorValueLEG1, 518, 870, 0, 100);
sensorValueLEG2 = mapfloat(sensorValueLEG2, 527, 868, 0, 100);
sensorVals[0] = sensorValueLEG1;
sensorVals[1] = sensorValueLEG2;
// print out the value you read:
lcd.setCursor(0, 0);
lcd.print("LEFT:");
lcd.print(sensorVals[0],1);
lcd.setCursor(0, 1);
lcd.print("RIGHT:");
lcd.print(sensorVals[1],1);
//delay(100);
Serial.print(sensorVals[0]);
Serial.print(",");
Serial.println(sensorVals[1]);
//delay(10); // delay in between reads for stability
}
float mapfloat(float x, float in_min, float in_max, float out_min, float out_max)
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
Should I post the proccesing code too here or its wrong forum?
![]()
Please edit your post and add code tags to your code.