Elisa3
motors.h File Reference

Motors module. More...

#include "variables.h"
#include <avr\io.h>
#include <avr\interrupt.h>
#include "behaviors.h"
#include "speed_control.h"
#include "utility.h"
#include "eepromIO.h"

Go to the source code of this file.

Functions

void initMotors ()
 Configure the timer3 and timer4 registers to work at about 122 Hz.
void handleMotorsWithSpeedController ()
 Change the motors speed (pwm registers) accordingly to the obstacle avoidance (if enabled). In this function both the motors velocities measurements are also updated (even if not needed).
void handleMotorsWithNoController ()
 Change the motors speed (pwm registers) accordingly to the obstacle avoidance (if enabled) and speed controller. In this function both the motors velocities measurements are also updated.
void setLeftSpeed (signed char vel)
 Set the desired speed for the left motor.
void setRightSpeed (signed char vel)
 Set the desired speed for the right motor.
void handleCalibration ()
void updateOdomData ()
void initCalibration ()
signed int getInputFromSpeed (signed int s, unsigned char mode)
signed int cast_speed (signed int vel)
void getLeftSpeedFromInput ()
void getRightSpeedFromInput ()
void writeDefaultCalibration ()

Detailed Description

Motors module.

Author:
Stefano Morgani <stefano@gctronic.com>
Version:
1.0
Date:
01.02.12

The motors are handled with two timers: timer3 for right motor and timer4 for left motor. Two independent timers are needed because the timer will reset when the output compare register matches the timer value. The settings for the two timers are the same; the related pwm frequency is 122 Hz and the duty cycle define the motors speed. In order to measure the consumption and speed of the motors respectively in the active and passive phase of the pwm, two interrupts per timer are generated: one at the beginning of the cycle (timer overflow) and another one when when the output compare matches (beginning of passive phase).


Function Documentation

signed int cast_speed ( signed int  vel)
signed int getInputFromSpeed ( signed int  s,
unsigned char  mode 
)

Change the motors speed (pwm registers) accordingly to the obstacle avoidance (if enabled) and speed controller. In this function both the motors velocities measurements are also updated.

Returns:
none

Change the motors speed (pwm registers) accordingly to the obstacle avoidance (if enabled). In this function both the motors velocities measurements are also updated (even if not needed).

Returns:
none
void initCalibration ( )
void initMotors ( )

Configure the timer3 and timer4 registers to work at about 122 Hz.

Returns:
none
void setLeftSpeed ( signed char  vel)

Set the desired speed for the left motor.

Parameters:
veldesired velocity to set (from -100 to 100)
Returns:
none
void setRightSpeed ( signed char  vel)

Set the desired speed for the right motor.

Parameters:
veldesired velocity to set (from -100 to 100)
Returns:
none
void updateOdomData ( )
 All Files Functions Variables Defines