Presentation is loading. Please wait.

Presentation is loading. Please wait.

Timers ME4447 INTRODUCTION TO MECHATRONICS Anthony Wingo Carlos Alzate Jim Kitchen.

Similar presentations


Presentation on theme: "Timers ME4447 INTRODUCTION TO MECHATRONICS Anthony Wingo Carlos Alzate Jim Kitchen."— Presentation transcript:

1 Timers ME4447 INTRODUCTION TO MECHATRONICS Anthony Wingo Carlos Alzate Jim Kitchen

2 Introduction Anthony Wingo……………A brief look back in time Carlos Alzate……………....555 chip and applications Jim Kitchen………………..HC11 and timing functions

3 A look at how the timer has evolved. Provides earliest evidence of day and night seperation Had to be made for specific latitudes Sundial from about 16 th century B.C.

4 The sundial works fine, if it is used on an unclouded day. A look at how the timer has evolved. Sundial from about 16 th century B.C.

5 The clepsydra was an improvement over the sundial. This device could be used during the day or night. Adjustments could be made to account for seasonal changes. Could be used only to measure pre-determined periods of time. Clepsydra from about 15 th century B.C.

6 Astrolabe from about 2 nd century A.D. Has ability to find and measure time Based on map constructed by Hipparchus around 150 B.C. Helped in construction of sundials.

7 Candle Clock from about 9 th century A.D. Inserting a nail at a pre-determined location, the candle clock could be used as a timer. Imagine interfacing this idea with the HC11.

8 Hour Glass came probably from Europe before the 14 th century. The medium flowed from one end through a passage that is 10 times larger than the medium particles. Sailors used the hour glass to calculate speed at sea.

9 Weight driven clock from 1270s and probably Europe. Time of invention as well as inventor is still unknown.

10 Spring driven clock from around 15 th century A.D. Bringing the tower clocks into homes. Prone to inaccuracy due to the mainspring

11 Pendulum Clock by Christiaan Huygens in 1656 First clock to count seconds. Galileo started the idea but died before implementing it. Accuracy was increased to a loss of only a few seconds per day.

12 Quartz watch Marrison and Horton in 1927 Quartz to be discussed later in the 555 section.

13 Cesium atomic clock Britain's National Lab 1955 Most accurate of any time-keeping device described. Not very portable or cost efficient in small projects Accuracy of 2 nanoseconds/day or 1 second per 1,400,000 years.

14 555 Timer What is the 555 Timer 555 schematic Pin Configurations Monostable Mode Astable Mode

15 What is the 555 Timer? Integrated Circuit Transistors, Diodes, Resistors Designed and invented in 1970 by Hans R. Camezind

16

17 Pin Configurations

18 Monostable Mode

19 Monostable Output Voltage

20 Monostable Characteristics Generates a single pulse of a fixed time duration each time it receives an input trigger pulse Length of pulse depends on when the capacitor reaches 66.6% V Length of pulse is given by:

21 Monostable Applications Turning a circuit or external component on / off for a specific length of time Generate delays Multiple pulses can be used to time and sequence other related applications

22 Astable Mode

23 Astable Output Voltage

24 Animation http://www.williamson-labs.com/480_555.htm

25 Astable Characteristics Outputs continuous stream of pulses Triggers from previous output pulse Frequency of series of pulses

26 Astable Applications Create an accurate clock signal Modulate transmitters such as ultrasonic and IR transmitters Turn on / off actuator at set intervals for a fixed duration

27 HC11 Timer Functions Fast Fact: Of 64 Register on the HC11, 29 are used for timing functions

28 HC11 Timer Functions Port A Main Timer Measuring Long Times –Prescaler –24-bit time Inputs –Input Capture –Pulse Accumulator Outputs –Output Compare –Real Time Interrupts

