lab 3 adc n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Lab 3: ADC PowerPoint Presentation
Download Presentation
Lab 3: ADC

Loading in 2 Seconds...

play fullscreen
1 / 31

Lab 3: ADC - PowerPoint PPT Presentation


  • 134 Views
  • Uploaded on

Lab 3: ADC. Signal Path. Produce a proper output voltage level. Signal Conditioning (if necessary). Sensors . Amplification Filtering. Analog to Digital Conversion (ADC). Light Temperature Acceleration Humidity Pressure etc. Resistance Capacitance Current Voltage

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Lab 3: ADC' - denim


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
signal path
Signal Path

Produce a proper output voltage level

Signal Conditioning

(if necessary)

Sensors

  • Amplification
  • Filtering

Analog to Digital Conversion

(ADC)

  • Light
  • Temperature
  • Acceleration
  • Humidity
  • Pressure
  • etc.
  • Resistance
  • Capacitance
  • Current
  • Voltage
  • etc.

10011101

Convert to voltage

Converts voltage to digital number

Today’s labs

general view
General View

Each storage register associated with a control register

Positive/Negative voltage reference: define the upper and lower limits of the conversion

16 conversion result storage registers

4 clock sources available for ADC12 clock

Software configurable sample-and-hold period

12 input channels available

conversion formula
Conversion Formula
  • This is a conversion formula of ADC
  • For MSP430 ADC12 module
    • It is a 12-bit ADC
    • If Vin > Vref+ => output 4095 (max)
    • If Vin < Vref- => output 0 (min)
input channels
Input Channels
  • 12 input channels available
    • 8 external input pins: A0 ~ A7
    • 2 external voltage reference pins: VeREF+, VeREF-
    • 1 internal temperature sensor
    • 1 supply voltage monitor
  • Multiplexed with P6 GPIO
    • Setting P6SEL to choose the

function you want

internal voltage reference generator
Internal Voltage Reference Generator
  • Voltage references are used as a base of the conversion
    • Input voltage compares to the voltage reference to generate the conversion result
  • A stable voltage reference is crucial to an accurate conversion
    • Usually we use a special circuit to generate stable voltage reference
  • MSP430 has a built-in voltage reference generator
    • It has two selectable voltage levels
      • 1.5V and 2.5V
voltage references options
Voltage References Options
  • 3 positive reference sources
    • AVcc – Positive supply voltage
    • VREF– internal voltage reference
      • Can be 1.5V or 2.5V, depends on your selection
    • VeREF+ – external positive voltage reference
  • 2 negative reference sources
    • AVss – Negative supply voltage (GND)
    • VeREF- -- external negative voltage reference
  • 6 combinations in total
adc12 conversion modes
ADC12 Conversion Modes
  • Single channel single-conversion
    • A single channel is converted once
  • Sequence-of-channels
    • A sequence of channels is converted once
  • Repeat-single-channel
    • A single channel is converted repeatedly
  • Repeat-sequence-of-channels
    • A sequence of channels is converted repeatedly
conversion memory
Conversion Memory
  • 16 ADC12MEMx memory registers to store conversion results
  • Each ADC12MEMx is configured with an associated ADC12MCTLx control register.
    • EOS: End of sequence, indicates last conversion
    • SREFx: Select voltage reference
    • INCHx: Select Input Channel
  • CSTARTADDx bits define the first memory used for conversion
    • This bit is in ADC12CTL1 control register
adc12mctlx
ADC12MCTLx

Use in sequence of channels mode

example
Example
  • Depends on the setting of conversion mode, ADC12MCTLx and CSTARTADDx, the ADC will have different behavior

Sequence of Channels

CSTARTADDx = 0000

CSTARTADDx = 0100

Single-channel

If you need 7 input channels

If you need 5 input channels

CSTARTADDx = 0000

CSTARTADDx = 0100

You need to set ADC12MCTL0 to ADC12MCTL4 (choose the input channel and voltage reference for each ADC12MEM). You need to set the EOS bit in ADC12MCTL4to 1, indicates the sequence of conversion end here. And the conversion results will store in corresponding ADC12 memory registers

