*arg max
*arg min
CSCE 236 Embedded Systems, Spring 2016
Lab 3
Tuesday, March 1, 2016
Names of Group Members:
1 Instructions
This is a group assignment to work on during class. You only
need to hand in one copy of this, but make sure that the names of all
of your group members are on this sheet to receive credit. Complete
all of the sections below and make sure to get the
instructor or TA to sign off where required.
You should keep your own notes on what you complete since parts of future homework
will build on this lab.
2 Manual Analog to Digital Converter
In this section of the lab, you will manually configure the analog to
digital converter (also know as ADC or A2D). You will then test it by
creating a voltage divider and reading the values at different points
on the voltage divider.
Refer to the datasheet (Section 24.9) and configure the ADC in the setup function by:
- Setting the ADC voltage reference to AVcc. This connects the
voltage reference to the external voltage supply, which on the
Arduino is 5V.
- Enabling the ADC by setting the appropriate bit in the
ADCSRA register.
- Setting the ADC clock prescaler to an appropriate value for the
Arduino. Refer to table 24-5 in the datasheet. As noted, in
section 24.4, the successive approximation circuitry in the ADC
requires an input clock frequency between 50kHz and 200kHz.
- Also make sure that you explicitly set all the bits in these and
other registers to ensure that they are all configured as expected.
Now create a voltage divider on your bread board using 3 different
resistors (of your choosing, whatever you have available). Connect 1
end of the divider to ground and the other to the 5V power rail.
Connect a wire to the ADC3 pin and use this as a probe to measure the values between each of the resistors. To do this in your loop code you should:
- Set the ADMUX register appropriately (do not overwrite
the voltage source bits).
- Start the conversion (look for ADSC bit).
- Wait for the conversion to complete (by monitoring the ADSC bit).
- Read the value out of the ADC register.
Checkoff: What clock divider did you end up using and what is
the final ADC clock value?
Checkoff: How do you convert from the ADC value to the actual voltage
on the pin? Do the voltages you read on your voltage divider match
the theoretical values given the resistor values you have?
3 Reflectance Sensor
In this section of the lab, you will hook up infrared (IR) reflectance
sensors to your robot. These sensors emit an IR light and then
measure how much is reflected back. If the IR sensor is over a white
surface a lot of IR will be measured, while if it is over a black
surface little will be seen. The distance to the surface also makes a
difference.
For this part of the lab, you can either read the ADC manually as
you configured it above, or use the Arduino analogRead(...)
command. I would recommend using the analogRead(...)
command or creating functions that encapsulate the ADC reading code
above. Regardless, you are expected to know how both work.
The reflectance sensors have three wires. Black should be connected
to ground, red to 5V, and the green wire to one of your ADC ports.
Perform basic experiments to characterize the performance of the
sensors. You can use the black line on the following page as a
reference.
Checkoff: As you move the sensor closer to a surface, does the ADC
value increase or decrease?
Checkoff: How close do you have to be to an object to have a
difference of more than 100 ADC values between a black and white
object?
File translated from
TEX
by
TTH,
version 3.89.
On 29 Feb 2016, 14:48.