$24
Introduction
In this lab you will write a task to read the Analog-to-Digital Converter (ADC), capture a time sequence of measurements, and transmit the measurements via the UART to the PC.
2 Rationale
There are many sensor situations in which you need to capture a sequence of measurements. In this lab you will measure the voltage across a capacitor as it charges from 0.0 V to 3.3 V.
2.1 Program Modifications
Make as copy of the ADC project from Lab #05. You will add a task as described below. You should remove the task that reads the potentiometer voltage.
2.2 ADC Background
The operation of the Analog-to-Digital Converter was described in class. The steps to program the ADC and sample the analog input were discussed in class and a sample task provided. Additional information on the ADC hardware and DriverLib software are at:
http://www.ittc.ku.edu/~gminden/Embedded_Systems/PDFs/TI_Stellaris_LM3S1968 _EvalBoard.pdf,
http://www.ittc.ku.edu/~gminden/Embedded_Systems/PDFs/TI_Stellaris_LM3S1968. pdf, and
http://www.ittc.ku.edu/~gminden/Embedded_Systems/PDFs/TI_Stellaris_DriverLib.p df.
You should read those documents.
2.3 RC Circuit
The circuit you will be using is shown below.
EECS 388 Laboratory #6
1
Version G
You measure the voltage on the capacitor using ADC<0. PortD<2 is used to discharge the capacitor.
2.4 Connector Pin-outs
With the LM3S1968 evaluation board receptacle facing you, we use twenty pins on the left-hand side to connect to off-board circuits. These pins are described in EECS 388 Laboratory #05 write-up.
3 New Tasks
Write a new FreeRTOS task. The task will do the following steps (states):
Initialize the required peripherals.
Wait for the Select button to be pushed and released.
Discharge the capacitor in the RC circuit by taking PortD<2 low and then high.
Collect 100 samples from the ADC0<0 as the capacitor charges.
Send the sample values to the PC workstation via the UART.
Go to step 2.
You will plot the collected voltage measurements and compared to expected voltages in your report.
3.1 Initialization Step
Initialized the required peripherals, e.g. the Select Button, PortD, the ADC, and UARTstdio.
3.2 Wait for Select Button Step
Use techniques from EECS 388 Laboratory #03 to detect, de-bounce, and detect the release of the Select Button.
3.3 Collection Step
Write a collection step that does the following:
EECS 388 Laboratory #6
2
Version G
Discharge the capacitor in the RC circuit.
Collect 100 samples from the ADC0<0 as the capacitor charges. The initial value of PortD<2 shall be ‘1’.
When the Select Button is released set PortD<2 to ‘0’ for 0.5 mS and then set PortD<2 back to ‘1’. Start collecting measurements.
Collect 100 ADC measurements using ADC0<0 with a measurement interval of 1 mS. You should use SysCtlDelay() from DriverLib to delay between measurement samples. If you return to FreeRTOS with vTaskDelay() you will likely have jitter in your measurement intervals.
3.4 Transmit ADC Samples Step
When a measurement set is complete, the task should transmit the individual measurements via the UART to PuTTY.
3.5 Collect Samples in PuTTY
You should set up PuTTY to receive the measurement set and save the values to a file. You can use a text editor to select the samples, paste into Excel or other graphing program, and generate a plot of the sampled voltage.
3.6 Comparison of Measured Values to Expected Values
You should compare your measured voltage values to expected voltage values. The expected values should consider R = 100 KOhm, C = 1 uF, and V = 3.3 V. The analytic formula for a charging capacitor is V(t) = Vdd * (1 – Exp(-t/(RC))), where in this laboratory, Vdd = 3.3. VDC.
Explain discrepancies between measured voltage and predicted voltage in your report.
EECS 388 Laboratory #6
3
Version G