00001 // 00002 // C Interface: robotu 00003 // 00004 // Description: helper routines for robot.c 00005 // 00006 // 00007 // Author: Leonhard Klein <leoklein@gmx.net>, (C) 2004 00008 #ifndef __ROBOT_H__ 00009 #define __ROBOT_H__ 00010 00011 #include "robotsound.h" 00012 #include "basic.h" 00013 #include "ir.h" 00014 00015 #define POS360 1187 00016 /* 1187 ticks = 56,5cm; 1 tick = 0.476mm; about 460ticks per round */ 00017 #define MINSPEED 10 00018 #define BATLOW 173 00019 #define BATEMPTY 120 00020 #define BATFULL 365 00021 #define IRMLENGTH 20 00022 /* some battery values: 00023 4.5: 244 00024 5.0: 292 00025 5.5: 338 00026 */ 00027 00028 #define INITSKRIPT 102 00029 #define DIVSPEED 85 00032 u16 time, modustime; 00033 00034 u08 light_value; /* to store the results of the AD */ 00035 u16 vcc_value, irpos_value, vcco_value; /* to store ... in 1/100V */ 00036 s16 radar_value, irstation_value; /* holds time from last radar-echo */ 00037 00038 00039 #define DIPPOS ((PINC & (_BV(PC3)|_BV(PC4)))>>3) 00040 #define SETMODUS(nmodus) do { modus=nmodus; modustime = 0; l_to=positionl; r_to=positionr; } while (0) 00041 #define RESETP do { l_to=positionl; r_to=positionr; speed = 0; } while (0) 00042 00043 00044 #define ISIRON ((PIND & _BV(PD4))==0) /* 1: ir-on, 0: ir-off */ 00045 00046 00047 s16 heading, positionl, positionr; /*< from position sensor; heading counterclockwise */ 00048 s08 speed, direction; /*< for driving, use directly */ 00049 s16 l_to, r_to; /*< for driving, use with drive_to_pos */ 00050 u16 d_pos; /*< the difference in ticks to the target position */ 00051 u08 olddippos; /*< the dip-switch position of the last call of the do'functions */ 00052 u08 needpower; /*< is set for loading when reaching station next time */ 00053 00054 #ifdef SINUS 00055 extern s08 sine(u08 in); 00056 #define COSINE(x) sine(x+90%255) 00057 #endif 00058 extern void decode_position(); /* decode angle sensors */ 00059 extern void drive_to_pos(s16 l2,s16 r2); 00060 extern void drive(); /* set H-Bridge according to speed and dire*/ 00061 00062 extern void start_ad(enum admodtype adm); 00063 extern void start_radar(); 00064 extern u08 atoi(u08 *str); 00065 00066 extern void ir_int_send(u16 val); 00067 #endif