dc_motor.c File Reference

DC motor driver (implementation). More...

#include "dc_motor.h"
#include "hw/hw_dc_motor.h"
#include <algo/pid_control.h>
#include <drv/timer.h>
#include <drv/adc.h>
#include <cfg/debug.h>
#include <kern/proc.h>

Go to the source code of this file.


Functions

static void NORETURN dc_motor_poll (void)
 Process to poll DC motor status.
void dc_motor_setDir (int index, bool dir)
 Set spin direction of DC motor.
void dc_motor_setSpeed (int index, dc_speed_t speed)
 Set DC motor speed.
void dc_motor_enable (int index, bool state)
 Enable or disable dc motor.
void dc_motor_setup (int index, DCMotorConfig *dcm_conf)
 Apply a confinguration to select DC motor.
void dc_motor_init (void)
 Init DC motor.

Variables

static DCMotor dcm_all [CONFIG_NUM_DC_MOTOR]
 DC motor definition.
static cpu_stack_t dc_motor_poll_stack [200]
 Stack process for DC motor poll.

Detailed Description

DC motor driver (implementation).

Thi module provide a simple api to controll a DC motor in direction and speed, to allow this we use a Back-EMF technique.

TODO: write a brief..

Author:
Daniele Basile <asterix@develer.com>

Definition in file dc_motor.c.


Function Documentation

static void NORETURN dc_motor_poll ( void   )  [static]

Process to poll DC motor status.

To use a Back-EMF technique (see brief for more details), we turn off a motor for max_sample_delay, that value are stored in each DC motor config. For this implementation we assume that have a common max_sample_delay, choose among a max delay to all DC motor configuration. The DC motor off time is choose to allow the out signal to be stable, so we can read and process this value for feedback controll loop. The period (sample_period - max_sample_delay) that every time we turn off a DC motor is choose to have a feedback controll more responsive or less responsive.

Definition at line 93 of file dc_motor.c.

void dc_motor_setDir ( int  index,
bool  dir 
)

Set spin direction of DC motor.

index number of DC motor dir direction of DC motor

Definition at line 191 of file dc_motor.c.


Variable Documentation

cpu_stack_t dc_motor_poll_stack[200] [static]

Stack process for DC motor poll.

Sample period for all DC motor.

Definition at line 70 of file dc_motor.c.