29 Port A PA7PA6PA5PA4PA3PA2PA1PA0 Port A$1000 OC1 PAIOC2OC3OC4 OC5/ IC4IC1IC2IC3 DDRA7PAENRTR0 PACTL $1026 PAMOD PEDGEDDRA3I4/O5RTR1 01234567 PA7 direction is changed by setting DDRA7 PA3 direction and function is changed by setting DDRA3 and I4/O5

30 Main Timer The HC11 Timer is a 16-bit read-only register Rolls over (overflows) from $FFFF to $0000 every 0.5μs*2 16 = 32.768ms Bit 15 - Bit 8 Bit 7Bit 0 TCNT $100F $100E ----- ------

31 Main Timer When the main timer overflows, the TOF flag is set If the TOI bit is set, an overflow will also generate an interrupt TOF RTIF0 TFLG2$1025 PAOVF PAIF000 01234567 TOI RTIIPR0 TMSK2$1024 PAOVI PAII00PR1 01234567

32 Measuring Long Times: Prescaler The prescaler will slow down the increments of the main timer, allowing for recording of longer time intervals E-Clock rate is divided by: 1, 4, 8, or 16 –Default prescale factor is 1 –Must be set during the first 64 E-Clock cycles after reset Trade-off between resolution and time between overflows

33 Measuring Long Times: Prescaler TOIRTII PR0 TMSK2$1024 PAOVI PAII00 PR1 01234567 Prescale Factor E Clock = 2MHz PR1PR0 Resolution (one count) Range (Overflow) Frequency (Overflow) 1 4 8 16 0.5  s 2.0  s 4.0  s 8.0  s 32.77 ms 131.1 ms 262.1 ms 524.3 ms 30.5 Hz 7.63 Hz 3.82 Hz 1.91 Hz 00110011 01010101 Prescaler is set with bits PR1 and PR0

34 Measuring Long Times: 24-bit time 24-bit time can be used to extend the range of the timer Accomplished by storing the # of overflows that have occurred in a memory location Store and compare 24-bit times: increases the range from 32.8 ms to 8.4 s Better resolution than prescaler, but harder to implement

35 Measuring Long Times: 24-bit time If you only need to measure one long time, store the timer reading at t 1 (16-bit), and reset the # of overflows counter When the final time is recorded, calculate the time elapsed by: t = (t 2 – t 1 ) + (# of overflows)*2 16

36 Important Note In almost all timer functions, several common things happen –A flag is set (must be cleared by user) –An interrupt can be generated (optional) –An event happens, dependent on the function being used

37 Inputs: Input Capture Used to record the clock time when an edge is detected on one of the input pins The time is stored in a register (read-only) by storing the contents of the free-running counter in the input capture registers (16-bits) Bit 15 - Bit 8 Bit 7Bit 0 TIC1 $1011 $1010 Bit 15Bit 8 Bit 7Bit 0 TIC2 $1013 $1012 Bit 15Bit 8 Bit 7Bit 0 TIC3 $1015 $1014 ----- ------ ------ ------ ------ ------

38 Inputs: Input Capture Configuration EDGxBEDGxA Capture Disabled00 Capture on Rising Edge Only01 Capture on Falling Edge Only10 Capture on Any Edge11 EDG3A TCTL2$1021 01234567 EDG3BEDG2AEDG2BEDG1AEDG1BEDG4AEDG4B Which edge to capture on can be configured with the TCTL2 register

39 Inputs: Input Capture Flags are set when a capture is made Interrupts can be generated if the mask bits are set OC1FOC2F IC3F TFLG1$1023 OC3FOC4FOC5F IC1FIC2F 01234567 OC1IOC2I IC3I TMSK1$1022 OC3IOC4IOC5I IC1IIC2I 01234567

40 Inputs: Pulse Accumulator The pulse accumulator is an 8-bit counter (read and writeable) It will count the # of pulses coming into PA7 when configured to do so It can also be used to measure the pulse width

