1 / 25

Issues surrounding Lab. 3 and Lab. 4

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

tarika
Download Presentation

Issues surrounding Lab. 3 and Lab. 4

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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

  2. How accurate does the temperature sensor timings need to be? T = 255 – 400 * T1 / T2 If T = 25 then T1 / T2 = 230 / 400 Where 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

  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 up dT = 400 * dT1 / T2 + 400 * T1 * dT2 / T2 ^ 2 Percentage error calculations dt / T, dT1 / T1, dT2 / T2 dT / T = 400 * dT1 / T2 / T + 400 * T1 * dT2 / T2 ^ 2 / TFor T = 25 C and T1 and T2 around 1 / 60 s – If 1% error in T1 and T2 what is accuracy in T

  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%

  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)

  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

  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

  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

  9. TTCOS using GP Timer TTCOS(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

  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?

  11. Reference material for TimersChapter 15 Blackfin Hardware manual– see class notes

  12. Timer behaves like McVASH in principle, but not in detail

  13. Q2 Watch out how access registers fromC and assembly code

  14. Watch out how access registers fromC and assembly Next question is clicker

  15. Q2 -- Which instruction will cause Blackfin to crash • *pTIMER_ENABLE = 0x3456; P0.L = lo(TIMER_ENABLE); P0.H = hi(TIMER_ENABLE); R0 = 0x3456;then B) [P0] = R0; C) W[P0] = R0; D) B[P0] = R0;

  16. Task_ActivateTimerStart AFTER setting other registers • Used to start timer -- use OR operation • Stop timer – W1C – DO NOT USE OR, DON’T USE AND

  17. 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

  18. TIMER0_CONFIG, TIMER1_CONFIG DISABLEINTERRUPTSAS WEARE POLLINGTHE TIMERS

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

  20. 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

  21. 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

  22. Q3 -- If timer 2 is active and captured signalWhat value when read STATUS? • 0x02 B) 0x04 C) 0x22 D) 0x44

  23. Q4 -- If both timer 1 and timer 2 are active, what operation clears "timer 1 done flag" (bit 1 TIMIL1 -- W1C)? • Read STATUS, AND with ~0x2, Write STATUS • Write STATUS with 0x2 • Read STATUS, OR with 0x1, Write STATUS • Read STATUS, OR with 0x2, Write STATUS

  24. 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)

More Related