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

PIDController.cpp

Committer:
sbouber1
Date:
2016-06-14
Revision:
30:cf12566013a5
Parent:
29:2b256a7ce0ae
Child:
32:1e4919a44196

File content as of revision 30:cf12566013a5:

#include "PIDController.h"
#include "SalinityController.h"

// This is called in the main loop on every iteration
void PIDController::update() {
    // You can use the variables temp, salt and proximity like this:
    float s = this->salt->getValue();
    
    if(s < 6.0) {
        float sInGrams = this->getSaltInGrams();
        
        float ml = SalinityController::getMl(sInGrams, this->proximity->getValue());
    
        printf("PIDCONTROLLER: need to pump %.3f ml\r\n", ml);
        
        // MAYBE DO SOME ROUNDING HERE
    
        // DO SHIT WITH MOTORS AND STUFF
    
    }
}

std::string PIDController::get_name() {
    return "PIDController";
}

//get the salt in the body in grams
float PIDController::getSaltInGrams()
{
    float currentppt = this->salt->getValue(); //in ppt
    float currentvol = this->proximity->getValue(); //in ml
    
    return currentppt * (currentvol /1000);
}