embedded system library for e-puck  1.0.1
A redesigned API library for the e-puck robot platform
 All Data Structures Files Functions Variables Enumerations Enumerator Modules Pages
Data Structures | Macros | Functions
el_stepper_motor.h File Reference
#include "el_common.h"

Go to the source code of this file.

Data Structures

struct  el_stepper_motor_param
 

Macros

#define EL_STEPPER_MOTOR_RATE_MAX   1000
 
#define EL_STEPPER_MOTOR_RATE_MIN   50
 
#define EL_STEPPER_MOTOR_LEFT   0
 
#define EL_STEPPER_MOTOR_RIGHT   1
 
#define EL_EPUCK_FULL_REVOLUTION_STEPS   2512
 

Functions

void el_enable_stepper_motor (void)
 enable the stepper motor module
 
void el_disable_stepper_motor (void)
 disable the stepper motor module
 
el_stepper_motor_paramel_stepper_motor_options ()
 get the pointer to a static instance of el_stepper_motor_param More...
 
void el_stepper_motor_options_apply ()
 apply the settings stored in el_stepper_motor_options directly More...
 
void el_stepper_motor_options_reset ()
 reset the settings stored in el_stepper_motor_options to default More...
 
void el_config_stepper_motor (const el_stepper_motor_param *p)
 apply the settings in the given structure More...
 
void el_stepper_motor_set_speed (el_index i, int u)
 set the stepping rate and direction of a motor More...
 
el_int16 el_stepper_motor_get_steps (el_index i)
 get the step counter of a motor More...
 
void el_stepper_motor_set_steps (el_index i, el_int16 n)
 set the step counter of a motor More...
 
void el_set_wheel_speed (int left, int right)
 change the rotation speed for both of the motors on the e-puck More...
 

Detailed Description

Author
Jianing Chen

Function Documentation

el_stepper_motor_param* el_stepper_motor_options ( )

get the pointer to a static instance of el_stepper_motor_param

Returns
the pointer
void el_stepper_motor_options_apply ( )

apply the settings stored in el_stepper_motor_options directly

This function is equivalent to "el_config_stepper_motor( el_stepper_motor_options() )".

void el_stepper_motor_options_reset ( )

reset the settings stored in el_stepper_motor_options to default

This function can be used in combination with el_stepper_motor_options_apply when the default configuration need to be used.

void el_config_stepper_motor ( const el_stepper_motor_param p)

apply the settings in the given structure

Parameters
ppointer to the data structure containing all parameters

Currently, the parameters are mainly related to the artificial acceleration of the stepper motors, which are typically used to make the motion of the robot more smooth.

For example, the following code enables a linear artificial acceleration with a rate of 2000:

1 el_stepper_motor_options()->UseAcceleration = true;
2 el_stepper_motor_options()->AccelerationRate = 2000;
3 el_config_stepper_motor( el_stepper_motor_options() );

A linear acceleration rate of 2000 means the stepping rate of the motors can reach 1000 from 0 in 0.5 sec. By default, the artificial acceleration is enabled and the acceleration rate is 3000.

void el_stepper_motor_set_speed ( el_index  i,
int  u 
)

set the stepping rate and direction of a motor

Parameters
iindex of the motor
ustepping rate of the motor

The valid range of the stepping speed is in [-1000,-50] and [50,1000]. This function does handle the range issue internally.

el_int16 el_stepper_motor_get_steps ( el_index  i)

get the step counter of a motor

Parameters
iindex of the motor
Returns
number of steps

Note: negative motor speeds contribute negative number of steps.

void el_stepper_motor_set_steps ( el_index  i,
el_int16  n 
)

set the step counter of a motor

Parameters
iindex of the motor
unumber of steps
void el_set_wheel_speed ( int  left,
int  right 
)

change the rotation speed for both of the motors on the e-puck

Parameters
leftleft motor speed
rightright motor speed

This function does virtually the same thing as el_stepper_motor_set_speed in just one line.