e_motors.c File Reference

Manage the motors (with timer 4 and 5). More...

#include <stdlib.h>
#include "e_epuck_ports.h"
#include "e_init_port.h"
#include "e_motors.h"

Functions

void __attribute__ ((interrupt, auto_psv, shadow))
void e_init_motors (void)
 Initialize the motors's ports.
void e_set_speed_left (int motor_speed)
 Manage the left speed.
void e_set_speed_right (int motor_speed)
 Manage the right speed.
int e_get_steps_left (void)
 Give the number of left motor steps.
void e_set_steps_left (int set_steps)
 Set the number of left motor steps.
int e_get_steps_right (void)
 Give the number of right motor steps.
void e_set_steps_right (int set_steps)
 Set the number of right motor steps.

Variables

static int left_speed = 0
static int right_speed = 0
static int nbr_pas_left = 0
static int nbr_pas_right = 0


Detailed Description

Manage the motors (with timer 4 and 5).

This module manage the motors with two timers: timer4 (motor left) and timer5 (motor right).

Warning:
You can't use this module to control the motors if you are using the camera, because the camera's module also use timer4 and timer5.
A little exemple for the motors (e-puck turn on himself)
 #include <p30f6014A.h>
 #include <motor_led/e_epuck_ports.h>
 #include <motor_led/e_init_port.h>
 #include <motor_led/e_motors.h>
 
 int main(void)
 {
        e_init_motors();
        e_set_speed_left(500); //go forward on half speed
        e_set_speed_right(-500); //go backward on half speed
        while(1) {}
 }
Author:
Code: Michael Bonani, Francesco Mondada, Lucas Meier
Doc: Jonathan Besuchet

Function Documentation

void __attribute__ ( (interrupt, auto_psv, shadow)   ) 

int e_get_steps_left ( void   ) 

Give the number of left motor steps.

Returns:
The number of phases steps made since the left motor is running.

int e_get_steps_right ( void   ) 

Give the number of right motor steps.

Returns:
The number of phases steps made since the right motor is running.

void e_init_motors ( void   ) 

Initialize the motors's ports.

Initialize the motors's agendas.

This function initialize the ports used by the motors. In fact it call "the e_init_port()" function.

See also:
e_init_port

void e_set_speed_left ( int  motor_speed  ) 

Manage the left speed.

Manage the left motor speed.

This function manage the left motor speed by changing the MOTOR1 phases. The changing phases frequency (=> speed) is controled by the timer5.

Parameters:
motor_speed from -1000 to 1000 give the motor speed in steps/s, positive value to go forward and negative to go backward.

void e_set_speed_right ( int  motor_speed  ) 

Manage the right speed.

Manage the right motor speed.

This function manage the right motor speed by changing the MOTOR2 phases. The changing phases frequency (=> speed) is controled by the timer4.

Parameters:
motor_speed from -1000 to 1000 give the motor speed in steps/s, positive value to go forward and negative to go backward.

void e_set_steps_left ( int  set_steps  ) 

Set the number of left motor steps.

Parameters:
set_steps The number of changed phases that you want set.

void e_set_steps_right ( int  set_steps  ) 

Set the number of right motor steps.

Parameters:
set_steps The number of changed phases that you want set.


Variable Documentation

int left_speed = 0 [static]

int nbr_pas_left = 0 [static]

int nbr_pas_right = 0 [static]

int right_speed = 0 [static]


Generated on Fri Feb 29 14:26:54 2008 for e-puck by  doxygen 1.5.4