1 / 17

Line Sensing 101

Line Sensing 101. TEAM SpeedRacers _______ Team Leader _______ Hardware Specialist _______ Software Specialist _______ Assistant. Overview. Problem statement Hardware requirements / constraints interface Software MCU module(s) needed code for initialization, operation Q&A.

etta
Download Presentation

Line Sensing 101

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. Line Sensing 101 TEAM SpeedRacers _______Team Leader _______ Hardware Specialist _______ Software Specialist _______ Assistant

  2. Overview • Problem statement • Hardware • requirements / constraints • interface • Software • MCU module(s) needed • code for initialization, operation • Q&A

  3. Problem Statement • Line Sensing: to determine relative position of track line beneath car. • Line is ¾" wide black on white background • electrical tape • sample 8.5"x11" on website Line Sensor MCU

  4. Hardware • Pololu QTR-8RC Reflectance Sensor Array • module of 8 IR LED/phototransistor element pairs

  5. QTR-8RC Reflectance Sensor Array Specifications: • Dimensions: 2.95" x 0.5" x 0.125" (without header pins installed) • Operating voltage: 3.3-5.0 VDC • Supply current: 100 mA (all IRLEDs on) • Output format: digital I/O compatible • Optimal sensing distance: 0.125" (3 mm) • Max recommended sensing distance: 0.375" (9.5 mm) • Weight without header pins: 0.11 oz (3.09 g)

  6. QTR-8RC Reflectance Sensor Array Operation: • each element has an R-C circuit • capacitor discharge rate is a function of reflected IR light • greater reflectance = shorter discharge time • algorithm: • C is 1st charged by driving it with a high output from an MCU I/O pin (~16us, use 20 to be safe) • I/O pin is switched to input and time to HL transition is measured • or simply wait for time 'x' and read H or L input

  7. Scope Shots* Output (yellow) 1/8" above white surface and MCU timing (blue) Output (yellow) 1/8" above black line and MCU timing (blue) * see data sheet for link to hi-res image

  8. Interface • QTR-8RC is interfaced to an 8-bit MCU I/O port via a ribbon cable and breadboard adapter

  9. Software: Algorithm • Turn on IR LEDs (if off) • Set 8-bit I/O port to all outputs • Set output port to all highs • First Delay (20us) • Set I/O port to all inputs • Second Delay (?) • Read 8-bit H/L input value • Turn off IR LEDs (opt.)

  10. Software Implementation • to achieve us delays, we will need to employ the MCU's timer peripheral (TPM1) • and also speed up the MCU from 4 MHz default to 24 MHz (using the MCG) • QTR-8RC is interfaced to I/O portB

  11. Software: Initialization // initialize MCG module to use external crystal void MCGinit() { MCGC1 = 0x1c; // set RDIV = 12MHz/8 = 1.5MHz MCGC2 = 0x64; // BDIV=2, enable ExtRef and Hi Range MCGC3 = 0x48; // select PLL source and VDIV= x32 // VCO is now going to 48 MHz MCGC1_IREFS = 0; // turn off IREFS while (!MCGSC_LOCK) {} // wait for OSC initialization to complete // MCGOUT=24Mhz, Busclk=12MHz } // MCU-specific initialization void initializeMCU() { SOPT1_COPT = 0; // disable COP SOPT2_CLKOUT_EN = 1; // enable BUSCLK output on PTF4 MCGinit(); // activate MCG for 24 MHz clock // I/O port initialization FB_YLED_ENABLE; // set PTE6 to be output (to yellow LED) // Real-Time Counter initialization RTCSC = 0x08; // enable RTC, select 1ms period from 1kHz internal clock RTCMOD = 9; // RTIF every 10ms // TPM1 initialization TPM1SC = TPM1SC_CLKSA_MASK // select bus clock for timer clock + 2; // divby-4 prescaler (12MHz / 4 = 3MHz Timer clock) EnableInterrupts; }

  12. Software: Timing Support • usDelay() is similar to previous msDelay() except much higher clock source is used • 12 MHz bus clock instead of 1 kHz LPO void usDelay(unsigned short n) { word timerticks = 3*(n-1); // x3 because Timer is clocked at 3MHz word startcnt = TPM1CNT; // wait for time to elapse while ((word)(TPM1CNT-startcnt) < timerticks) {} }

  13. Software: Line Sensing byte read_irarray() // read & return line sensor data { PTBD = 0xff; // make Port B all highs PTBDD = 0xff; // make Port B all outputs usDelay(20); // allow sensor caps to charge PTBDD = 0; // switch to all inputs usDelay(600); // delay for discharge return PTBD; // read & return sensor array results } • when line position data is needed, a call to "read_irarray" is made • ex: byte irdata;∶irdata= read_irarray();

  14. Performance Issue • Considering amount of power required to drive the IRLEDs and the sensor sample rate, a huge power savings would be achieved if IRLEDs are turned off between readings. • Ex: if LEDs are on 1ms and sensor is read at 10Hz, the D.C. of the LEDs is 1ms/100ms = 1% • applied to the 100 mA!

  15. Summary • Problem statement • Hardware • requirements / constraints • interface • Software • MCU module(s) needed • code for initialization, operation

  16. References • Huang, Han-Way. HCS12/9S12: An Introduction to Software and Hardware Interfacing. 2nded. Delmar, Cengage Learning, 2010. • MCF51JM128 ColdFire Integrated Microcontroller Reference Manual. 2. Freescale Semiconductor, Inc., 2009. Web.http://www.aet.calu.edu/ftp/cet/360/resources/Coldfire/MCF51JM128-RefManual-v2.pdf. • QTR-8RC Reflectance Sensor Array." Pololu -. N.p., n.d. Web. 18 Feb. 2014. http://www.pololu.com/catalog/product/961 • Sumey, Jeff. “CET Microprocessor Engineering.” California University of Pennsylvania. Web. 18 Feb 2014. http://aet.calu.edu/~jsumey.

  17. QUESTIONS?

More Related