Go Down

Topic: Arduinno Mega 2560 questions (Read 1 time) previous topic - next topic

bwilliams3

Hello,


What format does the Arduino save the data as? How many bytes is each sample? And what is the maximum number of samples that it can take? I appreciate the help.

AWOL


bwilliams3

We are testing the discharge time for new batteries. Here is a look at the script we are using for the uno if it helps.

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
 
}

// the loop routine runs over and over again forever:
void loop() {
   analogReference(EXTERNAL);
  // read the input on analog pin 0:
  int sensorValue_p = analogRead(A0);
  int sensorValue_n = analogRead(A1);
  int sensorValue_comp_p = analogRead(A2);
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  //positive battt voltage
  float voltage_div_p = sensorValue_p * (3.31 / 1023.0);
  float voltage_p = voltage_div_p * 4.0065076;            //*4 becaue of voltage
 
 //neg batt voltage
  float voltage_div_n = sensorValue_n * (3.31 / 1023.0);
  float voltage_n = voltage_div_n * -4.025467;            //*4 becaue of voltage divider
 
  //postivie comparator output voltage
  float voltage_div_comp_p = sensorValue_comp_p * (3.31 / 1023.0);
  float voltage_comp_p = voltage_div_comp_p *3.888;            //*4 becaue of voltage divider
 
  // print out the value you read:
  Serial.println(voltage_p,4);
  Serial.println(voltage_n,4);
  Serial.println(voltage_comp_p,4);
  Serial.println("");
 delay(10000);
}

Delta_G

#3
Jun 08, 2017, 12:24 am Last Edit: Jun 08, 2017, 12:25 am by Delta_G
You are calculating your results in float variables. Those are 4 bytes. But you're not storing them in any way. Each sample ceases to exist when the loop function returns. So you can keep running this forever.
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

bwilliams3

Yes, I am looking to store the samples on to the EEPROM in my next test. I plan on using the Mega which has 4kb of storage. Since each sample is 4 bytes, I should be able to store about a thousand samples right? I am also not very familiar with arduino coding as I inherited this code from my predecessor. Can I incorporate the EEPROM.write function to store the data along with my existing code?

CrossRoads

"I am looking to store the samples on to the EEPROM in my next test"
Be aware that an EEPROM write takes 3.3mS.

If you need to write faster, consider adding an external FRAM memory.
Writes occur at SPI speeds, way more than 4K is available, with 10 to 100 trillion write cycles you are not likely to ever wear it out. 3.3V and 5V parts available.
https://www.digikey.com/products/en/integrated-circuits-ics/memory/774?k=fram+memory&k=&pkeyword=fram+memory&pv2043=11&FV=ffe00306%2C1f140000&mnonly=0&newproducts=0&ColumnSort=0&page=1&stock=1&quantity=0&ptm=0&fid=0&pageSize=25
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up