00001 #ifndef AMPLIFIER_H 00002 #define AMPLIFIER_H 00003 00004 /* 00005 amplifier.h 00006 00007 Declarations for voltage amplifier 00008 00009 Set the voltage gain, max output current, and load resistance of motor 00010 attached to amplifier. runCycle will return the output voltage 00011 multiplied by the gain of the input voltage, checking for current limits, 00012 consistent with the enabled or reset state. 00013 00014 'enabled' means that runCycle will return amplified value. If not 00015 enabled, it will return 0. 'tripped' means that the output voltage 00016 calculated would have resulted in a current exceeding the value set 00017 by setMaxOutputCurrent(), for the motor resistance set by 00018 setLoadResistance(). 00019 00020 Modification history: 00021 00022 14-Apr-2000 WPS added _attribute__((unused)) to amplifier_h 00023 17-Mar-1998 FMP added section arg to amplifierIniLoad() 00024 18-Dec-1997 FMP took out C++ interface 00025 24-Apr-1997 FMP added amplifierIniLoad() 00026 17-Apr-1997 FMP split into C and C++ sections 00027 */ 00028 00029 /* ident tag */ 00030 #ifndef __GNUC__ 00031 #ifndef __attribute__ 00032 #define __attribute__(x) 00033 #endif 00034 #endif 00035 00036 static char __attribute__((unused)) amplifier_h[] = "$Id: amplifier.h,v 1.2 2000/10/27 20:34:42 terrylr Exp $"; 00037 00038 typedef struct 00039 { 00040 /* parameters */ 00041 double gain; /* multiplying gain for runCycle */ 00042 double maxOutputCurrent; /* output/loadResistance exceeds will trip */ 00043 double loadResistance; /* resistance of attached motor */ 00044 00045 /* internal vars */ 00046 int configured; /* non-zero means some params not set */ 00047 int enabled; /* zero means 0.0 output always */ 00048 int tripped; /* zero means 0.0 output always */ 00049 00050 } AMPLIFIER_STRUCT; 00051 00052 #ifdef __cplusplus 00053 extern "C" { 00054 #endif 00055 00056 extern int amplifierInit(AMPLIFIER_STRUCT * amp); 00057 extern int amplifierSetGain(AMPLIFIER_STRUCT * amp, double gain); 00058 extern double amplifierGetGain(AMPLIFIER_STRUCT * amp); 00059 extern int amplifierSetMaxOutputCurrent(AMPLIFIER_STRUCT * amp, double maxOutputCurrent); 00060 extern double amplifierGetMaxOutputCurrent(AMPLIFIER_STRUCT * amp); 00061 extern int amplifierSetLoadResistance(AMPLIFIER_STRUCT * amp, double loadResistance); 00062 extern double amplifierGetLoadResistance(AMPLIFIER_STRUCT * amp); 00063 00064 /* enables output */ 00065 extern int amplifierEnable(AMPLIFIER_STRUCT * amp); 00066 00067 /* disabled output */ 00068 extern int amplifierDisable(AMPLIFIER_STRUCT * amp); 00069 00070 /* 0 = disabled; non-zero = enabled, -1 = error */ 00071 extern int amplifierIsEnabled(AMPLIFIER_STRUCT * amp); 00072 00073 /* resets trip condition */ 00074 extern int amplifierReset(AMPLIFIER_STRUCT * amp); 00075 00076 /* 0 = not tripped; non-zero = tripped, -1 = error */ 00077 extern int amplifierIsTripped(AMPLIFIER_STRUCT * amp); 00078 00079 extern double amplifierRunCycle(AMPLIFIER_STRUCT * amp, double input); 00080 extern int amplifierIniLoad(AMPLIFIER_STRUCT * amp, const char * filename, const char *section); 00081 00082 #ifdef __cplusplus 00083 } 00084 #endif 00085 00086 #endif /* #ifndef AMPLIFIER_H */