IR Tracker

From Mech
Revision as of 05:16, 8 March 2008 by AliceZhao (talk | contribs)
Jump to navigationJump to search

Team Members

Team Members.jpg

Mark Straccia, Matt Turpin, Alice Zhao (Team '7.5')

Overview

The IR Tracker is a device that detects the position of an infrared emitter and orients itself to get in line with the emitter.

The goal of our project is:

This is how it works:

We will discuss:

Mechanical Design

The primary components used in this circuit are:

  • Plexiglas
  • Turntable (part number, vendor, cost, when available)
  • Mirror (part number, vendor, cost, when available)
Mechanical Design.jpg

The goals:

  • Pitman Motors - constantly detect location of the emitter
  • RC Servos -

Circuit

The four primary components used in this circuit are:

  • Controller (PIC)
  • Parallax GPS Receiver Module
  • Liquid Crystal Display
  • Three buttons
Parallax GPS Wiring Digram.jpg

Image 1 shows the connection between the PIC and GPS Receiver Module.

Note that the pin labeled "Raw" needs to be grounded with a 1K resistor. The serial line also needs to be pulled high with a 1K resistor.

Parallel LCD Wiring Digram.jpg

Image 2 shows the connection between the PIC and LCD.

GPS Circuit.jpg

Image 3 is an example of how to wire all these elements together on one breadboard

Code

See full code here

Include headers and set serial rate to 4800 baud

  #include <18F4520.h>
  #fuses HS,NOWDT,PUT,NOLVP
  #use delay(clock=20000000)
  #use rs232(baud=4800, rcv=PIN_C1)        //can use any pin to read from GPS, but define it here
  #include "flex_lcd.c"                    //included to allow easy writing to a parallel LCD display
  

Variable declarations and start of main loop

  char letter[300];
  int go = 0,wait = 0,commacount = 0,dataoutput = 1,j = 0;
  int16 i;
  int16 comma[90];
  
  void main()
  {
     lcd_init();
     while(TRUE)
     {

One of the most important aspects of this code is waiting for signal to return to high. Without this section, the rs232 command could end up in the middle of the output of the GPS and render all information unusable. This loop waits for the signal to remain high for over 2 bytes to ensure it is at the stop position before beginning to read.

        for (wait=0;wait<20;)               //for loop used to wait until signal has reset.  20*50us=1ms>two bytes of ones at 4800 baud
        {
           if (input(PIN_C1)==1)
           {
              wait++;
           }
           else if (input(pin_c1)==0)
           {
              wait = 0;
           }
           delay_us(50);
        }

After getting into the data loop, all data is recorded into a 300 character matrix letter

        for(i=0;i<300;i++)                  //record 300 characters into letter matrix
        {
           letter[i]= getc();
        }

The data is then parsed into sets of commas.

        for(i=0;i<300;i++)                  //parse matrix for commas (ascii=44 for a comma)
        {
           if (letter[i] == 44)
           {
              comma[commacount] = i;
              commacount++;
           }            
        }

Counting variables are reset to zero at the end of the while loop

        go = 0;                             //reset testing variables back to zero
        commacount=0;

To finish the program, data must be converted into a usable format and output to the LCD screen. See full code above for an example of how to do this.

References

Parallax Info: http://info.hobbyengineering.com/specs/PX-GPSManualV1.1.pdf

Circuit Info: http://hades.mech.northwestern.edu/wiki/index.php/C_Example:_Parallel_Interfacing_with_LCDs