EE47 Lab 4


A.

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

          • Based on the readings from the serial monitor, the range of analog values being read is 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?

          • The Atmega32U4 has a 10 bit ADC on board which would result in 2^10 (1024) possible values, 0 included. I am seeing the full 10 bit range on the serial monitor.

 

B.

     1.

          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 the IR distance sensor data is printed over the Serial Monitor, at the shortest distance possible the measurement hovers around 250 out of 1023, but when distance is increased to around 10cm, the measurement increases to a maximum of around 550. When the distance increases even more, the measurement slowly decreases back down over the distance to around 20 out of 1023. This trend matches the graph found in the datasheet.

 

     2.

          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()

{

  lcd.begin(16, 2);

}

 

void loop()

{

  lcd.setCursor(0, 0);

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

  lcd.setCursor(8, 0);

  lcd.print(F("X:"));

  lcd.print(analogRead(xpin));

  lcd.setCursor(0, 1);

  lcd.print(F("Y:"));

  lcd.print(analogRead(ypin));

  lcd.setCursor(8, 1);

  lcd.print(F("Z:"));

  lcd.print(analogRead(zpin));

  delay(100);

}

 

C.

     1.

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

               • 

 

D.

     1.

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

               • 

     2.

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

               • You can store 1000 byte-sized data samples in the Atmega32U4’s 1kB of EEPROM

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

               • The ADC returns 10 bit values and bytes are 8 bit values. To convert, divide the 10 bit values by 2^2, or 4.

     3.

          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. http://pressplay.pbworks.com/w/page/42939192/Lab%204%20Data%20Logger%20Hall%20of%20Fame