You need to set ADC12MCTL8 to ADC12MCTL14 (choose the input channel and voltage reference for each ADC12MEM). You need to set the EOS bit in ADC12MCTL14to 1, indicates the sequence of conversion end here. And the conversion results will store in corresponding ADC12 memory registers

You need to set ADC12MCTL0 (choose the input channel and voltage reference). And the conversion result will store in ADC12MEM0

You need to set ADC12MCTL8 (choose the input channel and voltage reference). And the conversion result will store in ADC12MEM8

conversion clock
Conversion Clock
  • 4 clock sources available
    • ADC12OSC: ADC12 internal oscillator
    • MCLK
    • SMCLK
    • ACLK
    • For simplicity, we use ADC12OSC in our lab
    • Independent of the system clock
adc12 core
ADC12 Core
  • Two phases for a conversion
    • Sample-and-hold
    • A/D conversion
  • Conversions in MSP430 ADC12
    • Triggered by a SHI signal
    • Two sample modes
      • Extended Sample Mode
      • Pulse Sample Mode

SHI signal triggers a conversion and controls the length of sample-and-hold period

SHI signal triggers a conversion, the length of the sample-and-hold period is controlled by other register

the shi signal
The SHI Signal
  • Four selectable sources for SHI
    • ADC12SC bit
      • A single bit in ADC12 control register, set this bit to high will trigger a conversion
    • Timer_A output unit 1 (TA1)
    • Timer_B output unit 0 (TB0)
    • Timer_B output unit 1 (TB1)

Lab_2 slide

sample and hold revisit
Sample And Hold Revisit
  • There is a sample and hold circuit before A/D conversion
  • Mostly integrated with the ADC chip
  • When no conversion, switch S1 is open
  • When a conversion start
    • S1 closed
    • Input signal charge C1
    • S1 open, C1 holds the value of input signal
    • A/D conversion
  • Sample and hold time
    • Time between S1 close and re open
    • If it is too short
      • C1 will not fully charged (error)
sample timing considerations
Sample Timing Considerations
  • For an accurate conversion, the sample-and-hold time must be long enough to charge up CI to Vs
  • Rs will affect the sample-and-hold time (tsample)
    • For MSP430F1611, RI = 2K ohm (max); CI = 40 pF (max)
    • Minimum tsample for 12-bit conversion

=>

setting t sample
Setting tsample

If we use ADC internal oscillator (ADC12OSC) as ADC12 clock source. Frequency of ADC12OSC is about 5MHz, if you set SHT0x to 0100, then the sample-and-hold time is 64*(1/5000000) second = 12.8 μs

rs source resistance
Rs: Source Resistance
  • Many devices didn’t specify their source resistance (source impedance/output impedance)
  • Measuring source impedance is not an easy task
  • For most of the case, set the SHTx bit to 0001 or 0010 should work
    • use ADC12OSC as clock source
  • My suggestion is
    • it’s only 16 possible setting, just try it out!
adc12 interrupts
ADC12 Interrupts
  • ADC12 has 18 interrupt sources:
    • ADC12IFG0-ADC12IFG15 flag
      • Associated with each ADC12MEMx, indicates a conversion of this memory is complete
    • ADC12OV: ADC12MEMx overflow
      • A conversion result is written to any ADC12MEMx before its previous conversion result was read
    • ADC12TOV: conversion time overflow
      • Another conversion is requested before the current conversion is completed
adc12iv interrupt vector generator
ADC12IV, Interrupt Vector Generator
  • All ADC12 interrupts are source to a single interrupt vector
    • Similar to Timer_A3
  • The highest priority enabled ADC12 interrupt generates a number in the ADC12IV register
    • Highest priority interrupt generates a number
      • Branch to the ADC ISR, read ADC12IV, process the associate sub-routine, leave the ADC ISR
    • And then, second highest priority interrupt generates another number
      • Branch to the ADC ISR again, ……….
reset of interrupts
Reset of Interrupts
  • Overflow interrupts (memory overflow and conversion time overflow) will reset automatically when
    • Any access, read or write, of the ADC12IV register
  • ADC12IFG0-ADC12IFG15 flag will reset when
    • Accessing their associated ADC12MEMx register
