Main Page | File List | Globals

robotu.h File Reference

#include "robotsound.h"
#include "basic.h"
#include "ir.h"

Go to the source code of this file.

Defines

#define POS360   1187
 the difference of values from the angle sensor that gives a 360 turn.

#define MINSPEED   10
 the minimum speed that is given to the motors. This saves some power because the motors would not move anyway.

#define BATLOW   173 /*!< vcc_value at low battery, about 4V */
#define BATEMPTY   120 /*!< reeeally empty: Modus empty 3,5V*/
#define BATFULL   365 /*!< after loading and disconnect: 5,9V for a full battery */
#define IRMLENGTH   20 /*!< the maximum length for a IR-string */
#define INITSKRIPT   102 /*!< the first eeprom adress for the skript */
#define DIVSPEED   85 /*!< the divisor vor the speed.*/
#define DIPPOS   ((PINC & (_BV(PC3)|_BV(PC4)))>>3)
 gives back the status of the dip switches. (adds the values written on in). Values are 0 .. 3

#define SETMODUS(nmodus)   do { modus=nmodus; modustime = 0; l_to=positionl; r_to=positionr; } while (0)
 Stops the Robot, sets the modus to nmodus and resets the modustimer (important for the new modus).

#define RESETP   do { l_to=positionl; r_to=positionr; speed = 0; } while (0)
 used to stop the robot instantly. It can loose the right heading by this.

#define ISIRON   ((PIND & _BV(PD4))==0) /* 1: ir-on, 0: ir-off */

Functions

void decode_position ()
 Decodes the angle sensor.

void drive_to_pos (s16 l2, s16 r2)
 gives a target for the robot

void drive ()
 This function calculates and sets the Driver-IC.

void start_ad (enum admodtype adm)
 starts the ADC of some given value.

void start_radar ()
 starts measuring the distance by "radar".

u08 atoi (u08 *str)
 Converts a hexnumber stored in a string to a u08.

void ir_int_send (u16 val)
 sends an integer value via IR. The leading '0's are transmitted


Variables

u16 time
 the global timer.

u16 modustime
 a helping variable vor the do_functions. Mainly for building a state machine (is initialised at 0)

u08 light_value
 the read light value.

u16 vcc_value
 the read voltage at the processor.

u16 irpos_value
 the distance to the next object measured by IR. Goes to about 30 cm.

u16 vcco_value
 the read voltage at the bumper. Also influenced by the DIPPOS-2.

s16 radar_value
 the distance to the next object measured by radar.

s16 irstation_value
 the read ir density from the loading station

s16 heading
 the actual heading of the robot.

s16 positionl
 the position of the left position sensor at the wheel.

s16 positionr
 the position of the right position sensor at the wheel.

s08 speed
 the speed to drive.

s08 direction
 see speed.

s16 l_to
 the positionl to be reached

s16 r_to
 the positionr to be reached

u16 d_pos
 the difference from the actual to the optimal position. in ticks like the POS360.

u08 olddippos
u08 needpower
 is set in the timer0 routine if the Battery is low.


Detailed Description

Definition in file robotu.h.


Define Documentation

#define BATEMPTY   120 /*!< reeeally empty: Modus empty 3,5V*/
 

reeeally empty: Modus empty 3,5V

Definition at line 20 of file robotu.h.

Referenced by SIGNAL().

#define BATFULL   365 /*!< after loading and disconnect: 5,9V for a full battery */
 

after loading and disconnect: 5,9V for a full battery

Definition at line 22 of file robotu.h.

Referenced by main().

#define BATLOW   173 /*!< vcc_value at low battery, about 4V */
 

vcc_value at low battery, about 4V

Definition at line 18 of file robotu.h.

Referenced by do_empty(), and SIGNAL().

#define DIVSPEED   85 /*!< the divisor vor the speed.*/
 

the divisor vor the speed.

Definition at line 34 of file robotu.h.

