Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BufferedSerial FastPWM mbed
controlt.cpp
00001 /* 00002 * controlt.cpp 00003 * 00004 * Created on: 2016. 2. 19. 00005 * Author: sbh9428 00006 */ 00007 00008 #include "controlt.h" 00009 00010 control_t::control_t() { 00011 // TODO Auto-generated constructor stub 00012 00013 } 00014 00015 control_t::control_t(pump_t *_dry, pump_t *_wet, humSensor_t *humSensor, BufferedSerial *_pc) 00016 { 00017 dry=_dry; 00018 wet=_wet; 00019 00020 pc=_pc; 00021 00022 mode=0; 00023 } 00024 00025 control_t::~control_t() { 00026 // TODO Auto-generated destructor stub 00027 } 00028 00029 void control_t::setP(float _P) 00030 { 00031 P=_P; 00032 } 00033 00034 void control_t::setI(float _I) 00035 { 00036 I=_I; 00037 } 00038 00039 void control_t::setD(float _D) 00040 { 00041 D=_D; 00042 } 00043 00044 void control_t::setMode(int _mode) 00045 { 00046 mode=_mode; 00047 } 00048 00049 void control_t::setPower(float _power) 00050 { 00051 power=_power; 00052 } 00053 00054 void control_t::setRatio(float _ratio) 00055 { 00056 ratio=_ratio; 00057 } 00058 00059 float control_t::getP() 00060 { 00061 return P; 00062 } 00063 00064 float control_t::getI() 00065 { 00066 return I; 00067 } 00068 00069 float control_t::getD() 00070 { 00071 return D; 00072 } 00073 00074 int control_t::getMode() 00075 { 00076 return D; 00077 } 00078 00079 float control_t::getPower() 00080 { 00081 return power; 00082 } 00083 float control_t::getRatio() 00084 { 00085 return ratio; 00086 } 00087 00088 void control_t::refreshPWM() 00089 { 00090 humidity=humSensor->getHumidity(); 00091 switch(mode) 00092 { 00093 case 0: 00094 dry->setPWM(0); 00095 wet->setPWM(0); 00096 break; 00097 case 1: 00098 dryValue=power*(1-ratio); 00099 wetValue=power*ratio; 00100 dry->setPWM(dryValue); 00101 wet->setPWM(wetValue); 00102 break; 00103 00104 00105 } 00106 printf("%d %1.3f %1.3f\n", mode, dryValue, wetValue); 00107 } 00108
Generated on Fri Jul 15 2022 04:27:40 by
1.7.2