Juan Salazar / robotic_fish_7

Dependencies:   mbed ESC mbed MODDMA

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PumpWithValve.h Source File

PumpWithValve.h

00001 
00002 /*
00003  * PumpWithValve.h
00004  *
00005  * Author: Cyndia Cao, Robert Katzschmann
00006  */
00007 
00008 #ifndef PUMPWITHVALVE_H_
00009 #define PUMPWITHVALVE_H_
00010 
00011 #include "mbed.h"
00012 
00013 #define valvePwmPin         p22
00014 #define pumpPwmPin          p23
00015 #define hallInterruptPin    p12
00016 //#define encoderPinA       p25
00017 //#define encoderPinB       p24
00018 //#define valveCurrentPin   p19
00019 
00020 #define count2rev           12
00021 #define valveMotorGearRatio 297.92
00022 #define KpFreq              10000.0 // frequency on the order of 10^-7
00023 #define KdFreq              0.00
00024 #define valveOffsetGain     0.5
00025 
00026 class PumpWithValve
00027 {
00028 public:
00029     // Initialization
00030     PumpWithValve();
00031     void start();
00032     void stop();
00033 
00034     void flipFlowUp();
00035     void flipFlowDown();
00036     void set(float freq_in, float yaw_in, float thrust_in);
00037     void setVoid();
00038 
00039     float getVset();
00040     bool getVside();
00041 
00042 protected:
00043     void calculateYawMethod1();
00044     void calculateYawMethod2();
00045 
00046 private:
00047 
00048     volatile float frequency;
00049     volatile float yaw;
00050     volatile float thrust;
00051     volatile float periodSide1;
00052     volatile float periodSide2;
00053 
00054     volatile bool   valveSide;
00055     volatile float  valveV1;
00056     volatile float  valveV2;
00057     volatile float  Vfreq;
00058     volatile float  VfreqAdjusted;
00059     volatile float  Vset;
00060 
00061     volatile float freqAct;
00062     volatile float freqErr;
00063     volatile float prevFreqErr;
00064     volatile float dVFreq;
00065 
00066     PwmOut pumpPWM;
00067     PwmOut valvePWM;
00068     //QEI valveEncoder;
00069     //AnalogIn valveCurrent; // actually is a voltage value proportional to current
00070     InterruptIn hallSignal;
00071     Timer timer;
00072     DigitalOut valveLED;
00073 
00074     Ticker valveControl;
00075 };
00076 
00077 // Create a static instance of PumpWithValve to be used by anyone controlling the pump with valve
00078 extern PumpWithValve pumpWithValve;
00079 
00080 #endif /* PUMPWITHVALVE_H_ */