Peripherals and their Control An overview of industrially available - PowerPoint PPT Presentation

1 / 27
About This Presentation
Title:

Peripherals and their Control An overview of industrially available

Description:

Title: Possible PWM Microprocessor Peripherals Last modified by: smith Created Date: 1/1/1601 12:00:00 AM Document presentation format: On-screen Show (4:3) – PowerPoint PPT presentation

Number of Views:57
Avg rating:3.0/5.0
Slides: 28
Provided by: enelUcalg
Category:

less

Transcript and Presenter's Notes

Title: Peripherals and their Control An overview of industrially available


1
Peripherals and their ControlAn overview of
industrially available peripheral devicesthat
use pulse-width modulation for information
passing.
  • Review for Midterm Quiz. Help for Lab. 2, Part
    of Lab. 3

2
To be tackled today
  • Analog Output Devices
  • These could be handled via A/D as we did with an
    audio signal in Lab. 1. Depends on amplitude and
    frequency of the signals generated by the
    devices.
  • Digital Output modulated pulse width use GPIO
    pin
  • Handle with PF interface as with switches
  • TSL230R Light sensor
  • ADI - TMP03 thermometer
  • ADXL213 Dual Axis Accelerometer
  • SPI devices use SPI interface 4lines control
    many devices
  • LCD screen using a serial parallel converter
  • MC33993 Multiple -- Switch Detection Interface
  • ADIS16003 accelerometer and temperature sensor

3
ADI TMP03 Serial Digital Output Thermometer
Use the same ideas to measure light
intensity(TSL230R Light Sensor) or acceleration
(ADXL213 Dual Axis Accelerometer)
GROUND WIRE 5VPF8 connection on Blackfin
Interface
4
Serial Digital Output Signal from TMP03
  • Say temperatures from minus 40C to plus 100 to be
    measured
  • Value converted into pulse length information
    digital signal
  • Transmitted over a single wire to PF8 pin

5
SKIP TMP03 Output characteristics
6
SKIP Block diagram for the TMP03
7
SKIP -- More information on the sigma-delta
modulator used to generate TMP03 output
8
ADXL213 Dual Axis AccelerometerTwo pulse width
modulated signal
PF9 PF10
9
MMA6260Q
  • How thisacc. works

10
ADXL213 Dual Axis AccelerometerOutput PWM signal
when used as tilt sensor
X 50Y 80
X 50Y 20
X 50Y 50
11
Design problem first part of Lab. 3Based on
record switches from Lab. 2
  • You are to design a digital thermometer based
    around the ADI TMP03 thermal sensor and using the
    Blackfin LED block as a temperature bar graph.
  • One of the LEDs must flash at 1 / 8 second
    intervals to show normal system operation
  • To be understood later -- Compare and contrast
    how you would design the software and configure
    the hardware for operation with a co-operative
    scheduler (Lab. 2) and a pre-emptive scheduler

12
Basically five tasksthat need designing
  1. Initialize interfaces
  2. Accurately measurewhen (at what time)the TMP03
    output voltages change
  3. Convert those times into T1, T2 measurements and
    then calculate temperature in degrees
  4. Display temperature on LEDs as bar graph OFF
    ON OFF OFF OFF 8 C
  5. Flash LED 6

13
  • void Task5_FlashLED6(void)
  • Code already done represents a task whose
    operation cant be disrupted by other tasks
  • void Task4_DisplayTemperature(void)
  • Update every 1 / 4 second would be enough
  • Task picks up information from a global
    temperature variable
  • Provided LED interface has been initialized then
    can use WriteLEDASM( ) to do the display global
    temperature variable

14
void Task3_CalculateTemperature(void)
  • Runs as fast as the display Task
  • Picks up information about T1 and T2 from global
    variables when these become available
  • Does calculation
  • Places result (temperature)where the display
    task can find it
  • Test by putting in known value for temperature
    (20C) and then setting T2 200 and calculate T1.
    Now use those T1 and T2 values to check
    calculation gives 20C

15
void Task1_HardwareInitialization(void)
  • Run once
  • Already have the code to initialize GPIO flags
    for input and code to initialize the Flash Memory
    to control LED
  • Does not look like we have any other hardware to
    control, but if do, add the necessary code to
    initialize

