Starting from:
$35

$29

Lab 2 A/D Converter Solution

This circuit connects a variable voltage to an ADC port on the ARM M0 MCU (Micro Controller Unit). Your software running on the ARM M0 MCU will read the digital value and display the percent and raw value of the voltage, VA.

The interface consists of some analog circuitry, wiring the circuit to the Nuvoton board, and running corresponding software on the ARM M0 MCU.

Figure 1: Input to an A/D converter

Voltage is measured at the output of the Potentiometer (VA). VCC and GND can be obtained from ports on the Nuvoton Nu-LB-NUC140 development board (Nuvoton).

A. Background:

A potentiometer can set a variable that is processed and used by the microprocessor. Typical applications include having the potentiometer represent a volume or level of ambient light, although a potentiometer can set just about any reference signal.

There are two basic styles of potentiometers: audio and linear. Audio potentiometers vary logarithmically as the sense of hearing is logarithmic. Recall, the definition of decibels is: ratio dB = 10 log10(ratio). This lab uses a linear single turn potentiometer.

The potentiometer in Figure 1 is part of an external circuit that provides an input signal to the Nuvoton. The NUC140VE3CN has an eight channel A/D converter connected to Port A on the Nu-LB-NUC140 development board.

B. ADC on the NUC140VE3CN:

The ADC on the M0 chip is a 12-bit A/D converter with an analog input voltage range of 0 to

Vref. For the Nuvoton board Vref is set at 3.3V. There are up to 8 single-end analog input channels and 4 pairs of differential analog input channels for compare functions. The maximum

conversion rate is 600 KHz and the maximum operating frequency is 16MHz. There are three operation modes: single mode, single-cycle mode, and continuous scan mode. The A/D

conversion can be triggered externally or by software. Conversion results are held in dedicated data registers for each channel with valid and overrun indicators. The ADC on the M0 chip is equipped with a digital compare function that can be used to monitor conversion results. Channel 7 on the NUC140VE3CN has 3 possible input sources, an external analog voltage (what we are doing in this lab), the internal bandgap voltage and the output of the temperature sensor on the Nuvoton board. The ADC also has a self-calibration function to minimize the conversion error.

Figure 2: Pin locations for Lab 2

In this lab you will create a program to use the A/D converter to sample and derive a digital value from the A/D port. Your first program should use the single mode operation and the second program use the continuous scan mode operation. In your report discuss the difference in performance, if any. Also compare the results if you include the self-calibration function vs. no calibration.

  1. Pre-lab Assignments:

    1. Familiarize yourself with the Technical Reference Manual, User Manual, schematics, and the Driver Reference Guide sections that discuss the ADC.

    1. Complete the Pre-lab Questions.

Note: Each student must conduct the labs by themselves. You are not allowed to copy codes/content or to pair-up with other students to complete the labs. Each student must demonstrate individual tasks (after completion) to the professor and teaching assistant to get the full marks for the demo.

  1. In-lab Tasks:
    1. Construct the circuit in Figure 1 but do NOT connect VA to the GPA pin of the ADC channel you will be using.

      1. Use lab equipment (multi-meter, oscilloscope) to verify that the potentiometer is operating correctly.

      1. Verify the values of VA. Make sure VA does not exceed the specifications for the input port of the ADC. Also, record max and min measured VA values.

    1. Connect the circuit, i.e. the GPA pin of the ADC channel you are using. Ensure your program includes the LCD display as a peripheral.

    1. Write a C-routine to read an A/D port and display its value on the LCD. Display the value as a percentage, a floating-point voltage, and the raw digital value read from the A/D port. You will need to make a design decision as to how often and under what conditions your program displays the A/D values.

    1. You have to write two programs for the ADC: first using the single mode operation and second using the continuous scan mode operation.

    1. Implement a heartbeat signal using an interrupt service routine (ISR) and one of the RGB LEDs.

    1. Include noise elimination in your code.

    1. Test the boundary conditions of the Circuit. That is, make sure that the display is correct both when the potentiometer is turned completely off and completely on.

    1. Create a table that records your results from the LCD Display and the multi-meter/ oscilloscope. See Figure 3.

    1. Graph the results from your data table. The graph should be the input voltage (as measured) vs. ADC output voltage. Use linear regression to produce a best-fit line through the data points. It is OK to use software to do the linear regression analysis. Include this in your lab report.

    1. Demonstrate all of the above designs/codes (working models) to your professor and teaching assistant.

  1. Parts List:

The items on this list will NOT be repeated in the lab write-up but they are necessary for all labs.

    1. A linear potentiometer
    2. Connector wires.
    3. USB to micro USB cable for programming

  1. Deliverables:

    1. To sign-off: Demonstrate to your professor and teaching assistant how the output display varies as the potentiometer varies. ALL the programs should have a heartbeat LED.

    1. Lab Write-up: Follow the Lab Report Format as well as the rubric for Lab2. The report should include:

      1. Introduction including a summary of the lab tasks.

      1. In-Lab tasks, problems encountered, your solutions, including hardware and software.

      1. Include the explanation of how you characterized the device, and your analysis of the values found. Discuss the difference in performance, if any, between the single mode and the continuous scan mode operations. Also

  1. Table 1 and the Graph of your data as the potentiometer was varied.
  2. Discussion and conclusion

  1. Program/code listing for each task, including the programs for single mode operation and continuous scan mode operation.

NOTE: All the lab reports should be typed and turned in as a hard copy on time (check the syllabus for the due date), and a soft copy should be forwarded to the Teaching Assistant: Srikanth Ramadurgam on the due date and time.

Table 1: Voltage and Percentage of Full

Scale

Voltage Measured

Display Voltage

Digital Value

Percentage of Full


Value at Point VA

Figure 3: Table 1

5. Pre-Lab Questions for Lab 2:

Name:___________________________

10 points total. Be sure to include units, as appropriate, with your answers.

  1. What is the range of an n-bit A/D converter?

  1. What is the range of the NUC140VE3CN converter, what is the resolution if the full-scale input range is 5V?

  1. Briefly describe the three operating modes of the ADC in the NUC140VE3CN. Use diagrams if necessary. Briefly describe the input modes

  1. What are the possible inputs for Channel 7 of the ADC and how do you select them

  1. How are the results accessed, what additional information is provided?

More products