Referenced by drive().

#define INITSKRIPT   102 /*!< the first eeprom adress for the skript */
 

the first eeprom adress for the skript

Definition at line 32 of file robotu.h.

#define IRMLENGTH   20 /*!< the maximum length for a IR-string */
 

the maximum length for a IR-string

Definition at line 24 of file robotu.h.


Function Documentation

void decode_position  ) 
 

Decodes the angle sensor.

This function is called every 0.5ms to decode the angle sensors. Every 0,13 s it updates the heading, posx and posy. Furthermore it avoids overflows of positionl and positionr while saving the heading. That's also the cause for which you should not use direct assignments to l_to and r_to.

Definition at line 47 of file robotu.c.

Referenced by SIGNAL().

void drive  ) 
 

This function calculates and sets the Driver-IC.

In this function the values l_to and r_to are used to drive the motors. Furthermore speed and direction are read to increment l_to and r_to. By doing this it prioritises the heading, so the robot will slow down if it cannot hold the direction.

Definition at line 79 of file robotu.c.

Referenced by SIGNAL().

void drive_to_pos s16  l2,
s16  r2
 

gives a target for the robot

With this function you can force the robot to go exactly l2 steps left and r2 steps right.

Definition at line 114 of file robotu.c.

void start_ad enum admodtype  adm  ) 
 

starts the ADC of some given value.

Starts the measure of adm. The normal measures should be ready in two cycles of Timer0. If the ADC is used already it will beep 5 times. This function will set admodus.

Definition at line 126 of file robotu.c.

Referenced by SIGNAL().

void start_radar  ) 
 

starts measuring the distance by "radar".

This will enter the radar mode. In this time nothing else will be computated. It will last at maximum 0.15s (depending on the distance). The result is written in radarcont. 0 for near, 1000 for far away or error.

Definition at line 119 of file robotu.c.

Referenced by SIGNAL().


Variable Documentation

heading
 

the actual heading of the robot.

Goes from 0 to POS360. Is calculated from positionl and positionr in decode_position(). counterclockwise

Referenced by decode_position().

l_to
 

the positionl to be reached

Don't change directly but with drive_to(), at it will change by overflow of positionl and positionr.

Referenced by decode_position(), do_boredom(), do_sleep(), and drive().

positionl
 

the position of the left position sensor at the wheel.

it is reset when positionl or positionr reaches 5000 so don't build your code at them.

Referenced by decode_position(), do_boredom(), and do_sleep().

positionr
 

the position of the right position sensor at the wheel.

it is reset when positionl or positionr reaches 5000 so don't build your code at them.

Referenced by decode_position(), do_boredom(), and do_sleep().

r_to
 

the positionr to be reached

Don't change directly but with drive_to(), at it will hcange by overflow of positionl and positionr.

Referenced by decode_position(), do_boredom(), do_sleep(), and drive().

radar_value
 

the distance to the next object measured by radar.

From 50cm to 5m. a difference of one is about 1,96 cm.

Referenced by SIGNAL(), and start_radar().

speed
 

the speed to drive.

When setting speed the robot drives forward or backward. The direction is set with direction. Direction = +-64 is meant that one wheel is standing still. If the heading cannot be hold the speed is internally reduced. When the speed is very small the robot will not drive constantly it holds the position averagly. Direction = +-128 turns around the own axis. Speed and direction should only get values from -128 to 127.

Referenced by do_boredom().

time
 

the global timer.

Is incremented by every "normal" Timer0 overflows ("normal" is everything besides ir-trans. and rec. and radar). The do_* functions can use it but should not change. It goes from 0 to 2^16.

Referenced by do_boredom(), and SIGNAL().

vcc_value
 

the read voltage at the processor.

It is done by comparing this to a zener diode and is highly nonlinear.

Referenced by do_empty(), main(), and SIGNAL().


Generated on Wed Feb 2 20:03:51 2005 for Robot by doxygen 1.3.6