interrupt enable register
Interrupt Enable Register

Enable the interrupt of corresponding ADC12 memory (ADC12MEM). Usually, you only need to enable one of the source.

adc12 configuration1
ADC12 Configuration

Enable/disable internal voltage reference generator, set the voltage reference to 1.5/2.5 V

Enable/disable overflow interrupt

adc12 configuration2
ADC12 Configuration

For example, if CSTARTADDx =

We use this bit in ADC12CTL0 register to trigger a conversion. You can try out the other source of trigger. The benefit of using Timer_A or Timer_B trigger sources is you don’t need CPU to handle the trigger

adc12 configuration3
ADC12 Configuration
  • Use Pulse Sample Mode

We use ADC12 internal oscillator as clock source

Depends on your requirement, choose the proper conversion sequence mode

example single channel single conversion
Example: Single Channel, single conversion
  • Only one input channel, one conversion at a time

Initialization

Configure the ADC:

ADC12CTL0

1. setting SHTx

2. setting voltage reference generator

ADC12CTL1

1. setting CSTARTADDx (pointed to one memory)

2. setting SHSx

3. SHP = 1

4. setting ADC12 clock source

5. select single channel, single conversion mode

ADC12MCTLx

1. depends on the conversion mode you choose, and the input channel and voltage reference you want, set proper ADC12MCTLx register

Turn-on ADC12

Set ADC12ON to 1

Enable Conversion

Trigger a Conversion

Set ENC to 1

An ADC interrupt generated when the conversion complete. The conversion result is available at the memory register you choose

You can use a timer to trigger a conversion, in the timer ISR, set the ADC12SC bit to 1

You need to enable the corresponding interrupt. The one selected by CSTARTADDx

example sequence of channels
Example: Sequence of Channels
  • Multiple input channels, a sequence of conversions

Configure the ADC:

ADC12CTL0

1. setting SHTx

2. setting voltage reference

3. set MSC bit to 1 (multiple conversion automatically start)

ADC12CTL1

1. setting CSTARTADDx (pointed to one memory)

2. setting SHSx

3. SHP = 1

4. setting ADC12 clock source

5. select Sequence-of-channelsmode

ADC12MCTLx

1. depends on the conversion mode you choose, and the input channel and voltage reference you want, set proper ADC12MCTLx register

2. depends on the number of channels you want, set the EOS bit to 1 in the proper ADC12MCTLx register

Initialization

Turn-on ADC12

Set ADC12ON to 1

Enable Conversion

Trigger a Conversion

Set ENC to 1

An ADC interrupt generated when the last conversion complete. The conversion results are available at the memory registers you choose

You can use a timer to trigger a conversion, in the timer ISR, set the ADC12SC bit to 1

You need to enable the interrupt of the last conversion memory.

today s labs
Today’s Labs
  • Lab 1: Light Sensor
    • use the sample code on website
    • choose a light sensor on Taroko
    • configure the ADC to take samples from the light sensor
    • when the light sensor is covered by hand, turn on a LED; when the hand remove, turn off the LED
      • set a threshold
lab2 infrared proximity sensor
Lab2: Infrared Proximity Sensor
  • Connect the sensor to Taroko
  • configure the ADC to take samples from the sensor
  • use an obstacle(hand, paper, etc.) to approach the sensor
    • if distance < 10 cm, Red LED on
    • if distance > 20 cm, Green LED on
    • else, Yellow LED on

Signal

GND

Vcc

lab 3 accelerometer
Lab 3: Accelerometer
  • Connect the accelerometer module to Taroko
  • Configure a GPIO pin as a supply voltage source for the accelerometer module
  • configure the ADC to take samples from multiple input channels
  • Configure the LEDs
    • when accelerate in +X direction, turn on Red LED; accelerate in -X direction, turn off Red LED
    • when accelerate in +Y direction, turn on Green LED; accelerate in -Y direction, turn off Green LED
    • when accelerate in +Z direction, turn on Yellow LED; accelerate in -Z direction, turn off Yellow LED