asuro.h

gehe zur Dokumentation dieser Datei
00001 
00026 /***************************************************************************
00027 *
00028 *it is not allowed to remove the nicknames of the contributers to this software
00029 * from the function header
00030 */
00031 /***************************************************************************
00032 *                                                                         *
00033 *   This program is free software; you can redistribute it and/or modify  *
00034 *   it under the terms of the GNU General Public License as published by  *
00035 *   the Free Software Foundation; either version 2 of the License, or     *
00036 *   any later version.                                                    *
00037 ***************************************************************************/
00038 
00039 /****************************************************************************
00040 *
00041 * File Name:   asuro.c
00042 *
00043 *
00044 * Ver.     Date         Author           Comments
00045 * -------  ----------   --------------   ------------------------------
00046 * 1.00     14.08.2003   Jan Grewe                build
00047 * 2.00     14.10.2003   Jan Grewe        RIGHT_VEL -> MotorSpeed(unsigned char left_speed, unsigned char right_speed);
00048 *                                        LeftRwd(),LeftFwd(),RightRwd(), LEFT_VEL,
00049 *                                        RigthFwd() -> MotorDir(unsigned char left_dir, unsigned char right_dir);
00050 *                                        GREEN_ON,GREEN_OFF,RED_ON,RED_OFF -> StatusLED(unsigned char color);
00051 *                                        LED_RED_ON, LED_RED_OFF -> FrontLED(unsigned char color);
00052 *                                        Blink(unsigned char left, unsigned char right) ->
00053 *                                         BackLED(unsigned char left, unsigned char right);
00054 *                                        Alles in Funktionen gefasst => leichter verständlich ?!?!
00055 * 2.10     17.10.2003   Jan Grewe        new Timer funktion void Sleep(unsigned char time36kHz)
00056 *
00057 *
00058 * Copyright (c) 2003 DLR Robotics & Mechatronics
00059 *****************************************************************************/
00060 /****************************************************************************
00061 *
00062 * File Name:   asuro.c
00063 * Project  :   asuro library "Robotrixer Buxtehude"
00064 *
00065 * Description: This file contains additional functions:
00066 *
00067 * signal (SIG_ADC)                 interrupt/signal routine for encoder-counter
00068 * signal (SIG_INTERRUPT1)          signal for switches
00069 * EncoderInit()                    initializing encoder-counter
00070 * EncoderStart()                   start autoencoding
00071 * EncoderStop()                    stop autoencoding
00072 * EncoderSet(int,int)              set encodervalue
00073 * Msleep(int delay)                wait for delay in milliseconds
00074 * Gettime()                        get systemtime in milliseconds
00075 * PrintInt(int)
00076 *
00077 * modifications in Sleep, SIG_OUTPUT_COMPARE2, PollSwitch, LineData
00078 *
00079 * Ver.     Date         Author           Comments
00080 * -------  ----------   --------------   ------------------------------
00081 * beta1    31.03.2005   Robotrixer       asuro library
00082 * -------  ----------   --------------   ------------------------------
00083 * the encoder source is based on RechteckDemo.c ver 2.0 by Jan Grewe 22.10.2003
00084 * Copyright (c) 2003 DLR Robotics & Mechatronics
00085 
00086 *****************************************************************************/
00087 /****************************************************************************
00088 *
00089 * File Name:   asuro.c
00090 * Project  :   asuro library modified for IR collision detector
00091 *
00092 * Description: modifications made in following functions:
00093 *
00094 * SIGNAL (SIG_OUTPUT_COMPARE2)  ->      SIGNAL (SIG_OVERFLOW2)
00095 * Gettime()                             counts now 36kHz
00096 * Init()                                timer2 modified for adjustable duty cycle
00097 * Batterie()                            bug fixed
00098 * Sleep()                               counts now 36kHz
00099 * Msleep()                              counts now 36kHz
00100 *
00101 * Ver.     Date         Author           Comments
00102 * -------  ----------   --------------   ------------------------------
00103 * beta2    11.06.2005   Waste            asuro library
00104 * -------  ----------   --------------   ------------------------------
00105 *****************************************************************************/
00106 /****************************************************************************
00107 *
00108 * File Name:   asuro.c
00109 * Project  :   asuro library
00110 *
00111 * Description: This file contains additional functions:
00112 *
00113 * motor control functions 29.7.2005 stochri
00114 * void Go(int distance)
00115 * void Turn(int degree)
00116 *
00117 * unsigned char Wheelspeed[2]           measured Wheelspeed by interupt
00118 *
00119 * Ver.     Date         Author           Comments
00120 * -------  ----------   --------------   ------------------------------------------
00121 * sto1     29.07.2005   stochri          asuro library with motor control functions
00122 * -------  ----------   --------------   ------------------------------------------
00123 *****************************************************************************/
00124 /****************************************************************************
00125 *
00126 * File Name:   asuro.c
00127 * Project  :   asuro library "Robotrixer Buxtehude"
00128 *
00129 * Description: modifications made in following function:
00130 *
00131 * Go (int distance, int speed)           Added Speed and Odometrie
00132 * Turn (int degree, int speed)           Added Speed and Odometrie
00133 *
00134 * modifications in Sleep, SIG_OUTPUT_COMPARE2, PollSwitch, LineData
00135 *
00136 * Ver.     Date         Author           Comments
00137 * -------  ----------   --------------   ------------------------------
00138 * And1     31.07.2005   Andun            See above
00139 * -------  ----------   --------------   ------------------------------
00140 *
00141 *****************************************************************************/
00142 /****************************************************************************
00143 *
00144 * File Name:   asuro.c
00145 * Project  :   asuro library
00146 *
00147 * Description: modifications made in following functions:
00148 *
00149 * void PrintInt(int wert)
00150 *
00151 * unsigned char Wheelspeed[2]            removed
00152 *
00153 * Ver.     Date         Author           Comments
00154 * -------  ----------   --------------   ------------------------------------------
00155 * 2.60     28.09.2005   m.a.r.v.i.n      doxygen comments
00156 * -------  ----------   --------------   ------------------------------------------
00157 *****************************************************************************/
00158 /****************************************************************************
00159 *
00160 * File Name:   asuro.c
00161 * Project  :   asuro library
00162 *
00163 * Description: modifications made in following functions:
00164 *
00165 * SIGNAL (SIG_ADC)
00166 * void PrintInt(int wert)
00167 *
00168 *
00169 * Ver.     Date         Author           Comments
00170 * -------  ----------   --------------   ------------------------------------------
00171 * 2.61     20.11.2006   m.a.r.v.i.n      SIGNAL (SIG_ADC): static Variable toggle initialisiert
00172 *                                        auf False (Bug report von Rolf_Ebert)
00173 *                                        PrintInt: Initialisierung text String kann zu Fehler
00174 *                                        beim Flashen mit RS232/IR Adapter fuehren
00175 *                                        (Bug report von francesco)
00176 * -------  ----------   --------------   ------------------------------------------
00177 *****************************************************************************/
00178 /****************************************************************************
00179 *
00180 * File Name:   asuro.c
00181 * Project  :   asuro library
00182 *
00183 * Description: new functions has been added:
00184 *
00185 * void uart_putc(unsigned char zeichen)
00186 * void SerPrint(unsigned char *data)
00187 * void SetMotorPower(int8_t left_speed, int8_t right_speed )
00188 * void sound(uint16_t freq, uint16_t duration_msec, uint8_t amplitude)
00189 *
00190 * Description: modifications made in following functions:
00191 *
00192 * void Go(int distance, int power)
00193 * void Turn(int degree, int speed)
00194 * void PrintInt(int wert)
00195 *
00196 *
00197 * Ver.     Date         Author           Comments
00198 * -------  ----------   --------------   ------------------------------------------
00199 * 2.70     07.01.2007   stochri          new functions:
00200 *                                        uart_putc: send single character
00201 *                                        SerPrint: send 0-terminated string
00202 *                                        SetMotorPower: set Motor speed and direction
00203 *                                        sound: Sound Ausgabe ueber Motor PWM
00204 *                                        Go: distance in mm
00205 *                                        Turn: comments
00206 *                       m.a.r.v.i.n      PrintInt: SerWrite ersetzt durch SerPrint
00207 * -------  ----------   --------------   ------------------------------------------
00208 *****************************************************************************/
00209 
00210 
00211 #ifndef ASURO_H
00212 #define ASURO_H
00213 
00214 #include <avr/io.h>
00215 #include <avr/interrupt.h>
00216 #ifndef SIGNAL
00217   #include <avr/signal.h>   // header file obsolete in actual avr-libc
00218   #include <inttypes.h>
00219 #endif
00220 #include <stdlib.h>
00221 
00222 #define  FALSE  0
00223 #define  TRUE   1
00224 
00225 #define  OFF    0
00226 #define  ON     1
00227 
00228 #define GREEN   1
00229 #define RED     2
00230 #define YELLOW  3
00231 
00232 /* neue Funktionen und Variablen*/
00233 #define LEFT    0
00234 #define RIGHT   1
00235 
00236 /* --- Globale Variablen -----------------------------------*/
00240 extern const char version[5];
00241 
00242 /*
00243  * Tastsensor Wert bei Interrupt Betrieb. 0=keine Taste, 1= Taste gedrueckt
00244  */
00245 extern int switched;
00246 
00247 /*
00248  * Odometriesensor Zaehler bei Interrupt Betrieb.
00249  * encoder[0] links, encoder[1] = rechts.
00250  */
00251 extern int encoder[2];
00252 
00253 /*
00254  * Counter fuer 36kHz.
00255  * Wird in der Interrupt Funktion SIG_OVERFLOW2 hochgezaehlt\n
00256  * und in der Sleep() Funktion abgefragt.
00257  */
00258 extern volatile unsigned char count36kHz;
00259 
00260 /*
00261  * Sytemzeit in ms.
00262  * Wird in der Interrupt Funktion SIG_OVERFLOW2 hochgezaehlt
00263  * und in der Gettime() Funktion verwendet.
00264  */
00265 extern volatile unsigned long timebase;
00266 
00267 /*
00268  * Odometrie Sensor Abfrage im Interrupt Betrieb.
00269  * Wird in der Interrupt Funktion SIG_ADC abgefragt,
00270  * in der EncoderInit() und EncoderStart() Funktion gesetzt
00271  * und in der EncoderStop() Funktion geloescht.
00272  */
00273 extern volatile int autoencode;
00274 
00275 
00276 /*
00277   Aufbau der Datenstruktur fuer die Asuro-typischen Parameter die jeder User
00278   fuer seinen Asuro in der Datei myasuro.h selber aendern kann.
00279  */
00280 typedef struct {
00287             long  switch_value;
00296   unsigned  int   odo_light_value[2];
00305   unsigned  int   odo_dark_value[2];
00313   unsigned  long  go_enc_count_value;
00321             long  turn_enc_count_value;
00322 } my_t;
00323 extern volatile my_t my;
00324 
00325 // Wheelspeed variables 29.7.2005 stochri
00326 // removed not referenced 29.09.2005 m.a.r.v.i.n
00327 //unsigned char Wheelspeed[2];
00328 
00329 /* --- Funktions Prototypen -----------------------------------*/
00330 
00331 // motor control functions 29.7.2005 stochri
00332 // motor control functions 31.7.2005 edited by Andun
00333 
00334 void Init(void);
00335 
00336 unsigned long Gettime(void);
00337 void Msleep(int dauer);
00338 void Sleep(unsigned char time36kHz);
00339 
00340 void EncoderInit(void);
00341 void EncoderSet(int setl,int setr);
00342 void EncoderStop(void);
00343 void EncoderStart(void);
00344 void Go(int distance, int speed);
00345 void Turn(int degree, int speed);
00346 
00347 void UartPutc(unsigned char zeichen);
00348 void SerPrint(unsigned char *data);
00349 void PrintInt(int wert);
00350 void PrintLong(long wert);
00351 
00352 int Batterie(void);
00353 void LineData(unsigned int *data);
00354 void OdometrieData(unsigned int *data);
00355 
00356 inline void StatusLED(unsigned char color);
00357 inline void FrontLED(unsigned char status);
00358 void BackLED(unsigned char left, unsigned char right);
00359 
00360 inline void MotorDir(unsigned char left_dir, unsigned char right_dir);
00361 inline void MotorSpeed(unsigned char left_speed, unsigned char right_speed);
00362 void SetMotorPower(int8_t leftpwm, int8_t rightpwm);
00363 
00364 void SerWrite(unsigned char *data,unsigned char length);
00365 void SerRead(unsigned char *data, unsigned char length, unsigned int timeout);
00366 
00367 unsigned char PollSwitch (void);
00368 void StartSwitch(void);
00369 void StopSwitch(void);
00370 
00371 void Sound(uint16_t freq, uint16_t duration_msec, uint8_t amplitude);
00372 
00373 /* ----------- END ------------ */
00374 
00375 
00376 /* --------------- INTERNAL ------------- */
00377 #define GREEN_LED_ON  PORTB |=  GREEN_LED       
00378 #define GREEN_LED_OFF PORTB &= ~GREEN_LED       
00379 #define RED_LED_ON    PORTD |=  RED_LED         
00380 #define RED_LED_OFF   PORTD &= ~RED_LED         
00382 #define FWD     (1 << PB5)                      
00383 #define RWD     (1 << PB4)                      
00384 #define BREAK   0x00                            
00385 #define FREE    (1 << PB4) | (1 << PB5)         
00387 #define IRTX        (1 << PB3)                  
00388 #define GREEN_LED   (1 << PB0)                  
00389 #define RED_LED     (1 << PD2)                  
00391 #define PWM       (1 << PB1) | (1 << PB2)       
00392 #define RIGHT_DIR (1 << PB4) | (1 << PB5)       
00393 #define LEFT_DIR  (1 << PD4) | (1 << PD5)       
00395 #define SWITCHES   (1 << PD3)                   /* PD3 Port fuer Tastsensor */
00396 #define SWITCH_ON  PORTD |= SWITCHES            /* Tastsensor an  */
00397 #define SWITCH_OFF PORTD &= ~SWITCHES           /* Tastsensor aus */
00398 
00399 #define BATTERIE  (1 << MUX0) | (1 << MUX2)     
00400 #define SWITCH    (1 << MUX2)                   
00401 #define IR_LEFT   (1 << MUX0) | (1 << MUX1)     
00402 #define IR_RIGHT  (1 << MUX1)                   
00403 #define FRONT_LED (1 << PD6)                    
00405 #define ODOMETRIE_LED     (1 << PD7)                    
00406 #define ODOMETRIE_LED_ON  PORTD |= ODOMETRIE_LED        
00407 #define ODOMETRIE_LED_OFF PORTD &= ~ODOMETRIE_LED       
00409 #define WHEEL_LEFT   (1 << MUX0)                
00410 #define WHEEL_RIGHT  0                          
00412 #endif /* ASURO_H */

Erzeugt am Wed Feb 14 16:10:02 2007 für ASURO Library von  doxygen 1.5.1-p1