Elisa3
|
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 () |
Motors module.
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).
signed int cast_speed | ( | signed int | vel | ) |
signed int getInputFromSpeed | ( | signed int | s, |
unsigned char | mode | ||
) |
void getLeftSpeedFromInput | ( | ) |
void getRightSpeedFromInput | ( | ) |
void handleCalibration | ( | ) |
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 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 initCalibration | ( | ) |
void initMotors | ( | ) |
Configure the timer3 and timer4 registers to work at about 122 Hz.
void setLeftSpeed | ( | signed char | vel | ) |
Set the desired speed for the left motor.
vel | desired velocity to set (from -100 to 100) |
void setRightSpeed | ( | signed char | vel | ) |
Set the desired speed for the right motor.
vel | desired velocity to set (from -100 to 100) |
void updateOdomData | ( | ) |
void writeDefaultCalibration | ( | ) |