41 Inputs: Pulse Accumulator PACNT $1027 –8 Bit PA Count PACTL $1026 –Data Direction for PA7 Pin –PA Enable –PA Mode –PA Edge B7 B0 B6B5 PA EN PA MOD PA EDGE B4 DDR A7 B7

42 Inputs: Pulse Accumulator TFLG2 $1025 –PA Overflow Flag –PA Input Edge Flag TMSK2 $1024 –PA Overflow Interrupt Enable –PA Input Edge Interrupt Enable PA OVF PA IF B4 B5 PA OVI PA II B4 B5

43 Inputs Applications: –User input (buttons, etc.) –Counting events (products on an assembly line with pulse accumulator) –Length of input (how long a button is held) Morse Code

44 Outputs: Output Compare Output compare lets you change an output pin when the main timer matches a specified time Along with the output pin, output compare will set a flag, and optionally generate an interrupt The comparison is done in hardware – basically free computing time

45 Outputs: Output Compare For Output Compare 2-5, Each Compare Register controls a single pin TCTL1 register determines how each pin changes when the comparison matches Output Compare 2PA6 Output Compare 3PA5 Output Compare 4PA4 Output Compare 5PA3 OM2OL2OM3OL3OM4OL4OM5OL5 $1020 OMxOLxPin Configuration 00Do nothing to pin 01Toggle pin on match 10Clear pin on match 11Set pin on match TCTL1

46 Outputs: Output Compare Output Compare 1: Causes 5 Port A pins to change simultaneously (PA3-PA7) Notice PA3-PA6 are also used by Output Compares 2-5 OC1M7OC1M6OC1M5OC1M4OC1M3000 OC1M Register determines which Port A Pins will be Controlled by Output Compare 1 OC1D7OC1D6OC1D5OC1D4OC1D3000 OC1D Register sets value to be written to Port A pins selected in OC1M PA7PA6PA5PA4PA3 OC1M $100C OC1D $100D

47 Outputs: Output Compare When Output Compare is successful it sets corresponding Flag in TFLG1 Control Register: OC1FOC2FOC3FOC4FOC5F IC1F TFLG1 $1023 Output Compare 1 Output Compare 2 Output Compare 3 Output Compare 4 Output Compare 5 OC1IOC2IOC3IOC4IOC5I IC1F TMSK1 $1022 Output Compare 1 Output Compare 2 Output Compare 3 Output Compare 4 Output Compare 5 It can also generate an interrupt if the appropriate mask bits are set

48 Outputs: Real-Time Interrupt Similar to the prescalar concept Generates hardware interrupts at one of four fixed rates Sets a flag at each interrupt Easier to use than generating output comparisons each time Limited to only 4 specific rates

49 Outputs: Real-Time Interrupt TMSK2 $1024 –Real-Time Interrupt Enable TFLG2 $1025 –Real-Time Interrupt Flag PACTL $1026 –Real-Time Interrupt Rate Selects RTII B6 RTIF B6 B0 RTR0RTR1 B1

50 Outputs: Real-Time Interrupts For 8MHz Crystal Frequency (2MHz E Clock) RTR1RTR0E/2 13 Divided ByRTI RateRTI Frequency 0014.10 ms244 Hz 0128.19 ms122 Hz 10416.38 ms61.0 Hz 11832.77 ms30.5 Hz

51 Outputs Applications: –Pulse Width Modulation with Output Compares –Create a delay, but use the wait productively Read the clock time Create an output compare with an offset –Drive a stepper motor with RTI

52 References/ Acknowledgements http://www.briticanna.com/clockworks http://www.me.gatech.edu/mechatronics_lab/ http://www.uoguelph.ca/~antoon/gadgets/555/55 5.html http://www.electronics- tutorials.com/devices/555.htm http://www.williamson-labs.com/480_555.htm The “Crazy J” Groups Timer Slides M68HC11 Reference Manual


Download ppt "Timers ME4447 INTRODUCTION TO MECHATRONICS Anthony Wingo Carlos Alzate Jim Kitchen."

Similar presentations


Ads by Google