Main Page | File List | Globals

robotu.c File Reference

Helper functions for robot. More...

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/signal.h>
#include <avr/pgmspace.h>
#include <avr/eeprom.h>
#include "robotu.h"

Go to the source code of this file.

Defines

#define IRON   (PORTB |= _BV(PB4)) /*!< switches the IR-diode on*/
#define IROFF   (PORTB &= ~_BV(PB4)) /*!< switches the IR-diode off*/
#define IRTOGGLE   (PORTB ^= _BV(PB4)) /*!< toggles the IR-diode*/

Functions

void decode_position ()
 Decodes the angle sensor.

u16 abs (s16 val)
 returns the positive value of val

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

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

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

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

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

const s08 graytab [] = {0,-1,1,0, 1,0,0,-1, -1,0,0,1, 0,1,-1,0}
u16 irtime
s16 irbit
irdatatype irbuf


Detailed Description

Helper functions for robot.

Definition in file robotu.c.


Define Documentation

#define IROFF   (PORTB &= ~_BV(PB4)) /*!< switches the IR-diode off*/
 

switches the IR-diode off

Definition at line 21 of file robotu.c.

#define IRON   (PORTB |= _BV(PB4)) /*!< switches the IR-diode on*/
 

switches the IR-diode on

Definition at line 19 of file robotu.c.

#define IRTOGGLE   (PORTB ^= _BV(PB4)) /*!< toggles the IR-diode*/
 

toggles the IR-diode

Definition at line 23 of file robotu.c.


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().


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