SelfTest/test.c

gehe zur Dokumentation dieser Datei
00001 /*******************************************************************************
00002 *
00003 * File Name:   Test.c
00004 * Project  :   SelfTest
00005 *
00006 * Description: This file contains all Test functions
00007 *
00008 * Ver.     Date         Author           Comments
00009 * -------  ----------   --------------   ------------------------------
00010 * 1.00     14.08.2003   Jan Grewe                build
00011 * 2.00     22.10.2003   Jan Grewe        adapted to asuro.c Ver.2.10
00012 * 2.01     19.11.2003   Jan Grewe        Serial Test changed (data += 1)
00013 *
00014 * Copyright (c) 2003 DLR Robotics & Mechatronics
00015 *****************************************************************************/
00016 /***************************************************************************
00017  *                                                                         *
00018  *   This program is free software; you can redistribute it and/or modify  *
00019  *   it under the terms of the GNU General Public License as published by  *
00020  *   the Free Software Foundation; either version 2 of the License, or     *
00021  *   any later version.                                                    *
00022  ***************************************************************************/
00023 #include "asuro.h"
00024 
00025 /* ----------------------------------------- */
00026 /* -------------- Serial Test -------------- */
00027 /*   ASURO sends recieved data+1 directly    */
00028 /* when TIMEOUT occures ASURO is sending 'T' */
00029 /* ----------------------------------------- */
00030 void SerialTest(void)
00031 {
00032   unsigned char data;
00033   unsigned char i;
00034   for (i = 0; i < 0xFE; i++)
00035   {
00036     StatusLED(GREEN);
00037     SerRead(&data,1,0xFFFE);
00038     StatusLED(RED);
00039     if (data != 'T') data += 1;
00040     SerWrite(&data,1);
00041   }
00042 }
00043 /* END Serial Test -------------------------- */
00044 
00045 /* ---------------------- */
00046 /* ----- Switch Test ---- */
00047 /* K1 -> Status LED Green */
00048 /* K2 -> Status LED RED   */
00049 /* K3 -> Line LED         */
00050 /* K4 -> Break LED Left   */
00051 /* K5 -> Break LED Rigth  */
00052 /* K6 -> Motor Left       */
00053 /* ---------------------- */
00054 void SwitchTest(void)
00055 {
00056   unsigned char sw,tmp;
00057   MotorDir(FWD,BREAK);
00058 
00059   sw = PollSwitch();
00060   StatusLED(OFF);
00061   FrontLED(OFF);
00062   BackLED(OFF,OFF);
00063   MotorSpeed(0,0);
00064   tmp = 0;
00065 
00066   if (sw & 0x01)
00067     MotorSpeed(200,0);
00068   if (sw & 0x02)
00069   {
00070     BackLED(OFF,ON);
00071     tmp = ON;
00072   }
00073   if (sw & 0x04)
00074     BackLED(ON,tmp);
00075   if (sw & 0x08)
00076     FrontLED(ON);
00077   if (sw & 0x10)
00078     RED_LED_ON;
00079   if (sw & 0x20)
00080     GREEN_LED_ON;
00081 }
00082 /* END Switch Test ------------------------------ */
00083 
00084 /* ---------------------------------------------- */
00085 /* ------------ Line Sensor Test ---------------- */
00086 /* Left Sensor -> Left Break LED ON when Light on
00087    Left Phototransistor bright enough             */
00088 /* Right Sensor -> Right Break LED ON when Light on
00089    Right Phototransistor bright enough            */
00090 
00091 void LineTest(void)
00092 {
00093   unsigned int data[2];
00094   unsigned char tmp[2] = {OFF,OFF};
00095 
00096   LineData(data);
00097   if (data[0] > 400)
00098     tmp[0] = ON;
00099   if (data[1] > 400)
00100     tmp[1] = ON;
00101   BackLED(tmp[0],tmp[1]);
00102 }
00103 /* END Line Sensor Test ------------------------- */
00104 
00105 /* ---------------------------------------------- */
00106 /* ---------- Odometrie Sensor Test ------------- */
00107 /* Left Sensor -> Status LED GREEN ON when Light on
00108    Left Phototransistor bright enough             */
00109 /* Right Sensor -> Status LED RED ON when Light on
00110    Right Phototransistor bright enough            */
00111 void OdometrieTest(void)
00112 {
00113   unsigned int data[2];
00114 
00115   OdometryData(data);
00116   StatusLED(OFF);
00117   if (data[0] < 512)
00118     StatusLED(GREEN);
00119   if (data[1] < 512)
00120     StatusLED(RED);
00121 }
00122 /* END Odometrie Sensor Test ------------------- */
00123 
00124 /* --------------------------------- */
00125 /* ---------- Motor Test ----------- */
00126 /* Motor Left forward to max. speed  */
00127 /* Motor Left rewind  to max. speed  */
00128 /* Motor Right forward to max. speed */
00129 /* Motor Right rewind  to max. speed */
00130 /* Both Motors forward to max. speed */
00131 /* Both Motors rewind to max. speed  */
00132 void MotorTestRight (void)
00133 {
00134   unsigned int i;
00135   unsigned char j;
00136   unsigned int speed;
00137 
00138   MotorDir(BREAK,FWD);
00139   for (speed = 0; speed < 0xFF; speed ++)
00140   {
00141     for (i = 0; i < 0x1FFF; i++)
00142       for (j = 0; j < 0x1F; j++);
00143     MotorSpeed(0,speed);
00144   }
00145   for (speed = 0xFF; speed > 0; speed --)
00146   {
00147     for (i = 0; i < 0x1FFF; i++)
00148       for (j = 0; j < 0x1F; j++);
00149     MotorSpeed(0,speed);
00150   }
00151 
00152   MotorDir(BREAK,RWD);
00153   for (speed = 0; speed < 0xFF; speed ++)
00154   {
00155     for (i = 0; i < 0x1FFF; i++)
00156       for (j = 0; j < 0x1F; j++);
00157     MotorSpeed(0,speed);
00158   }
00159   for (speed = 0xFF; speed > 0; speed --)
00160   {
00161     for (i = 0; i < 0x1FFF; i++)
00162       for (j = 0; j < 0x1F; j++);
00163     MotorSpeed(0,speed);
00164   }
00165 }
00166 
00167 void MotorTestLeft (void)
00168 {
00169   unsigned int i;
00170   unsigned char j;
00171   unsigned int speed;
00172 
00173   MotorDir(FWD,BREAK);
00174   for (speed = 0; speed < 0xFF; speed ++)
00175   {
00176     for (i = 0; i < 0x1FFF; i++)
00177       for (j = 0; j < 0x1F; j++);
00178     MotorSpeed(speed,0);
00179   }
00180   for (speed = 0xFF; speed > 0; speed --)
00181   {
00182     for (i = 0; i < 0x1FFF; i++)
00183       for (j = 0; j < 0x1F; j++);
00184     MotorSpeed(speed,0);
00185   }
00186 
00187   MotorDir(RWD,BREAK);
00188   for (speed = 0; speed < 0xFF; speed ++)
00189   {
00190     for (i = 0; i < 0x1FFF; i++)
00191       for (j = 0; j < 0x1F; j++);
00192     MotorSpeed(speed,0);
00193   }
00194   for (speed = 0xFF; speed > 0; speed --)
00195   {
00196     for (i = 0; i < 0x1FFF; i++)
00197       for (j = 0; j < 0x1F; j++);
00198     MotorSpeed(speed,0);
00199   }
00200 }
00201 
00202 void MotorTestBoth (void)
00203 {
00204   unsigned int i;
00205   unsigned char j;
00206   unsigned int speed;
00207 
00208   MotorDir(FWD,FWD);
00209   for (speed = 0; speed < 0xFF; speed ++)
00210   {
00211     for (i = 0; i < 0x1FFF; i++)
00212       for (j = 0; j < 0x1F; j++);
00213     MotorSpeed(speed,speed);
00214   }
00215   for (speed = 0xFF; speed > 0; speed --)
00216   {
00217     for (i = 0; i < 0x1FFF; i++)
00218       for (j = 0; j < 0x1F; j++);
00219     MotorSpeed(speed,speed);
00220   }
00221 
00222   MotorDir(RWD,RWD);
00223   for (speed = 0; speed < 0xFF; speed ++)
00224   {
00225     for (i = 0; i < 0x1FFF; i++)
00226       for (j = 0; j < 0x1F; j++);
00227     MotorSpeed(speed,speed);
00228   }
00229   for (speed = 0xFF; speed > 0; speed --)
00230   {
00231     for (i = 0; i < 0x1FFF; i++)
00232       for (j = 0; j < 0x1F; j++);
00233     MotorSpeed(speed,speed);
00234   }
00235   MotorSpeed(0,0);
00236 }
00237 
00238 void MotorTest(void)
00239 {
00240   MotorTestLeft();
00241   MotorTestRight();
00242   MotorTestBoth();
00243 }
00244 /* ---------------------------------------------- */
00245 
00246 /* ------------- LED Test ----------- */
00247 /* Switch On and Off all visible LEDs */
00248 /* Status LED GREEN,RED               */
00249 /* Line LED                                                       */
00250 /* Break LEDs                                             */
00251 void LEDTest (void)
00252 {
00253   unsigned int i;
00254   StatusLED(GREEN);
00255   BackLED(OFF,OFF);
00256   FrontLED(OFF);
00257   for (i = 0; i < 842; i++) Sleep(0xFF);
00258   StatusLED(RED);
00259   for (i = 0; i < 842; i++) Sleep(0xFF);
00260   StatusLED(OFF);
00261   FrontLED(ON);
00262   for (i = 0; i < 842; i++) Sleep(0xFF);
00263   BackLED(ON,OFF);
00264   FrontLED(OFF);
00265   for (i = 0; i < 842; i++) Sleep(0xFF);
00266   BackLED(OFF,ON);
00267   for (i = 0; i < 842; i++) Sleep(0xFF);
00268   BackLED(ON,ON);
00269   StatusLED(YELLOW);
00270   FrontLED(ON);
00271   for (i = 0; i < 842; i++) Sleep(0xFF);
00272   BackLED(OFF,OFF);
00273   StatusLED(OFF);
00274   FrontLED(OFF);
00275 }
00276 /* END LED Test --------------------- */
00277 

Erzeugt am Mon Apr 9 13:28:39 2007 für ASURO Library von  doxygen 1.5.1-p1