Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

dcmotor.h

Go to the documentation of this file.
00001 #ifndef DCMOTOR_H
00002 #define DCMOTOR_H
00003 
00004 /*
00005    dcmotor.h
00006 
00007    DC motor simulation interface
00008 
00009    From Benjamin C. Kuo, "Automatic Control Systems," Fourth Edition,
00010    pp. 176-186.
00011 
00012    Units are SI for all quantities. Note that back EMF constant Kb is
00013    identically equal to Torque Constant in SI units, so Ki is omitted
00014    from interface and replaced with Kb in calculations.
00015 
00016    Handy conversion factors:
00017 
00018    pounds (force) * 9.81/2.2 = newtons
00019    oz-in * 0.00708 = newton-meters
00020    foot-pounds * 1.359 = newton-meters
00021 
00022    Modification history:
00023 
00024    14-Apr-2000 WPS added __attribute__((unused))  to dcmotor_h
00025    27-Jan-1999 WPS added "volatile"'s to avoid NT optimization problem.
00026    17-Mar-1998  FMP added section arg to dcmotorIniLoad()
00027    18-Dec-1997  FMP took out C++ interface
00028    9-Sep-1997  FMP added dcmotorResetState();
00029    25-Apr-1997  FMP added lastTime
00030    24-Apr-1997  FMP added dcmotorIniLoad(); removed inifile
00031    17-Apr-1997  FMP split into C and C++ parts
00032    25-Oct-1996  FMP created
00033    */
00034 
00035 /* ident tag */
00036 #ifndef __GNUC__
00037 #ifndef __attribute__
00038 #define __attribute__(x)
00039 #endif
00040 #endif
00041 
00042 static char __attribute__((unused)) dcmotor_h[] = "$Id: dcmotor.h,v 1.2 2000/10/27 20:34:42 terrylr Exp $";
00043 
00044 typedef struct
00045 {
00046   /* parameters */
00047   double Ra;                    /* armature resistance, ohms */
00048   double La;                    /* armature inductance, henries */
00049   double Kb;                    /* back emf constant, V/rad/s, N-m/amp */
00050   double Jm;                    /* motor rotor inertia, N-m-s^2 */
00051   double Bm;                    /* viscous friction coefficient, N-m/rad/sec */
00052 
00053   /* state vars */
00054   double ia;                    /* armature current */
00055   double dia;                   /* derivative of above */
00056   double wm;                    /* angular velocity of motor */
00057   double dwm;                   /* derivative of above */
00058   double thm;                   /* angular position of motor */
00059   double dthm;                  /* derivative of above */
00060   double lastTime;              /* timestamp of last cycle */
00061 
00062   /* internal vars */
00063   int configured;
00064   double cycleTime;             /* copy of arg to setCycleTime() */
00065   double offset;
00066   double revsPerUnit;
00067 
00068 } DC_MOTOR_STRUCT;
00069 
00070 
00071 #ifdef __cplusplus
00072 extern "C" {
00073 #endif
00074 
00075 extern int dcmotorInit(DC_MOTOR_STRUCT * dcmotor);
00076 extern int dcmotorResetState(DC_MOTOR_STRUCT * dcmotor);
00077 extern int dcmotorSetCycleTime(DC_MOTOR_STRUCT * dcmotor, double seconds);
00078 extern double dcmotorGetCycleTime(DC_MOTOR_STRUCT * dcmotor);
00079 extern int dcmotorSetParameters(DC_MOTOR_STRUCT * dcmotor, DC_MOTOR_STRUCT params);
00080 extern DC_MOTOR_STRUCT dcmotorGetParameters(DC_MOTOR_STRUCT * dcmotor);
00081 extern int dcmotorSetOffset(DC_MOTOR_STRUCT * dcmotor, double _offset);
00082 extern double dcmotorGetOffset(DC_MOTOR_STRUCT * dcmotor);
00083 extern int dcmotorSetRevsPerUnit(DC_MOTOR_STRUCT * dcmotor, double _revsPerUnit);
00084 extern double dcmotorGetRevsPerUnit(DC_MOTOR_STRUCT * dcmotor);
00085 extern double dcmotorGetOutput(DC_MOTOR_STRUCT * dcmotor);
00086 extern double dcmotorRunCycle(volatile DC_MOTOR_STRUCT * dcmotor, volatile double ea);
00087 extern int dcmotorIniLoad(DC_MOTOR_STRUCT * dcmotor, const char * filename, const char *section);
00088 
00089 #ifdef __cplusplus
00090 }
00091 #endif
00092 
00093 #endif /* DCMOTOR_H */

Generated on Sun Dec 2 15:27:36 2001 for EMC by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001