+ All Categories
Home > Documents > Issues surrounding Lab. 3 and Lab. 4

Issues surrounding Lab. 3 and Lab. 4

Date post: 06-Jan-2016
Category:
Upload: fausta
View: 29 times
Download: 0 times
Share this document with a friend
Description:
Issues surrounding Lab. 3 and Lab. 4. Lab. 3 – Accurate timing to measure temperature Lab. 4 – Accurate timing signals to send temperature value to LCD screen. How accurate does the temperature sensor timings need to be?. T = 255 – 400 * T1 / T2 If T = 25 then T1 / T2 = 230 / 400 - PowerPoint PPT Presentation
25
Issues surrounding Lab. 3 and Lab. 4 Lab. 3 – Accurate timing to measure temperature Lab. 4 – Accurate timing signals to send temperature value to LCD screen 1
Transcript
Page 1: Issues surrounding  Lab. 3 and Lab. 4

1

Issues surrounding Lab. 3 and Lab. 4

Lab. 3 – Accurate timing to measure temperature

Lab. 4 – Accurate timing signals to send temperature value to LCD screen

Page 2: Issues surrounding  Lab. 3 and Lab. 4

2

How accurate does the temperature sensor timings need to be?

T = 255 – 400 * T1 / T2

If T = 25 then T1 / T2 = 230 / 400Where T1 + T2 is around 1 / 30 s so T1 around 1/90 s

Can use these ideas to validate CalculateTemp( ) task Part of the testing procedure for Lab. 3 – T is a float 25.4 etc whereas T1 and T2 are “counts” – see last lecture

Page 3: Issues surrounding  Lab. 3 and Lab. 4

3

How accuracte do we need to measure T1 and T2

T = 255 – 400 * T1 / T2 – Differentiate to get error estimates

Worse case -- all errors add updT = 400 * dT1 / T2 + 400 * T1 * dT2 / T2 ^ 2

Percentage error calculations dt / T, dT1 / T1, dT2 / T2dT / T = 400 * dT1 / T2 / T + 400 * T1 * dT2 / T2 ^ 2 / T

For T = 25 C and T1 and T2 around 1 / 60 s – If 1% error in T1 and T2 what is accuracy in T

Page 4: Issues surrounding  Lab. 3 and Lab. 4

4

Back of envelope calculationCLICKER RESPONSE 1

Percentage error calculations dT1 / T1, dT2 / T2 = 1%dT / T = 400 * dT1 / T2 / T + 400 * T1 * dT2 / T2 ^ 2 / T

dT / T = dT1 / T1 * 400 * T1 * / T2 / T + dT2 / T2 * 400 * T1 / T2 / T

= 1% * 400 * (1/90) / (1/45) / 25 + 1% * 400 * (1/90) / (1/45) / 25

What is accuracy in dT / T for 1% accuracy in T1 and T2A) Better than 1% B) around 2% C) around 4% D) worse than 6%

Page 5: Issues surrounding  Lab. 3 and Lab. 4

5

We need to find the rising edge of TMP03 signal shape – better than 1%

• Rising edge is “looked for” every PERIOD where period is fraction of milliseconds– TTCOS(MeasureTemp, NO_DELAY, Milli-Seconds)

• If another task gets executed then accuracy of Measure Temp( ) is lost– TTCOS(FlashLED, NO_DELAY, 1/20 S)– TTCOS(MeasureTemp2, NO_DELAY, Milli-Seconds)– TTCOS(MeasureTemp3, NO_DELAY, Milli-Seconds)

Page 6: Issues surrounding  Lab. 3 and Lab. 4

6

Solve this problem by“time multiplexing tasks – pre-schedule”

TTCOS(LED6, NODELAY, EVERY_SECOND / 2)TTCOS(LED5, NODELAY + 1ms, EVERY_SECOND / 2)TTCOS(AllTasks, NODELAY + 2 ms, EVERY_SECOND)TTCOS(Lab4_SPI_LCD

where AllTasks( ) isTTCOS(Temp1, NODELAY, RUN_ONCE) // Measure 4 or 5 TimesTTCOS(Destroy_Temp1, 180MS_DELAY, RUNONCE)TTCOS(Temp2, 360MS_DELAY, RUN_ONCE) TTCOS(Destroy_Temp2, 450MS_DELAY, RUNONCE)

SEE “SMITH” ARTICLE IN CLASS NOTES (ARTICLE 1) – POSSIBLE MIDTERM QUESTION

0 ms 1 ms 2 ms 182 ms 362 ms 452 ms 500 ms 501 ms 502 ms

LED6 LED 5 Temp1 Destroy Temp1

Temp2 DestroyTemp2

LED6 LED5 SPI_LCD(Lab. 4)

Page 7: Issues surrounding  Lab. 3 and Lab. 4

7

NOW MOVING PAST MIDTERM QUESTIONS(Up to and including Lab. 2)

And into Post Lab Quiz 3 and Final exam material

REMINDER: ENCM511 MIDTERMTHURSDAY 5th NOVEMBER 6:30 till 8 PMENA 103

Page 8: Issues surrounding  Lab. 3 and Lab. 4

8

Loss of battery power

• Basically the TemperatureMeasuring tasks are running every 0.1 ms– Use a lot of battery power– Basically waiting for something to happen

• Measure more accurately using “Hardware” – Blackfin has 3 GENERAL PURPOSE TIMERS to solve

this problem – (automotive industry and other embedded applications

Page 9: Issues surrounding  Lab. 3 and Lab. 4

9

TTCOS using GP TimerTTCOS(AllTasks, NODELAY + 2 ms, EVERY_SECOND)

Where AllTasks( ) launches the 2 tasks TTCOS(ActivateTimer, NO_DELAY, RUN_ONCE) TTCOS(CheckTimer, DELAY_100ms, RUN_ONCE)

Where CheckTimer( ) is the task If GP Timer DONE-FLAG is set, read T1 and T2 values

(to an accuracy of 1 / 1,000,000 s accuracy)else TTCOS(CheckTimer, DELAY_100ms, RUN_ONCE)

Check again in a short while that timer has completed

See article 3 in the class notes

Page 10: Issues surrounding  Lab. 3 and Lab. 4

10

Where are the inputs to the GP Timersfor use in Lab. 3?

• Input to 2 of the general purpose timers are on the logic lab break-out panel between the PF pins

• Question – First year these are used – how can we test if they work?

PF1

PF5

PF6

PF7

PF8

PF9

PF10

PF11

RST

GP 2 GP 1

Page 11: Issues surrounding  Lab. 3 and Lab. 4

11

Reference material for TimersChapter 15 Blackfin Hardware manual

– see class notes

Page 12: Issues surrounding  Lab. 3 and Lab. 4

12

Page 13: Issues surrounding  Lab. 3 and Lab. 4

13

Timer behaves like McVASH in principle, but not in detail

Page 14: Issues surrounding  Lab. 3 and Lab. 4

14

Q2 Watch out how access registers fromC and assembly code

Page 15: Issues surrounding  Lab. 3 and Lab. 4

15

Watch out how access registers fromC and assembly

Next question is clicker

Page 16: Issues surrounding  Lab. 3 and Lab. 4

16

Q2 -- Which instruction will cause Blackfin to crash

A) *pTIMER_ENABLE = 0x3456;

P0.L = lo(TIMER_ENABLE);P0.H = hi(TIMER_ENABLE); R0 = 0x3456;

thenB) [P0] = R0;C) W[P0] = R0;D) B[P0] = R0;

