asuro.h File Reference

Definitionen und Funktionen der ASURO Bibliothek. More...

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/signal.h>
#include <inttypes.h>
#include <stdlib.h>

Go to the source code of this file.

Defines

#define FALSE   0
#define TRUE   1
#define OFF   0
#define ON   1
#define GREEN   1
#define RED   2
#define YELLOW   3
#define LEFT   0
#define RIGHT   1
#define CENTER   2
#define K1   (1<<5)
#define K2   (1<<4)
#define K3   (1<<3)
#define K4   (1<<2)
#define K5   (1<<1)
#define K6   (1<<0)
#define Go(distance, speed)   GoTurn(distance,0,speed)
#define Turn(degree, speed)   GoTurn(0,degree,speed)
#define Batterie   Battery
#define OdometrieData   OdometryData
#define GREEN_LED_ON   PORTB |= GREEN_LED
#define GREEN_LED_OFF   PORTB &= ~GREEN_LED
#define RED_LED_ON   PORTD |= RED_LED
#define RED_LED_OFF   PORTD &= ~RED_LED
#define FWD   (1 << PB5)
#define RWD   (1 << PB4)
#define BREAK   0x00
#define FREE   (1 << PB4) | (1 << PB5)
#define IRTX   (1 << PB3)
#define GREEN_LED   (1 << PB0)
#define RED_LED   (1 << PD2)
#define PWM   (1 << PB1) | (1 << PB2)
#define RIGHT_DIR   (1 << PB4) | (1 << PB5)
#define LEFT_DIR   (1 << PD4) | (1 << PD5)
#define SWITCHES   (1 << PD3)
#define SWITCH_ON   PORTD |= SWITCHES
#define SWITCH_OFF   PORTD &= ~SWITCHES
#define BATTERIE   (1 << MUX0) | (1 << MUX2)
#define SWITCH   (1 << MUX2)
#define IR_LEFT   (1 << MUX0) | (1 << MUX1)
#define IR_RIGHT   (1 << MUX1)
#define FRONT_LED   (1 << PD6)
#define ODOMETRIE_LED   (1 << PD7)
#define ODOMETRIE_LED_ON   PORTD |= ODOMETRIE_LED
#define ODOMETRIE_LED_OFF   PORTD &= ~ODOMETRIE_LED
#define WHEEL_LEFT   (1 << MUX0)
#define WHEEL_RIGHT   0

Functions

void Init (void)
unsigned long Gettime (void)
 return time since system start in ms
void Msleep (int ms)
 sleep function (ms)
void Sleep (unsigned char time36kHz)
 sleep function (36Khz)
void EncoderInit (void)
 initialise and starts odometry mesurement uses interrupt(ADC_vect)
void EncoderSet (int setl, int setr)
 set odometry tick counter
void EncoderStop (void)
 stop counting odometry sensor ticks
void EncoderStart (void)
 stop counting odometry sensor ticks
void GoTurn (int distance, int degree, int speed)
 moves the robot forward/backward OR turns the robot using the odometry sensors. You can use the old function-names Go() and Turn()
int Battery (void)
 returns the battery voltage
void LineData (unsigned int *data)
 reads out the phototransistors
void OdometryData (unsigned int *data)
 reads out the odometry phototransistors
void StatusLED (unsigned char color)
 controls the StatusLED
void FrontLED (unsigned char status)
 controls the FrontLED
void BackLED (unsigned char left, unsigned char right)
 values: ON, OFF
void MotorDir (unsigned char left_dir, unsigned char right_dir)
 Motor configuration. values: FWD, RWD, BREAK, FREE.
void MotorSpeed (unsigned char left_speed, unsigned char right_speed)
 sets motor speed. range: 0..255
void SetMotorPower (int8_t leftpwm, int8_t rightpwm)
void SerWrite (unsigned char *data, unsigned char length)
 Send Data to UART.
void SerRead (unsigned char *data, unsigned char length, unsigned int timeout)
 Receive Data from UART.
