summaryrefslogtreecommitdiffhomepage
path: root/digital/asserv/src/asserv/motor_model.host.h
blob: 283b6fd610721304eb92e359eaff55d01996d99d (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
#ifndef motor_model_host_h
#define motor_model_host_h
/* motor_model.host.h - DC motor model. */
/* asserv - Position & speed motor control on AVR. {{{
 *
 * Copyright (C) 2006 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.
 *
 * }}} */

/** Motor and load characteristics. */
struct motor_def_t
{
    /* Motor characteristics. */
    double Ke;	/* Speed constant ((rad/s)/V). */
    double Kt;	/* Torque constant (N.m/A). */
    double Rf;	/* Bearing friction (N.m/(rad/s)). */
    double R;	/* Terminal resistance (Ohm). */
    double L;	/* Terminal inductance (H). */
    double u_max;/* Maximum voltage (V). */
    /* Gearbox characteristics. */
    double i_G;	/* Gearbox ratio. */
    double ro_G;/* Gearbox efficiency. */
    /* Load characteristics. */
    double J;	/* Load at gearbox output (kg.m^2). */
    /* Hardware limits (use +/-INFINITY for none). */
    double th_min; /* Minimum theta value. */
    double th_max; /* Maximum theta value. */
};

/** Motor and load characteristics and current data.  Angular speed and theta
 * are at motor output, not gearbox output. */
struct motor_t
{
    /* Motor and load characteristics. */
    struct motor_def_t m;
    /* Simulation parameters. */
    double h;	/* Simulation time step (s). */
    int d;	/* Simulation time step division. */
    /* Simulation current state. */
    double t;	/* Current time (not really used) (s). */
    double u;	/* Current input voltage (V). */
    double i;	/* Current current (A). */
    double o;	/* Current angular speed (o for omega) (rad/s). */
    double th;	/* Current theta (th for theta) (rad). */
};

/** Make a simulation step. */
void motor_model_step (struct motor_t *m);

#endif /* motor_model_host_h */