1 / 21

Speed Sensing

Speed Sensing. Team: Kicking Asphalt Ryan Dempsey - Team Leader Jordan Severo - Hardware Specialist Matt Bonaddio – Software Specialist John Donofrio - Assistant Hardware Mike Bichsel - Assistant Software. Presentation Overview. Problem Statement Hardware Topics

andie
Télécharger la présentation

Speed Sensing

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. Speed Sensing Team: Kicking Asphalt Ryan Dempsey - Team Leader Jordan Severo - Hardware Specialist Matt Bonaddio – Software Specialist John Donofrio - Assistant Hardware Mike Bichsel - Assistant Software

  2. Presentation Overview • Problem Statement • Hardware Topics • Sensor Specifications • Sensor Mounting • Sensor Wiring • Calculating Distance • Software Topics • Calculating Speed • TPM Initialization • Source Code • References • Q&A

  3. Problem Statement • Continuous tracking of the Smartcar’s real time speed. • Units of centimeters/second. • Measuring distance between two optical encoder holes (rising edges)

  4. Block Diagram

  5. Sensor Wiring (GP1A75 OPIC Photointerrupter) • Pin 1 – VCC – 5V DC {Yellow} • Pin 2 – Vout – to MCU (pin PTF2) {Red} • Pin 3 – GND {Black} *Connect a by-pass capacitor from Vin to GND >0.01uF

  6. Sensor Specifications

  7. Sensor Mounting Tight on bottom and top Eliminates rubbing

  8. Calculating Distance • Wheel Diameter=5.4864cm • Circumference=17.2359cm • 1 full revolution is 8 pulses • With each pulse the car covers 2.15cm

  9. Calculating Speed • Distance travelled (2.15 cm) per logic high • TPM1C4’s input capture mode will trigger an interrupt at every rising edge • Access TPM1C4V to record the time at which the event occurred

  10. Calculating Speed • We need the time between two captures • TachPeriod is a global variable • TachPeriod = (currentcnt-lastcnt)/3 • Dividing by 3 accounts for the 3Mhz clock • Results in a TachPeriod in microseconds

  11. Calculating Speed • Speed = distance / time • currentspeed = 2.15 cm / TachPeriod • But… • That would be in cm per microsecond! • We need cm per second

  12. Calculating Speed • currentspeed = x • currentspeed = = • # define CMPUS 2150000 • currentspeed = CMPUS/TachPeriod

  13. TPM Initialization • TPM1C4SC register is used for control and status of the TPM module • The bits of concern are • CHnF – Interrupt Flag Bit • CHnIE – Interrupt Enable Bit • MSnB – Mode Select Bit • MSnA – Mode Select Bit • ELSnB - Edge Level Select Bit • ELSnA – Edge Level Select Bit • 0b01000100 Will be the value which needs assigned

  14. TPM Initialization – 0b01000100 • The sensor will be producing a rising edge on the detection of a hole • For input capture on rising edge configure TPM as shown 0 1 0 0 0 1 0 0

  15. Source Code • New Constant • Global Variables • Initialization #define CMPUS 2150000 //2.15 cm per reading, multiplied by 1e6 to convert to second Global Variables: int TachPeriod = 0; //Time from one hole to the next on speed sensor int currentspeed = 0; //global result of getSpeed() function Initialization: TPM1C4SC = 0b01000100 //Enables interrupts and input capture mode(rising edge)

  16. Source CodeISR Routine – Tach_isr( void ) interrupt 75 void Tach_isr(void) //interrupt vector 75 is for TPM1 Ch.4 { static int lastcnt = 0; //Previous count at last tach reading int currentcnt = 0; //Initialize current count currentcnt = TPM1C4V; //take current readings from value register TPM1C4SC &= 0x7F; // acknowledge the interrupt TPM1C4SC_CH4IE = 1; // re-enable for the next interrupt TachPeriod=( currentcnt – lastcnt ) / 3; //Calculate period between tac readings //3 accounts for the 3 megahertz bus clock lastcnt = currentcnt; //update the last count }

  17. Source CodeFunction do_speed() - Calculates the speed given a period int do_speed( int TachPeriod ) //TachPeriod argument { if( TachPeriod != 0 ) //to prevent division by zero { currentspeed = (CMPUS/TachPeriod); //calc speed in cm per second return currentspeed; //return result } return 0; //else return 0 }

  18. Source Codemain() nsf++; // only update every 100 main loops do_speed(TachPeriod); // calculate the speed from period if((currentspeed > 0) && (nsf % 100 == 0)) // only if the current speed is valid { LCD_clear(); // clear the display sprintf(s, "%u", currentspeed); // create the string for the LCD LCD_line(0, s); // display current speed on LCD }

  19. Summary • Hardware Topics • Sensor wiring – 5v supply to yellow • Sensor Mounting – tight screws • Software Topics • Calculating Distance – CMPUS/TachPeriod • TPM Initialization – TPM1C4SC = 0b01000100 • Avoid divide by 0! • Q&A

  20. References • Huang, Han-Way. HCS12/9S12: An Introduction to Software and Hardware Interfacing. 2nd ed. Delmar, Cengage Learning, 2010. • GP1A75 OPIC Photointerrupter Datasheet. Sharp Corporation. 2005. Web. http://www.aet.calu.edu/~jsumey/CET360/smartcar/datasheets/GP1A75E.pdf • 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. • Sumey, Jeff. “CET Microprocessor Engineering.” California University of Pennsylvania. Web. 18 Feb 2014. http://aet.calu.edu/~jsumey.

  21. Questions?

More Related