summaryrefslogtreecommitdiff
path: root/digital/avr/modules/motor/control_system/control_system.h
blob: e8e6a4340290084b137a071840370a656c536d1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#ifndef control_system_h
#define control_system_h
/* control_system.h */
/* motor - Motor control module. {{{
 *
 * Copyright (C) 2011 Nicolas Schodet
 *
 * APBTeam:
 *        Web: http://apbteam.org/
 *      Email: team AT apbteam DOT org
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 * }}} */

#include "modules/motor/control_state/control_state.h"
#include "modules/motor/encoder/encoder.h"
#include "modules/motor/speed_control/speed_control.h"
#include "modules/motor/pos_control/pos_control.h"
#include "modules/motor/blocking_detection/blocking_detection.h"
#include "modules/motor/output/output.h"

/** Single motor control system. */
struct control_system_single_t
{
    control_state_t state;
    encoder_t *encoder;
    speed_control_t speed;
    pos_control_t pos;
    blocking_detection_t blocking_detection;
    output_t *output;
};
typedef struct control_system_single_t control_system_single_t;

/** Polar control system. */
struct control_system_polar_t
{
    control_state_t state;
    encoder_t *encoder_left;
    encoder_t *encoder_right;
    speed_control_t speed_theta;
    speed_control_t speed_alpha;
    pos_control_t pos_theta;
    pos_control_t pos_alpha;
    blocking_detection_t blocking_detection_theta;
    blocking_detection_t blocking_detection_alpha;
    output_t *output_left;
    output_t *output_right;
};
typedef struct control_system_polar_t control_system_polar_t;

/** Initialise single motor control system components. */
void
control_system_single_init (control_system_single_t *cs);

/** Initialise polar control system components. */
void
control_system_polar_init (control_system_polar_t *cs);

/** Prepare single motor control system update (update all non urgent
 * modules).  To be called before encoder is updated. */
void
control_system_single_update_prepare (control_system_single_t *cs);

/** Prepare polar control system update (update all non urgent modules).  To
 * be called before encoders are updated. */
void
control_system_polar_update_prepare (control_system_polar_t *cs);

/** Update single motor control system components (however do not update
 * encoder, neither output).  To be called after encoder is updated. */
void
control_system_single_update (control_system_single_t *cs);

/** Update polar control system components (however do not update encoder,
 * neither output).  To be called after encoders are updated. */
void
control_system_polar_update (control_system_polar_t *cs);

#endif /* control_system_h */