Starting from:

$30

ECE383 Microcomputers – Lab 8 Analog-to-Digital and Digital-to-Analog Conversion  Solved




1.    Introduction
This lab introduces a basic analog to digital data conversion using an ADC module on the PIC24 and digital to analog conversion using the SPI-based MAXIM 548 DAC. The tasks in this lab include: 

•       Wiring a MAXIM 548A integrated circuit to the Microstick II on a breadboard.

•       Write a C program to program the PIC24 system to act as a data acquisition and display device.

2.    Pre-lab
For this lab assignment, all programs should be completed as a pre-lab assignment prior to your assigned lab time.   

TA check: Show the TA your breadboard circuit and source code. 

3.    TASK 1: DAC wiring
Wire the MAX548A DAC should be added to your existing layout containing the LCD wiring that was constructed in a previous lab as shown on Figure 1: 

1.    Connect all required Vdd (3.3V) and Vss (GND) pins on the MAX548A to your system power and ground rails respectively.

2.    Connect the LDAC# pin (pin 6) to Vdd.

3.    Connect the CS# pin (pin 3) on the MAX548A to RB3 (pin 7) on the PIC24 Processor.

4.    Connect the DIN pin (pin 4) on the MAX548A to SDO1/RP11 (pin 22) on the PIC24 processor.

5.    Connect the SCLK pin (pin 5) on the MAX548A to SCK1/RP12 (pin 23) on the PIC24 processor.

6.    Connect the OUTA pin (pin 2) on the MAX548A to RA0/AN0 (pin 2) on the PIC24 processor. Connect the photocell and resistor (910 Ω) to RA1 pin (AN1) of the PIC24 processor as shown in Figure 1. 

Use the chap11/adc_spidac_test.mcp MPLAB projects from the code library as the starting point for this task. Modify the pin assignment as shown above. Then, compile and download it to the Microstick II for verification. Please also take a look at example project chap11/adc2pots1.mcp if you want to know how to read multiple analogy signals.

 If your code and system are constructed correctly, you will have around 3.3V on the OUTA (pin2) of the MAX548A when the photocell is fully covered and 0V on the OUTA when the photocell is fully illuminated. Use a flash light from your cell phone to illuminate the photocell. You need to use AN0 on pic24 to read the output voltage level of MAX548. Then, display the voltage level on the LCD.

1 | P a g e

 

TA check: Show the TA that your code functions as expected. Use a screen capture tool to capture analog output results on the LCD and include them in your lab report. Include your source language programs in your lab report. 

4.    TASK 2: PIC24 Data Acquisition and Display
Write a program which can do the following applications:

1.  Samples the analog value Vin on the AN1 input every 0.01 seconds. Use an infinite while loop with an interrupt-based timer to control the input sampling. Instead of outputting the analog output using OUTA, use OUTB pin (pin 7) on the MAX548A to display. Refer Page 9 of the MAX548 datasheet to see how to do this. The datasheet is available on the class website.

 

2 | P a g e

 

2.  Scale the acquired value Vin (0-3.3V) to the range 0-255. When the photocell is fully covered, the LCDscreen should display 255. When the photocell is fully illuminated, the LCD screen should display 0. Use the equation in below to scale the input. Notice that, LCD shows the scaled values read from RA1, but not RA0. Analogy signal input on AN0 does not required to be shown on LCD. However,  descriptions about how to set OUTB (PIN7) as the output of MAX548A are required to be included in your report.

Vscaled = 255 * (Vin-Vinmin)/(Vinmax-Vinmin) 

3.  When Vin is below 1.7V (modify the voltage threshold for your own case), turn on an LED that is connected on RB2. When Vin is above 1.7V, toggle the LED at a rate of 10 times per second. Compile and run the MPLAB project to verify operation of your system.

TA check: Show the TA that your program functions as expected. Capture screenshots of the LCD screen and include them as figures in your lab report. Include your source language programs in your lab report. 

5.    Laboratory Report
No later than a week from the day the lab is performed, provide the TA a printed copy of the lab report following the ECE383 Lab report Template given on the class website. Each lab group will submit one joint lab report to the TA. Your report should have the reporting requirements needed for Tasks 1-2. The TA will take off a significant number of points (15 points from total lab grade) if your C source does not have the required comments. 


More products