Austin Community College initial line follower program for Freescale car. This is based upon the FRDM-TFC code at mbed.org.

Dependencies:   mbed

Fork of FRDM-TFC by Eli Hughes

Austin Community College - Initial Specs for FRDM-TFC line following car.

This uses the fine library by ELI HUGHES.

Our goal here is to provide the simplest line-follower as a quick car checkout.

First, we limit the run duration for the car, so that you can catch it, if necessary. Right DIP switch (4) sets run time. 0 => 5 sec, 1 => 10 sec.

We provide simple speed selection with the other three DIP switches. I recommend 001 as the slowest real speed, (000 is stop, of course). DIP switches 1 2 3 make a 3 bit speed. 1 is msb, 3 is lsb

The car won't start until you press and release the driver's side PB. Left PB (TFC_PUSH_BUTTON_1) is permissive GO on release using left 3 DIPs for speed 0-7.

The car will stop when the passenger side PB is pressed. Right PB is STOP - TFC_PUSH_BUTTON_0

TFC_Ticker[3] is our run time counter. Like the Code Warrior edition, we use msec tickers.

Left (Driver side) trim pot 1 can be used to trim static steering servo Right trim pot 0 can be used to offset line camera

Back LED reflects drive motor status. The top three are not currently used.

main.cpp

Committer:
emh203
Date:
2013-07-17
Revision:
2:ce4a273be708
Parent:
0:cd9427630ad1
Child:
3:23cce037011f

File content as of revision 2:ce4a273be708:

#include "mbed.h"
#include "TFC.h"
 
DigitalOut myled(LED1);
Ticker TFC_TickerObj;
Serial PC(USBTX,USBRX);
 
#define NUM_TFC_TICKERS 4
 
volatile uint32_t TFC_Ticker[NUM_TFC_TICKERS];
 
void TFC_TickerUpdate()
{
    int i;
 
    for(i=0; i<NUM_TFC_TICKERS; i++) {
        if(TFC_Ticker[i]<0xFFFFFFFF) {
            TFC_Ticker[0]++;
        }
    }
}
 
 
 
 
int main()
{
    //  int i;
 
 
    PC.baud(9600);
    TFC_TickerObj.attach_us(&TFC_TickerUpdate,1000);
   __disable_irq();
   
    TFC_Init();
    __enable_irq();
// TFC_Init();
    while(1) 
    {
 
        if(TFC_ServoTicker >0) 
        {
            TFC_ServoTicker = 0;
 
            TFC_SetBatteryLED(TFC_GetDIP_Switch());
 
            if(TFC_DIP_SWITCH_0_ON) {
                  if(TFC_PUSH_BUTTON_0_PRESSED)
                   TFC_SetServo(0,0.2);
                else if(TFC_PUSH_BUTTON_1_PRESSED)
                   TFC_SetServo(0,-0.2);
                else
                 TFC_SetServo(0,TFC_ReadPot(0));
            }
 
 
            if(TFC_DIP_SWITCH_1_ON) {
                TFC_HBRIDGE_ENABLE;
                TFC_SetMotorPWM(TFC_ReadPot(1) ,TFC_ReadPot(1));
            } else {
                TFC_HBRIDGE_DISABLE;
            }
            
          
        }
 
 
            if(TFC_Ticker[0]>500)
            {
                 TFC_Ticker[0] = 0;
                  PC.printf("Servo Ticker %i",TFC_ServoTicker);
            }
 
 
 
    }
 
}