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
el_stepper_motor.h
Go to the documentation of this file.
1 /*
2 
3 embedded system library for e-puck
4 
5 --------------------------------------------------------------------------------
6 
7 code distribution:
8 https://github.com/jianingchen/epucklib
9 
10 online documentation:
11 http://jianingchen.github.io/epucklib/html/
12 
13 --------------------------------------------------------------------------------
14 
15 This file is released under the terms of the MIT license (see "el.h").
16 
17 */
18 
28 #ifndef EL_STEPPER_MOTOR_H
29 #define EL_STEPPER_MOTOR_H
30 
31 #include "el_common.h"
32 
33 // stepper motor rate is in range [-max,-min] and [min,max]
34 #define EL_STEPPER_MOTOR_RATE_MAX 1000
35 #define EL_STEPPER_MOTOR_RATE_MIN 50
36 
37 #define EL_STEPPER_MOTOR_LEFT 0
38 #define EL_STEPPER_MOTOR_RIGHT 1
39 
40 #define EL_EPUCK_FULL_REVOLUTION_STEPS 2512
41 
47 typedef struct {
48  el_bool UseAcceleration;
49  el_uint16 AccelerationRate;
51 
52 /*
53 --------------------------------------------------------------------------------
54 */
55 
59 void el_enable_stepper_motor(void);
60 
61 
65 void el_disable_stepper_motor(void);
66 
67 
74 
75 
82 
83 
91 
92 
114 
115 
125 void el_stepper_motor_set_speed(el_index i,int u);
126 
127 
137 el_int16 el_stepper_motor_get_steps(el_index i);
138 
139 
147 void el_stepper_motor_set_steps(el_index i,el_int16 n);
148 
149 
159 void el_set_wheel_speed(int left,int right);
160 
161 
162 //==============================================================================
163 
164 
165 #ifdef EL_INCLUDE_LIB_INTERNAL_CONTEXT
166 
167 #include "el_clock.h"
168 
169 #define EL_STPM_NUMBER 2
170 #define EL_STPM_DIR_STOP 0
171 #define EL_STPM_DIR_FORWARD 1
172 #define EL_STPM_DIR_REVERSE 2
173 #define EL_STPM_INTERRUPT_FREQ EL_T3_FREQ
174 #define EL_STPM_SPEED_CONTROL_FREQ 50
175 
176 typedef struct{
177  el_int8 direction;
178  el_int8 phase;
179  el_mcd period;
180  el_mcd timer;
181  el_int16 counter;
182  el_int16 true_speed;
183  el_int16 ref_speed;
184 } el_stpm;
185 
186 extern el_bool el_stpm_enabled;
187 extern el_bool el_stpm_accel_enabled;
188 
189 void el_init_stepper_motor();
190 void el_routine_stepper_motor_14400hz();
191 void el_routine_stepper_motor_accel_2400hz();
192 
193 #endif
194 
195 
196 #endif
void el_stepper_motor_set_steps(el_index i, el_int16 n)
set the step counter of a motor
void el_enable_stepper_motor(void)
enable the stepper motor module
void el_set_wheel_speed(int left, int right)
change the rotation speed for both of the motors on the e-puck
Definition: el_stepper_motor.h:47
void el_stepper_motor_set_speed(el_index i, int u)
set the stepping rate and direction of a motor
void el_stepper_motor_options_apply()
apply the settings stored in el_stepper_motor_options directly
void el_stepper_motor_options_reset()
reset the settings stored in el_stepper_motor_options to default
void el_disable_stepper_motor(void)
disable the stepper motor module
el_int16 el_stepper_motor_get_steps(el_index i)
get the step counter of a motor
el_stepper_motor_param * el_stepper_motor_options()
get the pointer to a static instance of el_stepper_motor_param
void el_config_stepper_motor(const el_stepper_motor_param *p)
apply the settings in the given structure