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.

Committer:
emh203
Date:
Wed Jul 17 19:31:32 2013 +0000
Revision:
2:ce4a273be708
Parent:
0:cd9427630ad1
Child:
3:23cce037011f
Work in progress commit....

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emh203 0:cd9427630ad1 1 #include "mbed.h"
emh203 2:ce4a273be708 2 #include "TFC.h"
emh203 2:ce4a273be708 3
emh203 0:cd9427630ad1 4 DigitalOut myled(LED1);
emh203 2:ce4a273be708 5 Ticker TFC_TickerObj;
emh203 2:ce4a273be708 6 Serial PC(USBTX,USBRX);
emh203 2:ce4a273be708 7
emh203 2:ce4a273be708 8 #define NUM_TFC_TICKERS 4
emh203 2:ce4a273be708 9
emh203 2:ce4a273be708 10 volatile uint32_t TFC_Ticker[NUM_TFC_TICKERS];
emh203 2:ce4a273be708 11
emh203 2:ce4a273be708 12 void TFC_TickerUpdate()
emh203 2:ce4a273be708 13 {
emh203 2:ce4a273be708 14 int i;
emh203 2:ce4a273be708 15
emh203 2:ce4a273be708 16 for(i=0; i<NUM_TFC_TICKERS; i++) {
emh203 2:ce4a273be708 17 if(TFC_Ticker[i]<0xFFFFFFFF) {
emh203 2:ce4a273be708 18 TFC_Ticker[0]++;
emh203 2:ce4a273be708 19 }
emh203 0:cd9427630ad1 20 }
emh203 0:cd9427630ad1 21 }
emh203 2:ce4a273be708 22
emh203 2:ce4a273be708 23
emh203 2:ce4a273be708 24
emh203 2:ce4a273be708 25
emh203 2:ce4a273be708 26 int main()
emh203 2:ce4a273be708 27 {
emh203 2:ce4a273be708 28 // int i;
emh203 2:ce4a273be708 29
emh203 2:ce4a273be708 30
emh203 2:ce4a273be708 31 PC.baud(9600);
emh203 2:ce4a273be708 32 TFC_TickerObj.attach_us(&TFC_TickerUpdate,1000);
emh203 2:ce4a273be708 33 __disable_irq();
emh203 2:ce4a273be708 34
emh203 2:ce4a273be708 35 TFC_Init();
emh203 2:ce4a273be708 36 __enable_irq();
emh203 2:ce4a273be708 37 // TFC_Init();
emh203 2:ce4a273be708 38 while(1)
emh203 2:ce4a273be708 39 {
emh203 2:ce4a273be708 40
emh203 2:ce4a273be708 41 if(TFC_ServoTicker >0)
emh203 2:ce4a273be708 42 {
emh203 2:ce4a273be708 43 TFC_ServoTicker = 0;
emh203 2:ce4a273be708 44
emh203 2:ce4a273be708 45 TFC_SetBatteryLED(TFC_GetDIP_Switch());
emh203 2:ce4a273be708 46
emh203 2:ce4a273be708 47 if(TFC_DIP_SWITCH_0_ON) {
emh203 2:ce4a273be708 48 if(TFC_PUSH_BUTTON_0_PRESSED)
emh203 2:ce4a273be708 49 TFC_SetServo(0,0.2);
emh203 2:ce4a273be708 50 else if(TFC_PUSH_BUTTON_1_PRESSED)
emh203 2:ce4a273be708 51 TFC_SetServo(0,-0.2);
emh203 2:ce4a273be708 52 else
emh203 2:ce4a273be708 53 TFC_SetServo(0,TFC_ReadPot(0));
emh203 2:ce4a273be708 54 }
emh203 2:ce4a273be708 55
emh203 2:ce4a273be708 56
emh203 2:ce4a273be708 57 if(TFC_DIP_SWITCH_1_ON) {
emh203 2:ce4a273be708 58 TFC_HBRIDGE_ENABLE;
emh203 2:ce4a273be708 59 TFC_SetMotorPWM(TFC_ReadPot(1) ,TFC_ReadPot(1));
emh203 2:ce4a273be708 60 } else {
emh203 2:ce4a273be708 61 TFC_HBRIDGE_DISABLE;
emh203 2:ce4a273be708 62 }
emh203 2:ce4a273be708 63
emh203 2:ce4a273be708 64
emh203 2:ce4a273be708 65 }
emh203 2:ce4a273be708 66
emh203 2:ce4a273be708 67
emh203 2:ce4a273be708 68 if(TFC_Ticker[0]>500)
emh203 2:ce4a273be708 69 {
emh203 2:ce4a273be708 70 TFC_Ticker[0] = 0;
emh203 2:ce4a273be708 71 PC.printf("Servo Ticker %i",TFC_ServoTicker);
emh203 2:ce4a273be708 72 }
emh203 2:ce4a273be708 73
emh203 2:ce4a273be708 74
emh203 2:ce4a273be708 75
emh203 2:ce4a273be708 76 }
emh203 2:ce4a273be708 77
emh203 2:ce4a273be708 78 }
emh203 2:ce4a273be708 79