00001 /******************************************************************************* 00002 * 00003 * File Name: LineDemo.c 00004 * Project : Demo 00005 * 00006 * Description: This file contains LineDemo features 00007 * 00008 * Ver. Date Author Comments 00009 * ------- ---------- -------------- ------------------------------ 00010 * 1.00 14.08.2003 Jan Grewe build 00011 * 2.00 22.10.2003 Jan Grewe angepasst auf asuro.c Ver.2.10 00012 * 00013 * Copyright (c) 2003 DLR Robotics & Mechatronics 00014 *****************************************************************************/ 00015 /*************************************************************************** 00016 * * 00017 * This program is free software; you can redistribute it and/or modify * 00018 * it under the terms of the GNU General Public License as published by * 00019 * the Free Software Foundation; either version 2 of the License, or * 00020 * any later version. * 00021 ***************************************************************************/ 00022 #include "asuro.h" 00023 00024 #define SPEED 0x8F 00025 00026 int speedLeft,speedRight; 00027 unsigned int lineData[2]; 00028 int ADOffset; 00029 00030 void LineLeft (void) 00031 { 00032 speedLeft += 1; /* links mehr Gas geben */ 00033 if (speedLeft > 0xFE) speedLeft = 0xFF; 00034 } 00035 00036 void LineRight (void) 00037 { 00038 speedRight += 1; /* rechts mehr Gas geben */ 00039 if (speedRight > 0xFE) speedRight = 0xFF; 00040 } 00041 00042 int main(void) 00043 { 00044 int i; 00045 unsigned char j; 00046 00047 Init(); 00048 00049 SerPrint("LineTest\r\n"); 00050 FrontLED(ON); 00051 for (j = 0; j < 0xFF; j++) LineData(lineData); 00052 LineData(lineData); 00053 ADOffset = lineData[LEFT] - lineData[RIGHT]; 00054 SerPrint("Offset: "); 00055 PrintInt(ADOffset); 00056 SerPrint("\r\n"); 00057 speedLeft = speedRight = SPEED; 00058 for (;;) 00059 { 00060 LineData(lineData); 00061 PrintInt(lineData[LEFT]); 00062 SerPrint(" "); 00063 PrintInt(lineData[RIGHT]); 00064 SerPrint(" "); 00065 i = (lineData[LEFT] - lineData[RIGHT]); 00066 PrintInt(i); 00067 SerPrint("\r\n"); 00068 Msleep(1000); 00069 if ( i > 4) 00070 { 00071 StatusLED(GREEN); 00072 LineLeft(); 00073 } 00074 else if ( i < -4) 00075 { 00076 StatusLED(RED); 00077 LineRight(); 00078 } 00079 else 00080 { 00081 StatusLED(OFF); 00082 speedLeft = speedRight = SPEED; 00083 } 00084 // PrintInt(speedLeft); 00085 // SerPrint(" "); 00086 // PrintInt(speedRight); 00087 // SerPrint("\r\n"); 00088 00089 // MotorSpeed(speedLeft,speedRight); 00090 } 00091 return 0; 00092 } 00093