void UartPutc (unsigned char zeichen)
void SerPrint (char *data)
void PrintInt (int wert)
void PrintLong (long wert)
void PrintFloat (float wert, char vorkomma, char nachkomma)
unsigned char PollSwitch (void)
 function to read out switches
void StartSwitch (void)
 binds switch press to external Interrupt 1 catch it with ISR(INT1_vect) see avr-libc documentation for details
void StopSwitch (void)
 stop sending switch interrupt clears INT1_vect
void Sound (uint16_t freq, uint16_t duration_msec, uint8_t amplitude)

Variables

const char version [5]
volatile int switched
 any switch pressed?
volatile int encoder [2]
 odometry sensors tick count access: encoder[LEFT], encoder[RIGHT]
range: 0..255
volatile unsigned char count36kHz
volatile unsigned long timebase
volatile int autoencode


Detailed Description

Definitionen und Funktionen der ASURO Bibliothek.

Revision
2.70
Date
07. Januar 2007
Author
Jan Grewe, Robotrixer, Waste, Stochri, Andun, m.a.r.v.i.n

Version:
V001 - 10.02.2007 - m.a.r.v.i.n
+++ my_t Neue Datenstruktur
Datenstruktur fuer die Asuro-Hardwareabhaengigen Parameter die jeder User fuer seinen Asuro in der Datei myasuro.h selber einstellen kann um die Asuro-Typischen Eigenschaften zu definieren.

V002 - 18.02.2007 - Sternthaler
+++ my_t

V003 - 20.02.2007 - m.a.r.v.i.n
+++ my_t Datenstruktur wieder entfernt
Es werden direkt die Defines aus der myasuro.h verwendet.

V004 - 06.04.2007 - m.a.r.v.i.n
Batterie und OdometrieData Funktionen umbenannt in Battery und OdometryData.
Alte Funktionsnamen ueber Defines beibehalten

V005 - 07.06.2007 - Sternthaler
Funktionen Go() und Turn() aus encoder.c zusammengefasst in GoTurn().
Alte Funktionsnamen ueber Defines beibehalten

V006 - 11.07.2007 - Sternthaler
Externe Variable encoder als volatile angegeben, da sie im Interrupt SIGNAL (SIG_ADC) benutzt wird.

V007 - 15.11.2007 - m.a.r.v.i.n
Variable switched als volatile definiert, da sie im Interrupt SIGNAL (SIG_INTERRUPT1) benutzt wird.

Definition in file asuro.h.


Define Documentation

#define BATTERIE   (1 << MUX0) | (1 << MUX2)

ADC5 A/D Wandler Port fuer Batterie Abfrage

Definition at line 530 of file asuro.h.

#define Batterie   Battery

Definition at line 409 of file asuro.h.

#define BREAK   0x00

Motor bremsen

Definition at line 515 of file asuro.h.

#define CENTER   2

Definition at line 253 of file asuro.h.

#define FALSE   0

Definition at line 240 of file asuro.h.

#define FREE   (1 << PB4) | (1 << PB5)

Motor freilaufend

Definition at line 516 of file asuro.h.

#define FRONT_LED   (1 << PD6)

PD6 Port fuer Front LED

Definition at line 534 of file asuro.h.

#define FWD   (1 << PB5)

Motor vorwaerts

Definition at line 513 of file asuro.h.

#define Go ( distance,
speed   )     GoTurn(distance,0,speed)

Definition at line 385 of file asuro.h.

#define GREEN   1

Definition at line 246 of file asuro.h.

#define GREEN_LED   (1 << PB0)

PB0 Port fuer Gruene Status LED

Definition at line 519 of file asuro.h.

#define GREEN_LED_OFF   PORTB &= ~GREEN_LED

Gruene Status LED aus

Definition at line 509 of file asuro.h.

#define GREEN_LED_ON   PORTB |= GREEN_LED

Gruene Status LED an

Definition at line 508 of file asuro.h.

#define IR_LEFT   (1 << MUX0) | (1 << MUX1)

ADC3 A/D Wandler Port fuer Linienfolger Fototransistor links

Definition at line 532 of file asuro.h.

