Presentation is loading. Please wait.

Presentation is loading. Please wait.

Line Sensing 101 TEAM SpeedRacers _______ Team Leader

Similar presentations


Presentation on theme: "Line Sensing 101 TEAM SpeedRacers _______ Team Leader"— Presentation transcript:

1 Line Sensing 101 TEAM SpeedRacers _______ Team Leader
_______ Hardware Specialist _______ Software Specialist _______ Assistant

2 Overview Problem statement Hardware Software Q&A
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:  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 32 MHz (using the MCG) QTR-8RC is interfaced to I/O portB

11 Software: Initialization
// Initialize MCG module for high-speed operation void MCGinit_fll() { // IREFS=1 (default), also select IREFSTEN MCGC1 = MCGC1_IREFS | MCGC1_IREFSTEN; MCGC2 = 0; // switch to BDIV=1 MCGC4 = 0x01; // select mid DCO range in FLL (FLL factor=1024) while (!MCGSC_LOCK) {} // wait till FLL acquires lock // MCGOUT=CPUclk=32Mhz, Busclk=16MHz (with proper trim value) } // MCU-specific initialization void initializeMCU() SOPT1_COPT = 0; // disable COP SOPT2_CLKOUT_EN = 1; // enable BUSCLK output on PTF4 MCGinit_fll(); // activate MCG for 32 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 + ?; // divby-16 prescaler (16MHz/16 = 1MHz Timer clock) EnableInterrupts;

12 Software: Timing Support
usDelay() is similar to previous msDelay() except much higher clock source is used 1 MHz timer clock instead of 1 kHz LPO void usDelay(unsigned short n) { word startcnt = TPM1CNT; // wait for time to elapse while ((word)(TPM1CNT-startcnt) < n) {} }

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(???); // 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 Software 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. 2nd ed. Delmar, Cengage Learning, 2010. MCF51JM128 ColdFire Integrated Microcontroller Reference Manual. 2. Freescale Semiconductor, Inc., Web. QTR-8RC Reflectance Sensor Array." Pololu -. N.p., n.d. Web. 18 Feb Sumey, Jeff. “CET Microprocessor Engineering.” California University of Pennsylvania. Web. 18 Feb

17 QUESTIONS?


Download ppt "Line Sensing 101 TEAM SpeedRacers _______ Team Leader"

Similar presentations


Ads by Google