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

dcmotor2.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: dcmotor2.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 
00054 
00055   double a,b,c;                 /* Quadtratic coefficetients. */
00056   double fourac_minus_b_squared;
00057   double sa_real,sb_real, sa_img, sb_img;                       /* Quadratic solutions. */
00058   double sa_time_factor, sb_time_factor;
00059 
00060   int order;                    /* Is this a first order or second order system.  */
00061   double wo,dwo;                /* angular velocity of motor and it's derivativ at time t =0. */
00062   double last_ea;               /* last applied voltage */
00063   double A;
00064   double B;
00065   double delta_thm;             /* difference in position over the cycle,
00066                                  NOT the same as instantaneous angular velocity  times cycle time. */
00067 
00068   /* state vars */
00069   double ia;                    /* armature current */
00070   double dia;                   /* derivative of above */
00071   double wm;                    /* angular velocity of motor */
00072   double dwm;                   /* derivative of above */
00073   double thm;                   /* angular position of motor */
00074   double dthm;                  /* derivative of above */
00075   double lastTime;              /* timestamp of last cycle */
00076 
00077   /* internal vars */
00078   int configured;
00079   double cycleTime;             /* copy of arg to setCycleTime() */
00080   double offset;
00081   double revsPerUnit;
00082 
00083 } DC_MOTOR_STRUCT;
00084 
00085 
00086 #ifdef __cplusplus
00087 extern "C" {
00088 #endif
00089 
00090 extern int dcmotorInit(DC_MOTOR_STRUCT * dcmotor);
00091 extern int dcmotorResetState(DC_MOTOR_STRUCT * dcmotor);
00092 extern int dcmotorSetCycleTime(DC_MOTOR_STRUCT * dcmotor, double seconds);
00093 extern double dcmotorGetCycleTime(DC_MOTOR_STRUCT * dcmotor);
00094 extern int dcmotorSetParameters(DC_MOTOR_STRUCT * dcmotor, DC_MOTOR_STRUCT params);
00095 extern DC_MOTOR_STRUCT dcmotorGetParameters(DC_MOTOR_STRUCT * dcmotor);
00096 extern int dcmotorSetOffset(DC_MOTOR_STRUCT * dcmotor, double _offset);
00097 extern double dcmotorGetOffset(DC_MOTOR_STRUCT * dcmotor);
00098 extern int dcmotorSetRevsPerUnit(DC_MOTOR_STRUCT * dcmotor, double _revsPerUnit);
00099 extern double dcmotorGetRevsPerUnit(DC_MOTOR_STRUCT * dcmotor);
00100 extern double dcmotorGetOutput(DC_MOTOR_STRUCT * dcmotor);
00101 extern double dcmotorRunCycle(volatile DC_MOTOR_STRUCT * dcmotor, volatile double ea);
00102 extern int dcmotorIniLoad(DC_MOTOR_STRUCT * dcmotor, const char * filename, const char *section);
00103 
00104 #ifdef __cplusplus
00105 }
00106 #endif
00107 
00108 #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