16
void Task2_MeasureTimes(void)
  • Using ReadGPIOFlags( )
  • Needs to accurately measure the precise time when
    the TMP03 output goes from low to high, high to
    low, and low to high
  • Once those values are known then can easily
    calculate T1 and T2 values and pass those onto
    CalculateTemperature TASK
  • Attempt 1 make Task2 into a waiting task
    that looks for the voltage changes in TMP03 output

17
Using a waiting approach
  • StartTimer (Assignment 2)
  • Read PF8 voltage level
  • While PF8 level is low wait
  • Record time A
  • While PF8 level is high wait
  • Record time B
  • While PF8 level is low wait
  • Record time C
  • T1 TimeB TimeA, T2 TimeC - TimeB

18
Problem we dont know when we will enter the
code and start measuringthe voltage levels (Mid
term hint)
A2 B2 C2
A1 B1 C1
Enter code at this time T1 accurate
Enter code at this time T1 inaccurate too
short
  • Solution five loops not three
  • Wait low (discard Time), Wait high (discard Time)
  • Wait low (record A), Wait high (record B), Wait
    low (record C)

19
The voltage measuring code look as if it is 4
tasks that operate one after the other
  • Init hardware
  • In loop
  • Measure T1 and T2 -- wait loops (slow)
  • Calculate Temperature -- fast
  • Display Temperature -- fast
  • Wait loop stops Task 5 (LED FLASH) from working
  • Many possible solutions
  • Co-operative scheduler is one possible

20
Co-operative Scheduler
  • Divide Time into segments frames
  • Each task is allotted its own time segment
  • Must guarantee that each task will run to
    completion in a way that allows all other tasks
    to start and complete as they need
    (predictability requirement).

Timer interrupt every ?? ms
T1 runs T2 runs T3 runs T4 runs T5
runsInit Measure Calc
Display Flash
Timer interrupt
XXXX T2 runs T3 runs T4 runs T5
runs
21
Current T1 and T2 measure task (Task 2) does not
satisfy this requirement
  • Uses five wait loops blocks other tasks
  • Wait low (discard Time), Wait high (discard Time)
  • Wait low (record A), Wait high (record B), Wait
    low (record C)
  • Solution break the task into smaller tasks that
    all satisfy this requirement of not blocking any
    other task

22
Task 2 has 7 states
  • Waiting while low -- STATE_LOW1
  • Waiting while high -- STATE_HIGH1
  • Waiting while low -- STATE_LOW2
  • Record time -- STATE_RECORD1
  • Wait while high -- STATE_HIGH2
  • Record time etc
  • Wait while low
  • Record time

23
So we could code some thing like this.Very
similar to the Lab. 2. Task 8
  • static state STATE_LOW1
  • switch (state)
  • case STATE_LOW1 if
    PF8 is low then return else
    nextState STATE_HIGH1 break case
    STATE_HIGH1
  • if PF8 is high then return
    else nextState STATE_LOW2
    break
  • case STATE_LOW2 if PF8
    is low then return else
    time0 ReadTimer( ) (number of interrupt
    ticks) nextState
    STATE_HIGH2 break ETC
  • end switchstate nextState

24
Co-operative scheduler
  • No task is blocked
  • Each task runs at a predictable time
  • But we can only measure the transitions between
    levels at best with an accuracy of the 1 or
    1 timer tick
  • Is this accurate enough for measuring temperature?

25
Temperature accuracy calculation
26
Final program using co-operative scheduler
  • InitScheduler( ) with adjusted timer interrupt
    settings
  • AddTask(InitHardware, NO_DELAY, RUN_ONCE)
  • AddTask(Measure, NO_DELAY, 1)
  • AddTask(Calculate, QUARTER_SECOND,
    QUARTER_SECOND)
  • AddTask(Display, 3/8 seconds, QUARTER_SECOND)
  • AddTask(FlashLED6, NO_DELAY, EIGHTH_SECOND
  • StartScheduler( )
  • Loop
  • GotoSleepTillInterrupt
  • Dispatch Tasks
  • Very easy to be able to add additional tasks and
    understand changes of system performance

27
Reference Information
  • Pictures are taken from various data sheets
    available from the Analog Devices and Freescale
    (Motorola) web sites
  • Proposed use of devices are for concept purposes
    only and no guarantee is made regarding suitable
    of circuits suggested
  • Application notes are also available on the
    website
Write a Comment
User Comments (0)
About PowerShow.com