| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

Lorta_Lab 4: Make a Data Logger!

Page history last edited by xinyi xie 9 years, 7 months ago

Part A.  Writing to the Serial Monitor

a. Based on the readings from the serial monitor, what is the range of the analog values being read?

0 - 1023

b. How many bits of resolution does the analog to digital converter (ADC) on the Atmega32U4 have (hint: where might you look to find this sort of thing)? How many are you using with the range of values you're seeing?

According to the Atmega32U4 datasheet, the ADC has 2 to 16 bit resolution. We’re using 10 Bit resolution according to the above range.

Part B. Voltage Varying Sensors

1. IR Distance Sensor

a. Describe the voltage change over the sensing range of the sensor. A sketch of voltage vs. distance would work also. Does it match up with what you expect from the datasheet?

When pointed into “space” (length of our Packard lab room), my sensor value returns virtually 0. When I place a white sheet of paper directly in front of the IR sensor, the sensor value also returns approximately 0. Yet, when I move a piece of white paper toward the sensor from a starting distance of 80 cm+, the sensor value starts at zero and spikes up to 634 momentarily, then goes back down to 0 when the paper covers the sensor entirely.

 

The analogRead(analogPin) function reads a “0 to 5” volt signal and maps it to a value between 0 and 1023. Therefore, when aimed into space, the IR sensor returns virtually 0 volts. And when a white piece of paper is moved toward the IR sensor, the voltage spikes up to (634 * 5) / 1023 = 3.10 V. This is in accordance with the datasheet, where the IR sensor returns a voltage slightly above 3 V for an object at a distance between 0 and 10cm, and then 0 for objects directly in front of the sensor.

2. Accelerometer

a. Include your accelerometer read-out code in your write-up.

// include the library code:

#include <LiquidCrystal.h>

 

// initialize the library with the numbers of the interface pins

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

 

// these constants describe the pins. They won't change:

const int xpin = A3;                  // x-axis of the accelerometer

const int ypin = A2;                  // y-axis

const int zpin = A1;                  // z-axis (only on 3-axis models)

 

void setup()

{

 // initialize the serial communications:

 Serial.begin(9600);

 lcd.begin(16, 2);

}

 

void loop()

{

 lcd.setCursor(0, 0);

 lcd.print("Accel. Data: ");

 lcd.setCursor(0, 1);

 lcd.print("X");

 lcd.print(analogRead(xpin));

 lcd.print(" Y");  

 lcd.print(analogRead(ypin));

 lcd.print(" Z");

 lcd.print(analogRead(zpin));

 delay(300);

}

Part C. Count/Time-Based Sensors

a. Upload a picture of your rotary encoder in action!


Part D. Logging values to the EEPROM and reading them back

1. Design your logger

a. Turn in a copy of your final state diagram.

-0.5

2. Reading and writing values to the EEPROM

a. How many byte-sized data samples can you store on the Atmega32U4?

According to the Atmega32U4 datasheet, the EEPROM contains 1KB of space. Therefore, we can store 1024 byte-sized data samples.

b. How would you get your analog data from the ADC to be byte-sized?

As mentioned above, our ADC uses 10 bit resolution, or 2^10. If we need the data to be byte sized, or 2^8, we need to divide by 2^2.

3. Create your data logger!

a. Use the lab camera or your own camera/cell phone to record and upload a short demo video of your logger in action.

b. Post a link to the Lab 4 Data Logger Hall of Fame.

 

 

Comments (1)

xinyi xie said

at 1:47 pm on Aug 10, 2014

-1 for not attaching the video.

You don't have permission to comment on this page.