#define IR_RIGHT   (1 << MUX1)

ADC2 A/D Wandler Port fuer Linienfolger Fototransistor rechts

Definition at line 533 of file asuro.h.

#define IRTX   (1 << PB3)

PB3 Port fuer Infrarot Transmitter LED

Definition at line 518 of file asuro.h.

#define K1   (1<<5)

Definition at line 258 of file asuro.h.

#define K2   (1<<4)

Definition at line 259 of file asuro.h.

#define K3   (1<<3)

Definition at line 260 of file asuro.h.

#define K4   (1<<2)

Definition at line 261 of file asuro.h.

#define K5   (1<<1)

Definition at line 262 of file asuro.h.

#define K6   (1<<0)

Definition at line 263 of file asuro.h.

#define LEFT   0

Definition at line 251 of file asuro.h.

#define LEFT_DIR   (1 << PD4) | (1 << PD5)

PD4, PD5 Ports fuer Drehrichtung linker Motor

Definition at line 524 of file asuro.h.

#define ODOMETRIE_LED   (1 << PD7)

PD7 Port fuer Odometrie LED

Definition at line 536 of file asuro.h.

#define ODOMETRIE_LED_OFF   PORTD &= ~ODOMETRIE_LED

Odometrie LED aus

Definition at line 538 of file asuro.h.

#define ODOMETRIE_LED_ON   PORTD |= ODOMETRIE_LED

Odometrie LED an

Definition at line 537 of file asuro.h.

#define OdometrieData   OdometryData

Definition at line 410 of file asuro.h.

#define OFF   0

Definition at line 243 of file asuro.h.

#define ON   1

Definition at line 244 of file asuro.h.

#define PWM   (1 << PB1) | (1 << PB2)

PB1, PB2 Ports fuer Pulsweitenmodulation der Motor Geschwindigkeit

Definition at line 522 of file asuro.h.

#define RED   2

Definition at line 247 of file asuro.h.

#define RED_LED   (1 << PD2)

PD2 Port fuer Rote Status LED

Definition at line 520 of file asuro.h.

#define RED_LED_OFF   PORTD &= ~RED_LED

Rote Status LED aus

Definition at line 511 of file asuro.h.

#define RED_LED_ON   PORTD |= RED_LED

Rote Status LED an

Definition at line 510 of file asuro.h.

#define RIGHT   1

Definition at line 252 of file asuro.h.

#define RIGHT_DIR   (1 << PB4) | (1 << PB5)

PB4, PB5 Ports fuer Drehrichtung rechter Motor

Definition at line 523 of file asuro.h.

#define RWD   (1 << PB4)

Motor rueckwaerts

Definition at line 514 of file asuro.h.

#define SWITCH   (1 << MUX2)

ADC4 A/D Wandler Port fuer Tastsensor

Definition at line 531 of file asuro.h.

#define SWITCH_OFF   PORTD &= ~SWITCHES

Tastsensor aus

Definition at line 528 of file asuro.h.

#define SWITCH_ON   PORTD |= SWITCHES

Tastsensor an

Definition at line 527 of file asuro.h.

#define SWITCHES   (1 << PD3)

PD3 Port fuer Tastsensor

Definition at line 526 of file asuro.h.

#define TRUE   1

Definition at line 241 of file asuro.h.

#define Turn ( degree,
speed   )     GoTurn(0,degree,speed)

Definition at line 386 of file asuro.h.

#define WHEEL_LEFT   (1 << MUX0)

ADC1 A/D Wandler Port fuer Odometrie Sensor links

Definition at line 540 of file asuro.h.

#define WHEEL_RIGHT   0

ADC0 A/D Wandler Port fuer Odometrie Sensor rechts

Definition at line 541 of file asuro.h.

#define YELLOW   3

Definition at line 248 of file asuro.h.


Function Documentation

void BackLED ( unsigned char  left,
unsigned char  right 
)

values: ON, OFF

Parameters:
left leftLED status
right rightLED status

int Battery ( void   ) 

returns the battery voltage

Returns:
ADC value. range: 0..1023

