Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

interface.c File Reference

Implementation of an example interface to a simple robot with two independent axies. More...

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <asm/io.h>
#include <time.h>
#include <sys/wait.h>

Defines

#define interface_ymax_time   20000
 Time it rakes to drive to robot form y_min to y_max. More...

#define interface_xmax_time   20000
 Time it rakes to drive to robot form x_min to x_max. More...

#define interface_ymax   100
 Maximal Y value (cosidered as 100 percent). More...

#define interface_xmax   100
 Maximal X value (cosidered as 100 percent). More...

#define interface_ioport   0x378
 IO Port to which lowest nible to robot is connected. More...


Functions

unsigned char input (int addr)
 Read a byte from an IO port. More...

unsigned char output (int addr, unsigned char out)
 Write a byte to an IO port. More...

void msleep (int msec)
 Wait a specified number of milliseconds. More...

int getmax (int a, int b)
 Get to highest number out of two input numbers. More...

int getmin (int a, int b)
 Get to lowest number out of two input numbers. More...

void interface_drive (int h, int v)
 Drive the robot in a specified direction. More...

void interface_init (int mode)
 Initialze the interface and drive the robot to the start position. More...

void interface_driveto (int x, int y)
 Drive to robot to absolute coordinates. More...

void interface_stop ()
 Stop the interface, switch all off. More...


Variables

int interface_x
 current X possition of robot (global). More...

int interface_y
 current X possition of robot (global). More...

int interface_mode
 mode of interface: 0: normal, 1: simulation (do all except to drive the robot), 2: simulation with position-output 3: Blocked: Do nothing. More...


Detailed Description

Implementation of an example interface to a simple robot with two independent axies.

The robot has four inputs whish are connected to the lower nible on IO port "interface_ioport". The bits are connected in this way (the signals a high-active):

Bit 0: Drive Up wires: switch to GND: yellow-green; +24V: gray-black

Bit 1: Dirve down wires: switch to GND: red-green; +24V: orange-black

Bit 2: Dirve right wires: switch to GND: green-red; +24V: yellow-black

Bit 3: Dirve left wires: switch to GND: white-red; +24V: red-blue

power wires: GND: blue; +24V: red

This interface assumes a linear dependency betwenn the coverence of distance and moving time. The 0,0 coordinates is left,bottom.

User functions are:

interface_init() - Initialze the interface and drive the robot to the start position (X=undefined; Y=0).

interface_driveto(int x, int y) - Drive the robot to the absolute coordinates x,y.


Define Documentation

#define interface_ioport   0x378
 

IO Port to which lowest nible to robot is connected.

#define interface_xmax   100
 

Maximal X value (cosidered as 100 percent).

#define interface_xmax_time   20000
 

Time it rakes to drive to robot form x_min to x_max.

#define interface_ymax   100
 

Maximal Y value (cosidered as 100 percent).

#define interface_ymax_time   20000
 

Time it rakes to drive to robot form y_min to y_max.


Function Documentation

int getmax int    a,
int    b
 

Get to highest number out of two input numbers.

Parameters:
a  (int) first input number
b  (int) second input number
Returns:
(int) the highest of the input numbers

int getmin int    a,
int    b
 

Get to lowest number out of two input numbers.

Parameters:
a  (int) first input number
b  (int) second input number
Returns:
(int) the lowest of the input numbers

unsigned char input int    addr
 

Read a byte from an IO port.

Parameters:
addr  (int): address of port to read
Returns:
(unsigned char) read byte

void interface_drive int    h,
int    v
 

Drive the robot in a specified direction.

Any axies can be zero, greater than zero or less than zero, in this cases the robot will not driven, driven to increase to position (up[v,y] or right[h,x]) and decrease the position (down[-v,-y] or left[-h,-x]).

Parameters:
h  (int) horizontal or X axias.
v  (int) vertical or Y axias.

void interface_driveto int    x,
int    y
 

Drive to robot to absolute coordinates.

Parameters:
x  (int): absolute x coordinate
y  (int): absolute y coordinate

void interface_init int    mode
 

Initialze the interface and drive the robot to the start position.

void interface_stop  
 

Stop the interface, switch all off.

void msleep int    msec
 

Wait a specified number of milliseconds.

Parameters:
msec  (int): milliseconds to wait

unsigned char output int    addr,
unsigned char    out
 

Write a byte to an IO port.

Parameters:
addr  (int): address of port to write onto
out  (unsigned char): byte to write
Returns:
(unsigned char) written byte


Variable Documentation

int interface_mode
 

mode of interface: 0: normal, 1: simulation (do all except to drive the robot), 2: simulation with position-output 3: Blocked: Do nothing.

int interface_x
 

current X possition of robot (global).

int interface_y
 

current X possition of robot (global).


Generated on Mon Apr 25 10:53:25 2005 for Hofmeier_FYP:libcomm by doxygen1.2.15