Program for the water play project for the course Software Testing Practical 2016 given at the VU University

Dependencies:   mbed DRV88255 TextLCD Ping mbed-rtos

Committer:
sbouber1
Date:
Tue Jun 14 10:26:03 2016 +0000
Revision:
30:cf12566013a5
Parent:
29:2b256a7ce0ae
Child:
32:1e4919a44196
more tests

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sbouber1 28:f4a4ee58d57e 1 #include "PIDController.h"
sbouber1 30:cf12566013a5 2 #include "SalinityController.h"
sbouber1 28:f4a4ee58d57e 3
sbouber1 28:f4a4ee58d57e 4 // This is called in the main loop on every iteration
sbouber1 28:f4a4ee58d57e 5 void PIDController::update() {
sbouber1 28:f4a4ee58d57e 6 // You can use the variables temp, salt and proximity like this:
sbouber1 28:f4a4ee58d57e 7 float s = this->salt->getValue();
sbouber1 30:cf12566013a5 8
sbouber1 30:cf12566013a5 9 if(s < 6.0) {
sbouber1 30:cf12566013a5 10 float sInGrams = this->getSaltInGrams();
sbouber1 30:cf12566013a5 11
sbouber1 30:cf12566013a5 12 float ml = SalinityController::getMl(sInGrams, this->proximity->getValue());
sbouber1 30:cf12566013a5 13
sbouber1 30:cf12566013a5 14 printf("PIDCONTROLLER: need to pump %.3f ml\r\n", ml);
sbouber1 30:cf12566013a5 15
sbouber1 30:cf12566013a5 16 // MAYBE DO SOME ROUNDING HERE
sbouber1 30:cf12566013a5 17
sbouber1 30:cf12566013a5 18 // DO SHIT WITH MOTORS AND STUFF
sbouber1 30:cf12566013a5 19
sbouber1 30:cf12566013a5 20 }
sbouber1 28:f4a4ee58d57e 21 }
sbouber1 28:f4a4ee58d57e 22
sbouber1 28:f4a4ee58d57e 23 std::string PIDController::get_name() {
sbouber1 30:cf12566013a5 24 return "PIDController";
sbouber1 28:f4a4ee58d57e 25 }
sbouber1 28:f4a4ee58d57e 26
joran 29:2b256a7ce0ae 27 //get the salt in the body in grams
joran 29:2b256a7ce0ae 28 float PIDController::getSaltInGrams()
joran 29:2b256a7ce0ae 29 {
joran 29:2b256a7ce0ae 30 float currentppt = this->salt->getValue(); //in ppt
joran 29:2b256a7ce0ae 31 float currentvol = this->proximity->getValue(); //in ml
joran 29:2b256a7ce0ae 32
joran 29:2b256a7ce0ae 33 return currentppt * (currentvol /1000);
joran 29:2b256a7ce0ae 34 }
joran 29:2b256a7ce0ae 35
joran 29:2b256a7ce0ae 36
joran 29:2b256a7ce0ae 37