void EncoderInit ( void   ) 

initialise and starts odometry mesurement uses interrupt(ADC_vect)

void EncoderSet ( int  setl,
int  setr 
)

set odometry tick counter

Parameters:
setl left tick counter
setr left tick counter

void EncoderStart ( void   ) 

stop counting odometry sensor ticks

void EncoderStop ( void   ) 

stop counting odometry sensor ticks

void FrontLED ( unsigned char  status  )  [inline]

controls the FrontLED

Parameters:
status values: ON, OFF

unsigned long Gettime ( void   ) 

return time since system start in ms

Returns:
current system time in ms

void GoTurn ( int  distance,
int  degree,
int  speed 
)

moves the robot forward/backward OR turns the robot using the odometry sensors. You can use the old function-names Go() and Turn()

Parameters:
distance travalling distance in cm. positive = forward, negative = backward if distanse is zero, then the function will work as Turn.
degree degrees to turn. positive = turn right, negative = turn left. range: -360..360
speed motor speed. range: 0..255

void Init ( void   ) 

initialises the hardware (ports, ADC, PWM) this function has to be called by every program first

void LineData ( unsigned int *  data  ) 

reads out the phototransistors

Parameters:
data pointer to the data destination. access: data[LEFT], data[RIGHT]

void MotorDir ( unsigned char  left_dir,
unsigned char  right_dir 
) [inline]

Motor configuration. values: FWD, RWD, BREAK, FREE.

Parameters:
left left motor
right right motor

void MotorSpeed ( unsigned char  left_speed,
unsigned char  right_speed 
) [inline]

sets motor speed. range: 0..255

Parameters:
left_speed left motor
right_speed right motor

void Msleep ( int  ms  ) 

sleep function (ms)

Parameters:
ms time in ms

void OdometryData ( unsigned int *  data  ) 

reads out the odometry phototransistors

Parameters:
data pointer to the data destination. access: data[LEFT], data[RIGHT]

unsigned char PollSwitch ( void   ) 

function to read out switches

Returns:
bitfield of switch value bit0 = K6, ... , bit5 = K1

void PrintFloat ( float  wert,
char  vorkomma,
char  nachkomma 
)

void PrintInt ( int  wert  ) 

void PrintLong ( long  wert  ) 

void SerPrint ( char *  data  ) 

void SerRead ( unsigned char *  data,
unsigned char  length,
unsigned int  timeout 
)

Receive Data from UART.

Parameters:
data pointer to data
length data count timeout count, 0 meens blocking mode

void SerWrite ( unsigned char *  data,
unsigned char  length 
)

Send Data to UART.

Parameters:
data pointer to data
length data count

void SetMotorPower ( int8_t  leftpwm,
int8_t  rightpwm 
)

void Sleep ( unsigned char  time36kHz  ) 

sleep function (36Khz)

Parameters:
time36kHz time in 1/36k (sec)

void Sound ( uint16_t  freq,
uint16_t  duration_msec,
uint8_t  amplitude 
)

void StartSwitch ( void   ) 

binds switch press to external Interrupt 1 catch it with ISR(INT1_vect) see avr-libc documentation for details

void StatusLED ( unsigned char  color  )  [inline]

controls the StatusLED

Parameters:
color values: OFF, GREEN, RED, YELLOW

void StopSwitch ( void   ) 

stop sending switch interrupt clears INT1_vect

See also:
StartSwitch

void UartPutc ( unsigned char  zeichen  ) 


Variable Documentation

volatile int autoencode

volatile unsigned char count36kHz

volatile int encoder[2]

odometry sensors tick count access: encoder[LEFT], encoder[RIGHT]
range: 0..255

See also:
EncoderInit

volatile int switched

any switch pressed?

is being set to TRUE by interrupt if a switch is pressed
remember to set it to false again, since it is not reset automatically

See also:
StartSwitch

volatile unsigned long timebase

const char version[5]

Asuro Lib Versions String


Generated on Sun Nov 18 18:30:58 2007 for ASURO Library by  doxygen 1.5.1-p1