0% found this document useful (0 votes)
60 views4 pages

PLEASE (NEATLY) SHOW ALL WORK! Comment All Code Well. Do Not Make The

This document provides instructions for Homework #4 involving analog-to-digital conversion using the ADC12 module on the MSP430 microcontroller. It includes 4 questions related to configuring and using the ADC12 to read various analog sensor signals, including a potentiometer, accelerometer, and thermistors to measure temperature. Code snippets are provided to help configure the ADC12 and students are asked to write additional code to implement specific functions like reading the potentiometer, calculating tilt from an accelerometer reading, and periodically sampling 3 thermistors to monitor temperature in experimental chambers.

Uploaded by

engshimaa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views4 pages

PLEASE (NEATLY) SHOW ALL WORK! Comment All Code Well. Do Not Make The

This document provides instructions for Homework #4 involving analog-to-digital conversion using the ADC12 module on the MSP430 microcontroller. It includes 4 questions related to configuring and using the ADC12 to read various analog sensor signals, including a potentiometer, accelerometer, and thermistors to measure temperature. Code snippets are provided to help configure the ADC12 and students are asked to write additional code to implement specific functions like reading the potentiometer, calculating tilt from an accelerometer reading, and periodically sampling 3 thermistors to monitor temperature in experimental chambers.

Uploaded by

engshimaa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

ECE2049 Homework #4 – Analog-to-Digital Conversion and the ADC12

(Due Monday 4/17/14 At the BEGINNING of class)

PLEASE (NEATLY) SHOW ALL WORK! Comment all code well. Do not make the
grader guess what your doing! All code should be typed.
To ensure proper grading & return, you must attach the included cover sheet!

Refererence: Davies Ch 9.2-3, 9.7, MSP430x55xx User's Guide Ch. 28, class notes,
examples, TI code examples

1) Answer the following questions completely. (20 pts)

a. Which of the ACD12_A's analog input channels (ADC12NCHx) are external input
channels? List the Ports and Pins each of these input channels uses when selected to be
in function mode (i.e. PxSEL.y = 1)

b. Which of the ACD12_A's analog input channels (ADC12NCHx) are internal analog
inputs? List what each internal input channel is attached to.

c. Now, for the ADC12_A as configured below what are the specific (10 pts)

i. Full-scale range, ii. Resolution, iii. Dynamic Range


iv. Input Channel v. Memory output register

REFCTL0 &= ~REFMSTR;

ADC12CTL0 = ADC12SHT0_9|ADC12SHT1_9|ADC12REFON|ADC12ON;
ADC12CTL1 = ADC12SHP;

P7SEL |= BIT0;
ADC12MCTL7 = ADC12SREF_1 + ADC12INCH_12;

ADC12CTL0 |= (ADC12SC|ADC12ENC);

while (ADC12CTL1 & ADC12BUSY)


__no_operation();

in_value = ADC12MEM7 & 0x0FFF;


2) Referring to the schematics at the end of the MSP-EXP430F5529 Experimenter's
Board Users Guide. Configure and implement the scroll wheel potentiometer. You will
need this for Lab 3. (15 pts)

a. To what analog input channel is the variable arm of the potentiometer connected?
And what digital IO port and pin does the potentiometer use?

b. Explain the operation of the potentiometer circuit. Specifically, to what logic value
must the digital IO pin be set for a voltage drop to be evident across the
potentiometer?

c. Write a CCS C function that will return read the value of the scroll wheel. Your
function must configure the digital IO pin and set its value, and then use ADC12_A to
read in from the potentiometer (single channel, single conversion) using analog Vcc as
Vref+ and ground as Vref-.

3) Accelerometers measure the force of gravity. A particular accelerometer has a range


of + 2.2 g but is currently being used simply as a single axis tilt sensor as shown below.
The analog output voltage of the accelerometer is 1.2 V at 0 g and the device has a
sensitivity of 362 mV per g. Assume the output of the accelerometer is input into the
MSP430's 12-bit analog to digital converter, and that the ADC12_A is configured using
the code shown below. (30 pts)

Accelerometer orientation and readings for 4 different tilt values:

Tilt = 0o Tilt =45o Tilt = 90o Tilt = 180o


Reads 1 g Reads 0.707 g Reads 0 g Reads -1 g

a) What is the Full Scale Range of the accelerometer in g's? What is the FSR of the
ADC12 in volts as it is configured above?

b) Given the settings in the code above, what is the resolution (in volts/bit) of ADC12_A?

c) What is the output of the ADC12 in hex for tilt readings of 0o, 45o, 90o and 180o.

d) Given the information and the diagram above, write the C function calc_tilt()
that converts the ADC12 output in adc_tilt to a tilt angle from 0 to 180 degrees.
You may assume the C math library <math.h> is available. Code must be typed to be
graded.

e) Can your tilt measurement system detect a 1 degree tilt from horizontal (0o to 1o)?
What is the smallest tilt from horizontal that you can measure?
void tiltMeter()
{
unsigned int adc_tilt;

P6SEL |= BIT6;
ADC12CTL0 = ADC12SHT0_9|ADC12REFON|ADC12REF2_5V|ADC12ON;
ADC12CTL1 = SHP;
ADC12MCTL0 = SREF_1 + INCH_6;

//Enable and start (a single) conversion


ADC12CTL0 |= (ADC12SC|ADC12ENC);

while (ADC12CTL1 & ADC12BUSY)


__no_operation();

adc_tilt = ADC12MEM0 & 0x0FFF;

calc_tilt(adc_tilt);
...
}

4) An MSP430 is being used to monitor the temperature inside 3 different experimental


chambers over time. Using the code examples from class and the TI website as a guide,
write a code segment in C that uses the ADC12 to sample the temperature inside each of
the experimental chambers once per second. Your code should configure the timer and
the ADC, make the conversions and express the results to degrees C. You do not have to
convert the results to ASCII for display. The output from the thermistors for Chambers 1
through 3 are connected to analog inputs A0, A2, A4 respectively. The thermistors inside
the chambers are linear across the temperature range of interest (-40 to 80Co) with

Vtemp = 0.0071*(Temp Co) + 1.103V.

What temperature corresponds to an ADC measurement of 0x090A for you temperature


monitoring system? What ADC measurement corresponds to 25C? Code must be typed
to be graded.(30 pts)

You must document the following in your solution -- what input channels
(ADC12INCHx) are used, what memory conversion registers are used, are you using
single channel or sequential channel mode, continuous or one-shot conversion. Also list
you choice for the reference voltage Vref. You may use code similar to the TimerA2 stop
watch example to measure time. You do not have to use ADC12_A interrupts but you
may. As is often the case, there are multiple approaches to this problem.
ECE2049 Homework #4

Submitted by:__________________________________

ECE Box #:____________

Date:_______________________________

Question Grade
1-20
2-30
3-25
4-25
Total:

You might also like