void TheveninMethod::calculateRthVth(AnalogInputs::ValueType oldValue) { tVout_.calculateRthVth(getVout(),oldValue); for(uint8_t c = 0; c < cells_; c++) { tBal_[c].calculateRthVth(balancer.getPresumedV(c),oldValue); } }
AnalogInputs::ValueType TheveninMethod::storeOldValue(AnalogInputs::ValueType oldValue) { tVout_.storeLast(getVout(), oldValue); for(uint8_t i = 0; i < cells_; i++) { AnalogInputs::ValueType vi = balancer.getPresumedV(i); tBal_[i].storeLast(vi, oldValue); } }
void TheveninMethod::init() { AnalogInputs::ValueType Vout = getVout(); tVout_.init(Vout, Vend_, minValue_); cells_ = balancer.getCells(); AnalogInputs::ValueType Vend_per_cell = balancer.calculatePerCell(Vend_); for(uint8_t c = 0; c < cells_; c++) { AnalogInputs::ValueType v = balancer.getPresumedV(c); tBal_[c].init(v, Vend_per_cell, minValue_); } Ifalling_ = NotFalling; fullCount_ = 0; }
uint16_t CurrentSensor::getCapacity(float* _current) { startTime = endTime; getVout(); //getVcc(); endTime = millis(); //current = 36.7*((float)Vout / (float)Vcc) - 18.3 + 0.2; current = 7.7054*Vout - 3.8841; current = constrain(current, 0.0, 50.0); *_current = current; capacity += ((float)endTime - (float)startTime)*current / 1000; currentMillis = millis(); if (currentMillis - previousMillis > 10000) { //every 10sec previousMillis = currentMillis; eeprom_update_word((uint16_t*)15, (uint16_t)capacity); eeprom_busy_wait(); } return (uint16_t)capacity; }