- Main Page
- Modules
- Data Structures
- Files
- Directories

# Ports, motors and LEDs

## Files
file | e_agenda.c
| Manage the agendas (timer2).

file | e_agenda.h
| Manage the agendas (timer2).

file | e_led.c
| Manage the LEDs with blinking possibility (timer2).

file | e_led.h
| Manage the LEDs with blinking possibility (timer2).

file | e_motors.c
| Manage the motors (with timer2).

file | e_motors.h
| Manage the motors (with timer2).

file | e_remote_control.c
| Manage the IR receiver module (timer2).

file | e_remote_control.h
| Manage the LEDs with blinking possibility (timer2).

file | e_remote_control.h
| Manage the LEDs with blinking possibility (timer2).

file | e_agenda_fast.c
| Manage the fast agendas (timer1, 2, 3).

file | e_agenda_fast.h
| Manage the fast agendas (timer1, 2, 3).

file | e_led.c
| Manage the LEDs with blinking possibility (timer1, 2, 3).

file | e_led.h
| Manage the LEDs with blinking possibility (timer1, 2, 3).

file | e_motors.c
| Manage the motors (with timer1, 2, 3).

file | e_motors.h
| Manage the motors (with timer1, 2, 3).

file | e_epuck_ports.h
| Define all the usefull names corresponding of e-puck's hardware.

file | e_init_port.c
| Initialize the ports on standard configuration.

file | e_init_port.h
| Initialize the ports on standard configuration.

file | e_led.c
| Manage the LEDs. A little exemple for the LEDs (all the LEDs are blinking).

file | e_led.h
| Manage the LEDs. A little exemple for the LEDs (all the LEDs are blinking).

file | e_motors.c
| Manage the motors (with timer 4 and 5).

file | e_motors.h
| Manage the motors (with timer 4 and 5).

file | e_motors_timer3.c
| Initialize the ports on standard configuration.

file | e_motors_timer3.c
| Initialize the ports on standard configuration.

## Detailed Description

## Introduction

This package contains all the resources you need to control the ports, the motors, the LED and the IR receiver of the e-puck.

### Ports

The standard port's name of the p30f6014A microcontroller is not explicit in the e-puck context, so we need to redefine these names to make them more user friendly.
This work is made in the file: e_epuck_ports.h.

### Motors

The e-puck has two step by step motors called MOTOR1 (left) and MOTOR2 (right). To control the changing phase's sequence of these motors we need to use timers. Four possibilities are offered to you:

- standard: we use the timer4 for MOTOR2 and timer5 for MOTOR1. This solution is exploited by the file library\motor_led\e_motors.c.
- one timer standard: we use the timer3 for both MOTOR1 and MOTOR2. This solution is exploited by the file library\motor_led\e_motors_timer3.c
- advance one timer: we use the timer2 for both MOTOR1 and MOTOR2, but this time the mechanism work on the agenda method (see below or e_agenda.h for more information about agenda). This solution is exploited by the file library\motor_led\advance_one_timer\e_motors.c.
- fast agenda: we use the timer1,2,3 for both MOTOR1 and MOTOR2, but this time the mechanism work on the fast_agenda method (see below or e_agenda_fast.h for more information about fast_agenda). This solution is exploited by the file library\motor_led\advance_one_timer\fast_agenda\e_motors.c.

### LED

The e-puck has 8 reds LEDs, a front LED and a body LED. All the functions needed to control these LEDs are in the file library\motor_led\e_led.c. This file is made for basics use. If you want blinking functions you have to work with these following files: library\motor_led\advance_one_timer\e_led.c or library\motor_led\advance_one_timer\fast_agenda\e_led.c. In the case you will work with agenda solution (see below or e_agenda.h or e_agenda_fast.h for more information about agenda or fast agenda).

### IR remote

The e-puck has a IR receptor. To control this receptor look at this file: library\motor_led\advance_one_timer\e_remote_control.c.

Warning:
  The IR remote uses the agenda solution, then it use timer2 (see below or e_agenda.h for more information about agenda).

## Timer's problems

The p30f6014A microcontroller has five timers. The camera's package uses the timer4 and the timer5, so we can't exploit them to make the motors work when we want to use the camera. For this reason we can't use the standard solution above.

Warning:
  If you are using the camera, you have to work with one of this three solutions explained above:
  - one timer standard
  - advance one timer
  - fast agenda

## Agenda solution

As we have seen, we can use the agenda solution to make the motors work.
So what is an agenda ?
An agenda is a structure which can launch a specific function (called callback function) with a given intervals. The agenda structure is made to work as chained list.
How it works ?
You create an agenda by specifying:

- the callback function you will call
- the delay between two calls
- the next element of the chained list

On each timer overflow all the agenda chained list is scanned and if an agenda in the list has reached the delay, then the callback function is called.

See also:
  e_agenda.c, e_agenda_fast.c

Author:
  Doc: Jonathan Besuchet