Page 17: Issues surrounding  Lab. 3 and Lab. 4

17

Task_ActivateTimerStart AFTER setting other registers

• Used to start timer -- use OR operation

• Stop timer – W1C – DO NOT USE OR, DON’T USE AND

Page 18: Issues surrounding  Lab. 3 and Lab. 4

18

Task_Has_Timer_Captured_SignalRun once – ignore, use second result

• Timer changes these bits from 0 to 1• You must write 1 into these bits to change to 0

POLL FOR THISBIT TO CHANGE

Page 19: Issues surrounding  Lab. 3 and Lab. 4

19

TIMER0_CONFIG, TIMER1_CONFIG

DISABLEINTERRUPTSAS WEARE POLLINGTHE TIMERS

Page 20: Issues surrounding  Lab. 3 and Lab. 4

20

Read the PERIOD and WIDTH – ONLY after device has indicated it is ready

Page 21: Issues surrounding  Lab. 3 and Lab. 4

21

How are we going to test?• Hook up PF7 (output) to PF8 (input)• Hook up PF7 (output) to “Timer 0” (input)

• InitGPIOFlags( ); (Lab. 1)• ChangePF7_to_Output( );• Switches = Read GPIOFlags( ); Lab. 1• CHECK(PF8 (SW1) == 0);• WriteGPIOFlags(PF7) – turns PF8 on• Switches = Read GPIOFlags( ); Lab. 1• CHECK(PF8 (SW1) == 0);• THIS CHECKS THAT PF7 works as an output

PF1

PF5

PF6

PF7

PF8

PF9

PF10

PF11

RST

GP 2?GP 1?

GP 1?GP 0?

Page 22: Issues surrounding  Lab. 3 and Lab. 4

22

Write a Routine that activates all timers in Pulse capture mode

• InitGPIOFlags( )• TurnPF7 to output ( )• Turn on all timers( ) • For count = 1 to 8

– WaitAWhile(4000);– WritePFFlags(PF7); -- pulse on– WaitAWhile(8000);– WritePFFlags(0); , pulse off

• Turn off All timers ( )• Check the Timer status register to see which timer is being

pulsed – its IRQ request should be set

Page 23: Issues surrounding  Lab. 3 and Lab. 4

23

Q3 -- If timer 2 is active and captured signalWhat value when read STATUS?

A) 0x02 B) 0x04 C) 0x22 D) 0x44

Page 24: Issues surrounding  Lab. 3 and Lab. 4

24

Q4 -- If both timer 1 and timer 2 are active, what operation clears "timer 1 done flag" (bit 1 TIMIL1 -- W1C)?

A) Read STATUS, AND with ~0x2, Write STATUSB) Write STATUS with 0x2C) Read STATUS, OR with 0x1, Write STATUS D) Read STATUS, OR with 0x2, Write STATUS

Page 25: Issues surrounding  Lab. 3 and Lab. 4

25

For Lab. 3 need to slightly modify“time multiplexing tasks – pre-schedule”

TTCOS(LED6, NODELAY, EVERY_SECOND / 2)TTCOS(LED5, NODELAY + 1ms, EVERY_SECOND / 2)TTCOS(AllTasks, NODELAY + 2 ms, EVERY_SECOND)TTCOS(Lab4_SPI_LCD

where AllTasks( ) isTTCOS(Temp1, NODELAY, RUN_ONCE) // Measure 4 or 5 TimesTTCOS(Destroy_Temp1, 180MS_DELAY, RUNONCE)

SEE “SMITH” ARTICLE IN CLASS NOTES (ARTICLE 1 AND ARTICLE 3)

0 ms 1 ms 2 ms 182 ms 362 ms 452 ms 500 ms 501 ms 502 ms

LED6 LED 5 Temp1 Destroy Temp1

LED6 LED5 SPI_LCD(Lab. 4)


Recommended